|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Asynchronous Message Listener. |
« View previous topic :: View next topic » |
Author |
Message
|
samguan |
Posted: Wed Sep 30, 2009 6:20 am Post subject: Asynchronous Message Listener. |
|
|
Newbie
Joined: 30 Sep 2009 Posts: 3
|
Here is my scenario. I have one thread running. when it first starts, it will create an instance of another class called MQ, it will call the receive() method of the class. In the receive() method, it makes the connection to WebSphere and register a message listener for the connection. Basically the thread will always be listening for messages on the requestQ.
When the message arrives, the message listener method will put a "Received" + "counter"(int) message back to another queue called responseQ
My problem is that when I try to send 100 messages, I do see 100 messages in the responseQ, this means that my program did received all the messages. However, the problem is with the counter variable. Some messages will read Received35, Received 39 and some just says "Received" without the counter.
Anybody knows what is going on here. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Sep 30, 2009 7:20 pm Post subject: Re: Asynchronous Message Listener. |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
samguan wrote: |
Here is my scenario. I have one thread running. when it first starts, it will create an instance of another class called MQ, it will call the receive() method of the class. In the receive() method, it makes the connection to WebSphere and register a message listener for the connection. Basically the thread will always be listening for messages on the requestQ.
When the message arrives, the message listener method will put a "Received" + "counter"(int) message back to another queue called responseQ
My problem is that when I try to send 100 messages, I do see 100 messages in the responseQ, this means that my program did received all the messages. However, the problem is with the counter variable. Some messages will read Received35, Received 39 and some just says "Received" without the counter.
Anybody knows what is going on here. |
Sounds like you are having a scope problem with your counter variable and the thread that is accessing and incrementing it. As well you should make sure to have thread safety in case you use multiple instances of the class.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|