RabbitMQ 3.1.0 message broker released

The RabbitMQ team announced the release of RabbitMQ 3.1.0 – This release introduces eager synchronisation of mirror queue slaves, automatic cluster partition healing, and improved statistics (including charts) in the management plugin. It also adds many smaller new features, bug fixes and performance improvements.
The developers encourage all users of earlier versions of RabbitMQ to upgrade to this latest release.

For Delphi and Free Pascal, Habarisoft offers a client library for RabbitMQ 2.8.7 and newer.

Habari Client libraries new versions released

The new release of Habari message broker client libraries introduces new features, including:

  • new connection parameter “send.receipt” to enable broker receipt confirmations for all outgoing messages
  • new connection parameter “disconnect.receipt” to enable broker receipt confirmations for disconnect operations
  • new connection parameter “tcp.keepalive” to enable TCP keep-alive (Indy only)
  • resource saving on-demand creation of threads for asynchronous message receive
  • improved support for heart-beating

The full release notes are included in the “Getting Started” PDF documentation.

Continue reading

Habari Chat: message exchange for Delphi applications

habarichatHabari Chat is a demo application for the Habari Client libraries, available with full source code and as executable in the demo downloads.

Sending broadcast messages

After choosing a chatroom name and a nickname, the user interface allows to send text messages. For system messages – for example when users enter or leave a chatroom – the code below is used:

Continue reading

Automatic reconnect with Habari message broker client libraries

The next release of Habari message broker client libraries includes an example for automatic reconnect in case of connection loss.

It uses two nested loops, where the outer loop connects and disconnects, and the inner loops processes (sends or receives) messages. If an exception occurs while sending or receiving data on the TCP socket, the program leaves the inner loop, closes the connection and restarts the outer loop.

Continue reading

Ubuntu 13.04 will ship with RabbitMQ 3.0.2 (or newer)

From the launchpad details, the rabbitmq-server included in Ubuntu 13.04 will be at least v3.0.2-1. From the release schedule the final freeze is upon us so it is unlikely that any newer version will be included.

For Delphi and Free Pascal, Habarisoft offers a client library for RabbitMQ wich has been tested with RabbitMQ 2.8.7 and RabbitMQ 3.0.4.

Habari Client open source message broker libraries

The next major versions of Habari message broker client libraries for Delphi and Free Pascal are close to release. The new versions introduce options for easier detection of connection loss, reduced resource usage for synchronous operation mode, improved support for heart-beating (on STOMP 1.1 capable message brokers), source code refactorings, and have been tested with the open source message brokers Apache ActiveMQ 5.8.0, Apollo 1,6, HornetQ 2.3.0.CR1, OpenMQ 4.5.3 and RabbitMQ 3.0.4.

Habari Client Libraries

Habari Client for RabbitMQ 1.5 released

December 12, 2012 – Habarisoft today released version 1.5 of Habari Client for RabbitMQ, a library which provides easy access to RabbitMQ, the open source messaging system.

Habari Client libraries provide acces to production-ready and industry standard based cross-platform application integration, using the peer-to-peer or the publish/subscribe communication model.

The main new feature introduced in release 1.5 is the support for temporary queues. Temporary queues are managed by the server, exist only for the duration of a connection, and can be used for RPC style message processing. For more information and code examples please visit the blog page.

Temporary queue support in Habari Client libraries

What is a temporary queue?

Temporary queues are destinations with a scope limited to the connection that created it, and are removed on the server side as soon as the connection is closed. They are typically used for synchronous messaging (request/reply communication model). Their main advantage is that no queue management to provide unique destination names is required, because their uniqueness is provided by the server, and queues are removed automatically after use.

Use cases for temporary queues

