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
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
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.
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
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.
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?
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.
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
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.
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?
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?
I've introspected the endpoint and are now able to browse queues.
Thanks for your input.