A useful feature of HornetQ are management notifcations. HornetQ servers emit management notifications when events of interest occur (consumers are created or closed, destinations are created or deleted, security authentication fails, etc.). These notifications can be received either by using JMX or by receiving JMS Messages from a well-known destination.
In the broker configuration file hornetq-configuration.xml, a JMS topic name can be set for the management name:
<management-notification-address> jms.topic.notificationsTopic </management-notification-address>
The Delphi code below creates a connection and subscribes to the topic. Next, it uses a loop to receive the notification messages:
Connection := TBTJMSConnection.MakeConnection; Connection.Start; Session := Connection.CreateSession(False, amAutoAcknowledge); Destination := Session.CreateTopic('notificationsTopic'); Consumer := Session.CreateConsumer(Destination); while True do begin Reply := Consumer.Receive; PropNames := Reply.GetPropertyNames; for I := 0 to Length(PropNames) - 1 do begin PropName := PropNames[I]; WriteLn(Format(' %s: %s', [PropName, Reply.GetStringProperty(PropName)])); end; end; Connection.Close;
The Habari Client for HornetQ library for Delphi (6 – XE) and Free Pascal is now in development at habarisoft.com.