The article Designing Messaging Applications with Temporary Queues by Thakur Thribhuvan shows a typical use case. In his example, many clients send messages with healthcare system information to a static request queue destination, and pass the identity of their individual temporary queue in the ReplyTo header of the message. The recipient of the message processes incoming messages in the static request queue, and sends a reply to the temporary queue in the ReplyTo header. The originating client then consumes the reply from the temporary queue.

The author summarizes: “In this configuration, temporary destinations can be viewed as analogous to callbacks in synchronous processing, i.e., when the callee wants to reach out to the caller in a decoupled way, without the caller and callee having to know about each other in advance.

Code example

The unit test for temporary queues in the Habari Client for RabbitMQ 1.5 demonstrates the interaction between a ‘client’ and a ‘server’ using a static queue for the requests and temporary queues for the replies.

The server code creates a static request queue (ServerRequestQueue) and a consumer for the request messages (RequestConsumer). The server then starts receiving requests (shown later, we first need to see the client side).

// SERVER: start a consumer waiting for request messages
ServerRequestQueue := Session.CreateQueue('StaticRequestQueue');
RequestConsumer := Session.CreateConsumer(ServerRequestQueue);

The client creates a destination object for the static request queue (ClientRequestQueue) and a message producer for the requests (RequestProducer). The client also a creates the temporary queue object (ClientTempQueue) and a consumer for the server response (ResponseConsumer).

  // CLIENT: prepare a "normal" destination queue
  ClientRequestQueue := OutSession.CreateQueue('StaticRequestQueue');
  RequestProducer := OutSession.CreateProducer(ClientRequestQueue);
  // CLIENT: create a temporary queue for responses
  ClientTempQueue := OutSession.CreateTemporaryQueue;
  // create a consumer for response messages
  ResponseConsumer := OutSession.CreateConsumer(ClientTempQueue);

Now the client creates and sends a request (RequestMsg), which also specifies the temporary queue in the ReplyTo header:

  // CLIENT: send message and specify a reply queue
  RequestMsg := OutSession.CreateTextMessage('request');
  // pass the temp queue name in the message header
  RequestMsg.JMSReplyTo := ClientTempQueue;
  // send it
  RequestProducer.Send(RequestMsg);

The server runs a receive loop to consume requests from the static request queue:

  // SERVER: get the request
  RequestMsg := RequestConsumer.Receive(100);
  if RequestMsg <> nil then
  begin
    // ... process the request
  end

When the server completed the message processing, it sends the response back to the client:

  // SERVER create reply queue based on message reply-to and send the response
  ResponseQueue := Session.CreateQueue((RequestMsg.JMSReplyTo as IQueue).QueueName);
  ResponseProducer := Session.CreateProducer(ResponseQueue);
  ResponseMsg := Session.CreateTextMessage('response');
  ResponseProducer.Send(ResponseMsg);

Finally, the client receives the response message:

  // CLIENT: receive the ResponseMsg from the temporary queue
  ReceivedResponseMsg := ResponseConsumer.Receive(100);
  if ReceivedResponseMsg <> nil then
  begin
    // ... process the response
  end else begin
    // error: no response received
  end;

Load balancing

This solution uses the terms “client” and “server” only to make the request/response communication clear: the client initiates the communication with a request, and the server responds. The “server” however is not necessarily a singular instance (a Delphi application). As the requests sent by the clients are stored in a single message queue on the message broker, it is possible to launch many identical Delphi applications, running the same logic shown above, to handle extra workload when needed.

Free “RabbitMQ Fundamentals” Course

SpringSource has released a free 2.5 hour eLearning training called vFabric RabbitMQ Fundamentals. This 2.5 hour eLearning training introduces you to the RabbitMQ product, why people use messaging, and how RabbitMQ high availability and clustering works. The training consists of five modules:

  • Module 1: Introduction to Messaging and AMQP
  • Module 2: RabbitMQ Product Presentation
  • Module 3: RabbitMQ Development
  • Module 4: RabbitMQ High Availability and Clustering
  • Module 5: RabbitMQ Advance Development