Back in August, I had the pleasure of speaking at NDC Sydney, which I wrote about in a previous post. The videos of those talks are now both available and shown below. The first in my .NET Data Security talk about cryptography and the 2nd video is my social engineering talk.
I recently released my latest (7th) course over at Pluralsight called RabbitMQ by Example. This course shows you how to make full use of RabbitMQ in your .NET applications. RabbitMQ is a very powerful messaging broker and this course takes a practical look at how to use it by showing you how to build a payments system.
Here is the official course description :
In this course, RabbitMQ by Example, you will see how to use RabbitMQ by using practical examples featuring a fictional company and a software development scenario based around taking card payments and purchase order payments. You’ll start with an introduction to RabbitMQ and how it compares to Windows’ default queue technology, MSMQ. As well as looking at RabbitMQ specifically, you will look at message queuing architectures, micro services, and how RabbitMQ can work as a broker for handling asynchronous and synchronous messages in this architecture. You will also get to explore the use of the topics exchange for routing and synchronous remote procedure calls. By the end of this course, you’ll be ready to use RabbitMQ in your .NET applications.
The course is split into 8 modules
- Introducing RabbitMQ
- Introducing RabbitMQ Exchanges
- Understanding Queuing Architecture
- Implementing Microservices and Message Queueing
- Installing and Configuring RabbitMQ
- Implementing Queueing Code
- Course Summary
The example application built in this course is based around the concept of Microservices, so this is a great use case for modern enterprise application development. The feedback from the course so far has been excellent as it has been getting very good ratings, so I am glad that it is helping people.
The Video recording of my talk at NDC London is now available to watch on-line. This was my first major conference so it was a little scary, but I really enjoyed the experience. The room was about 2 thirds full and I got an excellent speaker rating at the end so I must have done something right.
Yesterday I did a new talk on Code Metrics and Static Code Analysis at my usergroup Derbyshire DotNet. The talk seemed to go down well and there were some interesting discussions about code quality and the meaning of quality to people in different industries.
I have made the slides available from this link to anyone that wants them for reference.
Now that we have covered a lot of the introductory material for RabbitMQ, this part of the series will look at developing software to interact with the message broker as both a producer and a consumer. First we will take a look at the RabbitMQ client library. Then we will introduce the business scenario used for the sample applications. Before we start looking at the individual examples we will take a quick look at the common code shared between them. Then we will move onto the actual code examples themselves.
The code for this series can be found here.
These example will include:
- Basic queues
- Worker queues
- Publisher and subscribers
- Direct routing of queues
- Topic based publisher and subscribers
- Remote procedure calls
RabbitMQ client library
To develop software against RabbitMQ you will need to install the RabbitMQ client library for .NET. Before we look at how to install the client library, let’s take a brief look at what it is. This series will not serve as an in-depth guide to the whole client library API. You can read a more in-depth document for the client library that explains the full library from the RabbitMQ site. This section will serve as an introduction to the library and the examples in the rest of this series will help you cement your understanding further.
What is contained in the Client Library?
The RabbitMQ .NET client is an implementation of an AMQP client library for C# and other .NET languages. The client library implements the AMQP specification 0-8 and 0-9. The API is closely modeled on the AMQP protocol specification with little additional abstraction, so if you have a good understanding of the AMQP protocol, then you will find the client library easy to follow.
The core API interfaces and classes are defined in the RabbitMQ.Client namespace. The main API interfaces and classes are:
- IModel : This represents an AMQP data channel and provides most of the AMQP operations.
- IConnection : represents an AMQP connection.
- ConnectionFactory: constructs IConnection instances.
Some other useful interfaces and classes include:
- ConnectionParamters: configures a ConnectionFactory.
- QueueingBasicConsumer: receives messages delivered from the server.
In the previous article we looked at administering RabbitMQ from the command line. In this next article we will set-up a basic queue and also send and receive a basic message via the management portal.
Before we go and dive into some code and look at our samples, let’s work through a very simple scenario where we create an exchange and a queue and bind them together via the management portal. We will then send a message to the exchange and pull it from the queue. It is a very simple example, but it serves as a good introduction before we tackle some real world scenarios.
First of all go to the management portal and click on the exchanges tab. Once you are on the exchanges page, open up the ‘Add a new exchange’ section and fill it in as shown in the following screenshot. You will then need to click on the “Add exchange” button to add the exchange.
This will add a new ‘direct’ exchange to the list of exchanges. Now click on the Queues tab at the top of the page to go to the queue list. Open up the ‘Add a new queue’ section and fill it in as per the following screenshot. Now click the “Add queue” button.
In the previous article we looked the Rabbit MQ management portal in more detail. In this article we will look at configuring RabbitMQ from the command line.
As well as using the web based management portal to administer RabbitMQ you can also use the command line (rabbitmqctrl.bat) interface. In this chapter we will demonstrate some of the basic features that you may need to use most frequently, but for a more exhaustive list of commands you can read the RabbitMQ manual page for the rabbitmqctrl.bat tool.
At a high level rabbitmqctrl lets you manage the run state of the message broker, manage your RabbitMQ clusters, administer users and permissions, manage policies and list exchanges, bindings, and queues.
Let’s work through a simple example of stopping and starting the RabbitMQ broker and checking the broker status.
Open up a command prompt and navigate to “C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.4.4\sbin
From the command prompt type:
You will see the following output in the command line window.
To stop the RabbitMQ broker from running you type the following into the command line:
This will give you console output that looks as following:
If you run the status command line again by typing:
You will see that the RabbitMQ service has stopped. This will mean RabbitMQ will stop receiving and processing messages. If you have not setup durable queues and messages you will lose any messages already in the system.