Consume a JMS ObjectMessage with Habari Client for ActiveMQ

As a follow-up to the previous article about MapMessage exchange with Apache ActiveMQ, here is an example for an ObjectMessage, sent from a Java JMS client and consumed from a Delphi application.

Continue reading “Consume a JMS ObjectMessage with Habari Client for ActiveMQ”

Advertisement

Consume ActiveMQ JMS MapMessages from Delphi

One outstanding feature of the popular Apache ActiveMQ message broker is its rich message conversion capability, which allows cross-platform/cross-language exchange by serialization of JMS object and map messages to XML or JSON. Non-Java clients do not have to support the native ActiveMQ wire protocol. Instead, they can use a simple protocol such as STOMP.

Continue reading “Consume ActiveMQ JMS MapMessages from Delphi”

ActiveMQ, Qpid, HornetQ and RabbitMQ in Comparison

An article by Thomas Beyer (also available in German language) gives a short introduction into popular messaging solutions which are available as free open source projects.

“Newer architectures and the standardized AMQP protocol have led to a flood of message brokers. All brokers take claim to be fast, robust and reliable. But what really distinguish the broker? How do I choose the right broker? Should we continue to use established brokers such as the ActiveMQ or try a more modern one? This article attempts to answer these questions and help the reader in selecting a suitable broker.”

Article URL: http://predic8.com/activemq-hornetq-rabbitmq-apollo-qpid-comparison.htm

Query ActiveMQ Broker Statistics with Delphi

Broker Configuration

To configure ActiveMQ to use the statistics plugin add the following to the ActiveMQ XML configuration:

<plugins>
  <statisticsBrokerPlugin/>
</plugins>

The statistics plugin looks for messages sent to particular destinations.

Query running broker statistics

To query the running statistics of the message broker, the client sends an empty message to a Destination named ActiveMQ.Statistics.Broker, and sets the replyto field with the Destination you want to receive the result on. The statistics plugin will send a  MapMessage filled with the statistics for the running ActiveMQ broker.

Source code

program DestStatistics;

(**
  Requires ActiveMQ 5.3 or higher
  To configure ActiveMQ to use the statistics plugin, add the following to the ActiveMQ XML configuration:
  <broker>
  ...
    <plugins>
      <statisticsBrokerPlugin/>
    </plugins>
  ...
  </broker>

  Usage:
  ------
  DestStatistics [destination]
  If no destination is specified, the program returns the broker statistics

  Reference
  ---------
  http://activemq.apache.org/statisticsplugin.html
  https://issues.apache.org/activemq/browse/AMQ-2379
  http://rajdavies.blogspot.com/2009/10/query-statistics-for-apache-activemq.html

  You can also use wildcards too, and receive a separate message for every destination matched.
*)

{$APPTYPE CONSOLE}

uses
  SysUtils,
  BTCommAdapterIndy, BTMessageTransformerXMLMapOmni,
  BTJMSInterfaces, BTJMSConnection, BTSessionIntf, BTSerialIntf,
  BTStompTypes, BTTypes,
  Classes;

var
  Connection: IConnection;
  Session: ISession;
  Producer: IMessageProducer;
  Consumer: IMessageConsumer;
  Destination, ReplyQueue: IQueue;
  JMSMessage: ITextMessage;
  Reply: IMapMessage;
  MapNames: PMStrings;
  I: Integer;
  Key: string;

begin
  Connection := TBTJMSConnection.MakeConnection;
  try
    try
      // Create and assign the message transformer
      SetTransformer(Connection, TBTMessageTransformerXMLMapOmni.Create(nil));

      Connection.Start;
      Session := Connection.CreateSession(False, amAutoAcknowledge);

      // listen on reply queue
      ReplyQueue := Session.CreateQueue('Habari' + '?' +
        BTStompTypes.SH_TRANSFORMATION + '=' + TRANSFORMER_ID_MAP_XML);
      Consumer := Session.CreateConsumer(ReplyQueue);

      // create the pseudo destination
      if ParamCount = 0 then
      begin
        Destination := Session.CreateQueue('ActiveMQ.Statistics.Broker');
      end
      else
      begin
        Destination := Session.CreateQueue('ActiveMQ.Statistics.Destination.' + ParamStr(1));
      end;

      // display destination name
      WriteLn('Request statistics for ' + Destination.QueueName + ' ...');

      // create the message and set reply queue name
      JMSMessage := Session.CreateTextMessage;
      JMSMessage.JMSReplyTo := ReplyQueue;
      Producer := Session.CreateProducer(Destination);
      Producer.Send(JMSMessage);

      // read the result message
      Reply := Consumer.Receive(1000) as IMapMessage;

      // list the map key/values
      while Assigned(Reply) do
      begin
        MapNames := Reply.GetMapNames;
        for I := 0 to Length(MapNames) - 1 do
        begin
          Key := MapNames[I];
          WriteLn(Key + '=' + Reply.GetString(Key));
        end;
        WriteLn;
        Reply := Consumer.Receive(1000) as IMapMessage;
      end;

      WriteLn('No more message on queue ' + ReplyQueue.QueueName);

      Connection.Stop;

    except
      on E: Exception do
        WriteLn(E.Message);
    end;
  finally
    Connection.Close;
  end;

  WriteLn('Press any key');
  ReadLn;
