Tag Archives: Coding

Code Metrics and Static Code Analysis Talk

The Perils of Not Writing Good Unit Tests?

The Perils of Not Writing Good Unit Tests?

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.

RabbitMQ Series Part 6: Basic Queuing and Message Example

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.

RabbitMQ Basic Queue and Message Example

RabbitMQ Basic Queue and Message Example

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.

Continue reading

RabbitMQ Series Part 5: Administration via the Command Line

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:

 Rabbitmqctl status

You will see the following output in the command line window.

Configure RabbitMQ from the Command Line

Configure RabbitMQ from the Command Line

To stop the RabbitMQ broker from running you type the following into the command line:

 Rabbitmqctl stop

This will give you console output that looks as following:

Configure RabbitMQ from the Command Line

Configure RabbitMQ from the Command Line

If you run the status command line again by typing:

 Rabbitmqctl status

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.

Continue reading

RabbitMQ Series Part 4: Overview of the Management Portal

In the previous article we looked at the installation and basic configuration of RabbitMQ. In this article we will look in more detail at the Management Portal.

The RabbitMQ management plugin provides a browser based user interface to administer the message broker as-well as a HTTP-based API for management and monitoring of your RabbitMQ server.

The management plug-in features include:

  • Declare, list and delete exchanges, queues, bindings, users, virtual hosts and permissions.
  • Monitor queue length, message rates globally and per channel, data rates per connection, etc.
  • Send and receive messages.
  • Monitor Erlang processes, file descriptors, memory use.
  • Export / import object definitions to JSON.
  • Force close connections, purge queues.

The management portal is split into different screens that are selectable with the menu bar at the top of the screen. The first screen you will see is the overview page. This acts as a dashboard view showing you how many messages are in the broker, and the message throughput rate.

RabbitMQ Management Portal Overview Screen

RabbitMQ Management Portal Overview Screen

This screen is useful to have up on a large display so you can see at a glance how RabbitMQ is performing. If, for example, any of your message consumer applications go down, you will start to see a large buildup of undelivered messages which is a good indication that something has gone wrong.

In the image above, you can see on the overview screen that 1 messages was placed onto the queue at 10:49.00. In the chart below this you can see the message rates which is split into Published messages, Delivered messages, Redelivered messages, Acknowledged messages and Delivered messages where no acknowledgement was required.

Continue reading

RabbitMQ Series Part 3: Installing and Configuring RabbitMQ

In the previous article we look at the AMQP messaging standard that sits behind RabbitMQ. In this article we will look at installing and configuring RabbitMQ.

Basic Installation

Now that we have covered the basics of message queuing, RabbitMQ, and the AMQP model, let’s get RabbitMQ installed and configured. When you set up RabbitMQ on a server, you need to install two components. First, you need the Erlang run time and then RabbitMQ itself. First, go to the RabbitMQ website to download it.

Once you are on this page, select “Install: Windows” from the grey panel to the right of the screen:

Download RabbitMQ

Download RabbitMQ

From this page, click the link to the “Erlang Windows Binary File” as shown in the following screen shot. This will take you to the Erlang website downloads page.

Download the Erlang Runtime

Download the Erlang Runtime

When you are on the Erlang site, pick the latest version of the runtime that matches your operating system. If you are running a 64bit operating system, then pick the 64bit version and visa versa with the 32bit version.

Continue reading

Developing Windows 10 Universal Apps in Microsoft Visual Studio 2015

Now that I have upgraded my main work laptop to Windows 10, I want to learn all about the Windows 10 Universal Apps platform. I am at the beginning of this journey, so I am a beginner here. I have been looking for lots of resources to help me out and I found this TechEd training session on youtube. I have found it useful, so I thought I would share it.

I have also found the Microsoft Virtual Academy video for Windows 10 Development on Youtube. This is a longer tutorial, but covers much more detail.

RabbitMQ Series Part 2: The AMQP Messaging Standard

In the first article in this RabbitMQ series we looked at what message queueing is and a brief look at RabbitMQ. In this article we will look in more detail at the AMQP messaging standard that underpins RabbitMQ.

RabbitMQ is built on top of the AMQP. This is a network protocol that enables client applications to communicate with a compatible messaging system.

A message broker works by receiving messages from a client (publisher) and that broker routes the message to a receiving application (consumer).

RabbitMQ Message Broker

RabbitMQ Message Broker

RabbitMQ currently supports version 0-9-1 of the AMQP protocol. With the AMQP protocol, a message is published by an application to an exchange. You can think of the exchange as a mailbox. The exchange then sends the message to a queue by using different rules called bindings. This is all within the message broker.

The message broker will then deliver the message from the queue to a consumer (the consumer pulls the message) that is subscribed to the queue. When a message is published to a queue, a publisher can specify various different message attributes. Some of these attributes will be used by the message broker but the rest is completely opaque to the broker and is only used by any applications that receive the message.

Continue reading