ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Asynchronous Message Listener.

Post new topic  Reply to topic
 Asynchronous Message Listener. « View previous topic :: View next topic » 
Author Message
samguan
PostPosted: Wed Sep 30, 2009 6:20 am    Post subject: Asynchronous Message Listener. Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Wed Sep 30, 2009 7:20 pm    Post subject: Re: Asynchronous Message Listener. Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Asynchronous Message Listener.
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.