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 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

Red Hat introduces JBoss A-MQ

JBoss A-MQ is intended as a “lightweight” alternative to Red Hat’s own Enterprise Service Bus (ESB) and used to be known as Fuse Message Broker. The technology is mainly based on the Apache ActiveMQ messaging platform.

News blog (h-online.com): A new ESB and messaging platform join Red Hat’s middleware

Red Hat JBoss A-MQ product page

Red Hat JBoss A-MQ download page

Delphi and Free Pascal can connect to ActiveMQ using the native Habari Client libraries from Habarisoft.

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

DataSnap speed and stability tests

Roberto Schneiders published and discussed test results for a REST application implemented with the frameworks DataSnap, mORMot, Jersey/Grizzly, ASP.NET WCF and Node.js: DataSnap analysis based on Speed & Stability tests. All the source code of the servers, as well as the binaries and the JMeter test plans are available for download at https://github.com/RobertoSchneiders/DataSnap_REST_Test.

Update: Indy HTTP server tests with pretty good results

To see wether Indy or DataSnap is the bottleneck, I ran a single-threaded JMeter test of the Indy HTTP server on a quite slow system (Mobile Core2 Duo @ 2.1 GHz), with HTTP 1.1 keep-alive enabled. The average throughput was 320 requests/second, with zero (0) % HTTP errors. The CPU load was around 40%, Client and server where running on the same system. In the tests described above, DataSnap with Indy as HTTP transport reached 62 requests/second on a Core i5 750 with 4 x 2,67 GHz system. With 50 threads, throughput reached more than 1.400 requests/second (over 1 million requests), 50% CPU load and 3 MB RAM usage.

The server application was the BasicDemo (a simple ‘Hello world!’) web application implemented with the Habari Web Components, which are a layer on top of Indy HTTP server components.

Firebird Database Events and Message-oriented Middleware (part 2)

Firebird developers can use Firebird events to notify clients about changes in database record data. In the previous post, I showed and discussed some limitations of Firebird events. This post presents a solution based on message-oriented middleware.

The solutions in the first post used server-side logic in the Firebird database metadata, implemented with Firebird’s procedural language (PSQL). Information which can not be passed within Firebird events, such as the record ID of the new purchase order, can be stored in helper tables which then must be read by the database clients. So from a technical view, these solutions only replace the timer-triggered client-pull with event-triggered client-pull. This is a small step forward, at the price of increased complexity of database metadata.

A new strategy: implementing the event notification on the client side

Obviously, the client application which inserts a new purchase order could also send notifications to the other clients. The advantage would be that server-side PSQL code can be replaced by code written in your client-side programming language (Delphi/Free Pascal, C#, …). The PSQL code in the server-side solution looked like this:

  CREATE TRIGGER PURCHASE_ORDER_INSERT FOR PURCHASE_ORDER AFTER INSERT
  AS
  BEGIN
    POST_EVENT 'purchase_order_table_updated';
  END

If we implement notifications in the client side application, similar code has to be be executed when a new order record has been inserted in the order table, using an inter-process communication method. The event notification code could look like this:

procedure TAppDataModule.PurchaseOrderAfterPost(DataSet: TDataSet);
var
  Notification: INotification;
begin
  Notification := NotificationService.CreateNotification(PURCHASE_ORDER_TABLE_UPDATED);
  Notification.SetIntProperty(PURCHASE_ORDER_ID, PurchaseOrderID.AsInteger);
  NotificationService.Send(Notification);
end;

But advanced features like load balancing, or for notifying clients which currently are not listening, would need a high amount of custom code. Another difficult task would be the integration of clients or other systems written in an other programming languages (a PHP based order entry web app for example) – their integration with your application would only be possible after porting the notification system.

Continue reading

Firebird Database Events and Message-oriented Middleware (part 1)

Firebird developers can use Firebird events to notify clients about changes in database record data. In this article, I will show and discuss some limitations of Firebird events and compare possible workarounds with a solution based on message-oriented middleware.

How should I implement “server push” for new data, instead of “client pull”?

For this article we assume a common business use case:

  • a two-tier client-server application
  • one client creates new records of type “purchase order”
  • other clients need to be notified about new “purchase order” records

In this scenario, repeated pulling data from the “purchase order” table causes network traffic from all client workstations – even if there are no new orders at all, and too many clients would cause network and/or server resource overload. But being a two-tier architecture, there is no service layer or application server between database and the client software which could handle the notifications. Our conclusion is that we need server side ‘push’ notifications, which will only cause network traffic when there is new data.

Continue reading

AMQP 1.0 is now an OASIS standard

Members of the independent Organisation for the Advancement of Structured Information Standards (OASIS) have approved version 1.0 of the Advanced Message Queuing Protocol (AMQP) as a standard. The Advanced Message Queuing Protocol (AMQP) is an open standard application layer protocol for message-oriented middleware. Contributors to the standardisation process include the Bank of America, Deutsche Börse, Goldman Sachs, Huawei, JPMorgan Chase, Microsoft, Progress Software, Red Hat, Software AG and VMware.