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 » MQ Listener help....

Post new topic  Reply to topic
 MQ Listener help.... « View previous topic :: View next topic » 
Author Message
manojsingh
PostPosted: Tue Jun 07, 2005 12:53 pm    Post subject: MQ Listener help.... Reply with quote

Newbie

Joined: 07 Jun 2005
Posts: 3

Hi,
I am little new to the MQ world. I have been working with MDB etc so far so I know how to create MessageListeners in a App server environment. But now I need to create a stand alone java program which will act as a Listener to a MQ queue. I can write the code but I don't know how to make it running all the time and get messages as they are recd. on the relevant queue. ...can someone please point me in the right direction.

Thanks in advance.
MS
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Jun 07, 2005 1:02 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Use JMS, use the listener pattern, and set the MessageListener on the receiver.

To receive messages start the connection.

To stop receiving messages stop the connection

When done:
Stop the connection
set the listener on the receiver to null
close the receiver
close the session
close the connection

And remember setting session attributes for transaction boundaries and committing the session ( in the onMessage() method)....

Enjoy
Back to top
View user's profile Send private message Send e-mail
bower5932
PostPosted: Tue Jun 07, 2005 1:15 pm    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

Take a look at:

http://www.developer.ibm.com/isv/tech/sampmq.html

There are some programs that should give you what you need.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
manojsingh
PostPosted: Wed Jun 08, 2005 6:13 am    Post subject: Thanks Reply with quote

Newbie

Joined: 07 Jun 2005
Posts: 3

Hi,

Thanks for the replies....just to make sure I am understanding what you mentioned fjb_saper .... I need to create my own listener class ...and since mq.receive(..) (signature or method name might be wrong) is a blocking call the process will wait till the time a message is recd in the reciever queue.. . ...once the execution reaches the next line in my code I will know that the message is recd and I can process the message ....I need to put this in kind of infinite loop ...or till I explicitly close the connection...please correct me if I am wrong..

Thanks again to all of you for your help.
Manoj
Back to top
View user's profile Send private message
bower5932
PostPosted: Wed Jun 08, 2005 6:33 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

If you are using the WMQ java api (ie, not JMS), then the MQQueue.get() method will block until a message is received. This is assuming that you are specifying that you want to wait for a message (MQC.MQGMO_WAIT) and that you give an infinite timeout (MQC.MQWI_UNLIMITED). If you are going to block like this, then you should also specify that your get should end if the qmgr is shutting down (MQC.MQGMO_FAIL_IF_QUIESCING).

Your earlier appends lead me to believe that you may be using JMS. If that is the case, you can setup an asynchronous message listener to listen for incoming messages (take a look at the mqjmssub.java program at the URL above). You could also skip the asynchronous message listener and have your program listen synchronously (ie, block, take a look at mqjmssrv.java).
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
manojsingh
PostPosted: Wed Jun 08, 2005 10:18 am    Post subject: Thanks Reply with quote

Newbie

Joined: 07 Jun 2005
Posts: 3

bower5932 ....I think I am in a good now....thanks for your help I really appreciate it.. if there is any problem then....I will post it here again...

Thanks
Manoj
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » MQ Listener help....
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.