end.

 


Query Statistics for Apache ActiveMQ with Delphi

A Habari Client library for the IBM WebSphere MQ message broker?

If you are a Delphi or Free Pascal developer and interested in application integration with WebSphere MQ, please let me know. You can vote for it or drop me a message. Currently, Habari Client libraries are only available for open source message brokers (ActiveMQ, Apollo, HornetQ, Open MQ and RabbitMQ) – which also have commercial support options. A Delphi / Free Pascal application integration with WebSphere MQ could be a useful option for enterprise developers.

Note that IBM WebSphere Application Server Community Edition is based on the open source Apache Geronimo application server and uses Apache ActiveMQ be default, so you can integrate Delphi and Free Pascal applications with it already now, using Habari Client for ActiveMQ.

Habari Client for Apollo 1.2

August 7, 2012 – Habarisoft is pleased to announce release 1.2 of Habari Client for Apollo. ActiveMQ Apollo is a faster, more reliable, easier to maintain messaging broker built from the foundations of the original ActiveMQ.
With this library, Delphi and Free Pascal developers can build integrated solutions, connecting applications using the peer-to-peer and the publish and subscribe communication model.
New in version 1.2

  • STOMP 1.1 support
  • NACK (negative ACK) support
  • tested with Apollo 1.4 (released August 6 2012)
  • internal improvements and fixes

Home page:
http://www.habarisoft.com/habari_apollo.html
“Getting Started” guide:
http://www.habarisoft.com/download/HabariApolloGettingStarted.pdf
Feature matrix:
http://www.habarisoft.com/download/HabariFeatureMatrix.pdf
Online API documentation:
http://www.habarisoft.com/habari_apollo/1.2/docs/api/index.html

Habarisoft message broker client libraries for Delphi updated

Habarisoft announced new versions of its Delphi client libraries for the open source message brokers Apache ActiveMQ, Apollo, HornetQ, OpenMQ, and RabbitMQ:

All client libraries include the full source code, one year free minor and major updates, royalty-free distribution of applications, many demo projects, unit tests, API documentation in HTML format, and a “Getting Started” PDF.

About Habari Client libraries
Habari Client libraries provide access to standards-based, enterprise quality solutions for distributed messaging. With these libraries, Delphi applications now can take advantage of open source message broker technology which is distributed, loosely coupled, reliable and asynchronous – and build integrated systems, connecting clients using the peer-to-peer or the publish and subscribe communication model.

VisualMM for FastMM first demo download available

A first demo application for VisualMM is now available for download at http://www.habarisoft.com/download/VisualMMWebDemo.zip (234 KB), it requires Apache ActiveMQ 5 (http://activemq.apache.org).

Start the ActiveMQ broker with this command line:

<path to ActiveMQ>\bin\activemq-admin.bat start xbean:activemq-demo.xml

VisualMMWebDemo.exe uses an embedded Indy HTTP server. The local firewall will issue a warning if you start it. When started, the demo will launch the web browser to show the monitor charts (see http://www.habarisoft.com/visualmm.html for a dynamic example).

The demo writes its own memory allocation statistics to the ActiveMQ broker and reads it back to create the charts.

The next demo will also allow to select from a list of running applications which provide VisualMM data.

Visual FastMM monitoring with Habari Client for ActiveMQ

visualmm demo chart
visualmm demo chart

The next release of Habari Client for ActiveMQ includes a web demo application which displays memory allocation charts for running Delphi applications. This demo leverages a feature of FastMM (the new memory manager in Delphi): run time memory allocation statistics.

A dynamic chart example is available. It displays four charts:

  1. FastMM Memory Block Count (current snapshot)
  2. FastMM Overall Block Count (timeline for last n snapshots)
  3. FastMM Memory Block Size (current snapshot)
  4. FastMM Overall Block Size (timeline for last n snapshots)

Bundled with dwf – Web Framework for Delphi

The new dwf Web Application Framework for Delphi also includes the full source code for VisualMM, except the Habari Client library.