How to browse a queue from within an ESB service

Posted by bjorn_kroghrud on 20-Jan-2011 03:51

I am trying to add functionality to an ESB service that checks another queue (other than the ones specified in the service endpoints) without fetching the messages.

If certain messages (with specific contents and properties) are found on the browsed queue, the service will take specific actions.

From what I can find, the only way to get hold of the (JMS)Connection is to do getCurrentJMSConnection from XQServiceContext.

So far so good, but the XQServiceContext is only available from the service method of the ESB service. And I'd like to be able to browse the queue before the service method is run.

How can I get the jms connection of an ESB service before the service method has been called?

Thanks,

Bjørn

All Replies

Posted by tsteinbo on 21-Jan-2011 03:10

What you describing sounds like you want to filter the content of that other queue. Why don't you do that with content based routing that performs the filtering for you? Just an idea...

For you original approach: if the message content would be insignificant for your decision you might be able to use message selectors against the properties.

HTH

Thomas

Posted by bjorn_kroghrud on 21-Jan-2011 03:35

Thanks Thomas.

The thing is that the property that is to be checked, is a timestamp and browsed messages should not be handled until the "time is right".

Ok, I should propably state my intentions with the service: It's a delay service that will pass messages through when the timestamp property on the message has passed current time.

I have a cbr service that directs messages to a specific queue if there should be a delay on the delivery. This is why I want to browse that specific queue - to be able to pass them on to the exit endpoint when the "time is right".

I know this is not an ideal solution - to be "storing" messages on queue - but the messages are very small and not that many. Besides, it's a temporary solution.

Posted by tsteinbo on 21-Jan-2011 04:12

Professional Services actually has a ready-made delay service that does exactly what you described. If you already in contact with them ask them about it.

If I remember correctly it establishes a separate jms connection and performs an sync receive() ever so often.

Thomas

Posted by sk185050 on 21-Jan-2011 04:16

I am not sure how you are putting the delay, I am using the SOnic7.5.2 I don't seen anything in this version, but custom service type that I think can use to, and we are doing that as well for some cases like that.

I think if you have that, you can do the browse on QUEUE.

Posted by bjorn_kroghrud on 21-Jan-2011 04:33

I am not in contact with professional services at this time. This is a small task (not even project) that I hoped to do without much effort (and cost).

The question is: How do I get the JMS connection that is used by the service? Could that connection be reused or should the settings be copied and a new connection created?

Posted by bjorn_kroghrud on 21-Jan-2011 04:53

Actually, I have a custom java service that should provide the delay.

The service should "poll" the queue a certain intervals (typically 60 seconds) - this is controlled by a wait() inside a loop.

Initially I thought I'd fetch all messages from queue and just put them back to the queue if the property did exist and its value (the timestamp) had not been reached. But, this created duplicates of the messages and seemed to mess up the wait() interval - it never finished fetching the messages. I did adjust QoS to Exactly_once to prevent duplicate messages, but have come to realize that browsing is preferable.

Posted by sk185050 on 21-Jan-2011 05:06

I think when you re-put the message you can set a property which say the message is processed, initially you can have that value as false, later after process you can make that true, I think with this you can handle duplicates.

What you think on that?

Browsing is also an option, but like thing you are expecting to pass though the message if the timestamp property pass the current time, for this you need to pull right?

-sksk

Posted by tsteinbo on 21-Jan-2011 06:30

I think we do introspect the jms connection that is used for the entry endpoint of the service and build our own jms connection for that particular service I had in mind.

Not particular clean and also makes use of internal APIs.

Posted by tsteinbo on 21-Jan-2011 06:31

Can you tell us a bit more about the message order. E.g. are the messages in the waiting queue in the order they should be released? Or can the be released in a different order than in the queue?

Posted by bjorn_kroghrud on 21-Jan-2011 08:55

The messages can arrive in any order with regards to the delay timestamp.

That's why I want to browse the waiting queue and select only the ones ready for sending.

I guess this would require a selector when connecting to the queue for fetching the specific messages?

Posted by bjorn_kroghrud on 27-Jan-2011 06:34

I've introspected the endpoint and are now able to browse queues.

Thanks for your input.

This thread is closed