Tuesday, March 16, 2010

Just finished implementing QueueBrowser support in ActiveMQ-CPP

I just finished implementing the CMS QueueBrowser for ActiveMQ-CPP, it required me to make some changes to the QueueBrowser interface that was there but I think it was worth it. The JMS QueueBrowser uses an Enumeration returned from the JMS QueueBrowser as the way to browse Messages in JMS, so to keep things similar I created the CMS MessageEnumeration interface.

To use the QueueBrowser from CMS you just create a new QueueBrowser instance using your Session object and then get a MessageEnumeration when you want to browse the contents of the Queue. Here's a small snippet of code to demonstrate how its done.

std::auto_ptr browser = session->createQueueBrowser( queue );

// Enumerations are owned by the browser so don't delete or put in an auto_ptr
MessageEnumeration* enumeration = browser->getEnumeration();

while( enumeration->hasMoreMessages() ) {
cms::Message* message = enumeration->nextMessage();

// ... Do something with the Message

delete message;


The QueueBrowser is implemented in the ActiveMQ-CPP trunk.


titexe said...

Good News, we are waiting along time to have this fonctionnality,we hope to have the same functionality for ActiveMQ .Net :)


Tim said...

I'm working on it this week, it mostly works although hangs about half the time right now in the unit tests, so once I figure that out it should be good to go.

KPA said...

Outstanding news!
I already locally implemented this feature for AMQ.NET on NMS 1.2 (based on patch proposed by Symon). My solution is properly working since some time... If you're interested I can provide my patch...