-
1. Re: Invoking Service Invoker on client side...
scottdawson Jun 10, 2009 1:28 PM (in response to rkapur123)Rishi,
Have you considered using a JMS client? Instantiate a class that implements javax.jms.MessageListener and the onMessage method will get called every time a message arrives on the queue. Then the listener will resume listening. An asynchronous JMS client fits your use case perfectly.
Regards,
Scott -
2. Re: Invoking Service Invoker on client side...
rkapur123 Jun 11, 2009 7:23 PM (in response to rkapur123)Thanks Scott for the reply.
Yes, but one of the main reason I like ServiceInvoker is that it handles Failover.
btw, I tried to use the same instance of TwoWayCourier in while loop - but it won't pick up all the messages consistently. If I publish 5 messages - it picks 2 or 3 sometimes. I feel somewhere I am making a mistake.
Here is what I did:
Client Side
1) Standalone client to listen on queue using TwoWayCourier.
Server Side (ESB)
1) In service; first action logs the message and second action route it to responseQueue using JMSRouter. This is where client is listening.
please let me know if its correct why to do this.
Thanks a lot, regards,
rishi -
3. Re: Invoking Service Invoker on client side...
rkapur123 Jun 16, 2009 12:37 PM (in response to rkapur123)It's working now. I somehow did not grasped statement in JavaDocs earlier.
As per JavaDocs for CourierFactory.getPickupCourier(epr); I should prime "replyTo address" and "to address" with EPR that we are listening on. After I did that it started working.
Here is what I did in client:JMSEpr pickupEPR = new JMSEpr("1.1", "queue", "responseQueue", "ConnectionFactory", props, null); TwoWayCourier twoWayCourier = CourierFactory.getPickupCourier(pickupEPR); twoWayCourier.setReplyToEpr(pickupEPR); twoWayCourier.setToEpr(pickupEPR); Message responseMessage = null; do { responseMessage = twoWayCourier.pickup(20000); }while (System.currentTimeMillis() < timeToWait);
Now I don't need to create separate instances and I receive all messages correctly. Thanks all,
-rishi