A STOMP class for connecting to Apache MQ

An experiment with Apache MQ

Installing Apache MQ

I first downloaded the version from http://activemq.apache.org, I switched to the version from http://open.iona.com. Both work equally well as far as my test go but IONA offers support. The commands shown are those for the IONA Fuse message broker, except for installation paths the instructions are the same for the Apache version.

the queue can be started with
# cd /opt/iona/fuser-message-broker-5.0.0.16
# nohup bin/apachemq &

To check it is running open http://localhost:8161/admin/ replace localhost with the hostname where you installed the MQ.

Connecting from OpenEdge ABL

Browsing through the Apache MQ documentation I found the STOMP protocol to communicate with MQ's.
STOMP is a very simple protocol, for documentation see http://activemq.apache.org/stomp and http://stomp.codehaus.org/Protocol . I quickly wrote a procedure to implement the stomp protocol, soon I was sending messages to the queue.

Using a class

Although the procedural approach worked, this seemed a good project to build as a class. A procedure or other class can then simply new() a stomp connection. Rewriting the procedure to a class was pretty straightforward except for one thing. The SET-READ-RESPONSE-PROCEDURE of a socket does not accept a method, procedures are not allowed inside classes. Thanks to Julian Lyndon-Smith who sent me some sample code in response to a question on the peg I got around this limit.

The code

This is my first attempt to write a class, don't expect expert OO constructs.
Absolutely no warranty that it works, if you find problems or even better, solutions please send them to me. I'll try to update the source here.

Testing

Sending text messages is easy. I haven't tried binary and as most things that get past around these days are XML based I'm not really interested in binary. Performance looks good, sending 10000 "Hello world" messages takes 7 seconds.

Receiving messages was a different matter. It works, but I'm loosing messages. Worst case so far : received 21 out of 200 messages. Adding socket:sensitive = no in the read-response procedure seems to improve the receiving (23 instead of 21) but I'm still loosing messages.
This is fixed now, there were some bugs in my readhandler procedure.

What next

  • DONE Where are the lost messages ?
  • Adding ServiceMix (Fuse ESB)
  • Adding a second MQ

Support

By now I have found out that support for Apache MQ doesn't come cheap either. The advantage of Apache is you can DIY. If you want support, you're in the same price range as Sonic. To be fair, it was developer support, if you use it for multiple projects you can divide the cost among those project. This is not my case now :-(.

Disclaimer

This is a spare time experiment. This blog contains personal views and opinions.


AttachmentSize
stomp.zip4.68 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Queues vs Topics

Ok, have to admit I'm slightly confused about the differences between topics and queues. I thought that queues were for point-to-point, and topics for multiple subscribers. However, this code subscribes to queues ...

Performance seems ok - was able to transmit and receive 500,000 messages between 5 clients at a rate of around 1500/s so was quite pleased. (we need 500,000 messages in total per day at the moment, so scalability is more than achievable here).


Real World usage

Hi Carl,

Been reading up on the couple of ABL solutions for connecting to a stomp server. I was wondering how you had found the usage of this over the past couple of years ? Any gotchas ? Or is it all working smoothly ?

Are there any code updates ? Be interested in helping out if you need things doing.


bug receiving messages solved

As I expected there is a bug in my readhandler.
I fixed that, now I see all incoming messages.