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 JAva listener

Post new topic  Reply to topic
 MQ JAva listener « View previous topic :: View next topic » 
Author Message
subhendu
PostPosted: Mon Mar 11, 2002 12:58 pm    Post subject: Reply with quote

Novice

Joined: 05 Mar 2002
Posts: 18

Hi i want to implement a Messagelistener Using MQ Pure JAva. I know Using JMS it can be done. But i want to use MQ java due to some restriction.
That means as soon as message arrives in the queue my program should run.
Any ideacode samples how to implement this.

Thanks,
Subhendu
Back to top
View user's profile Send private message
bduncan
PostPosted: Mon Mar 11, 2002 1:15 pm    Post subject: Reply with quote

Padawan

Joined: 11 Apr 2001
Posts: 1554
Location: Silicon Valley

Subhendu,
Please look at this thread:
http://www.mqseries.net/phpBB/viewtopic.php?topic=1694&forum=5


_________________
Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator
Back to top
View user's profile Send private message Visit poster's website AIM Address
subhendu
PostPosted: Mon Mar 11, 2002 4:44 pm    Post subject: Reply with quote

Novice

Joined: 05 Mar 2002
Posts: 18

my concern is using JMS i can define a MessageListener so that when a message arrives it will trigger the onmessage method of listener.

So is there such type of implementation in MQ base java classes?

THanks,
Subhendu
Back to top
View user's profile Send private message
kolban
PostPosted: Mon Mar 11, 2002 5:54 pm    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

No .. but think what is going on here. By registering a message listener, you are asking for messages to be handled asynchronoulsy from your initial thread. You can trivially (and in my opinion with much more power) achieve the same task using base java MQ classes.

Simply create a new thread which creates a new MQQueueManager object, accesses a queue and then performs a get() method call blocking on a message arriving.
Back to top
View user's profile Send private message
subhendu
PostPosted: Tue Mar 12, 2002 6:28 am    Post subject: Reply with quote

Novice

Joined: 05 Mar 2002
Posts: 18

The message comes to queue asynchronously. That means message comes to the queue when user from online system submits some thing.So it is totally asynchronous.In this case if i have a jms listener then i need not to worry. I will register it to the queue and i will call the start method in side a startup servlet. so at any time message comes it will pick up.

But if i am using the base MQ class it will pick up message once and process it and thread will go down. So how to achieve the same functionality menioned above by jms.
Thanks,
Subhendu
Back to top
View user's profile Send private message
kolban
PostPosted: Tue Mar 12, 2002 7:21 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

You own the thread using base java ... why not put it in a loop. ... Get the message, process the message, get the message, process the message ....

The thread doesn't have to end just because you got a message. If you want multiple messages to be processed concurrently, spawn a new thread yourself and pass in the MQMessage as a parameter.
Back to top
View user's profile Send private message
subhendu
PostPosted: Tue Mar 12, 2002 7:43 am    Post subject: Reply with quote

Novice

Joined: 05 Mar 2002
Posts: 18

The message does not come always. Message comes and then may be for some time there will be no message.Making loop ,will it not be performance problem?
FOr example some application will put a message and after one or two hour another messsage arrives. So in that case the loop will be always regardless there is message in the queue or not.
Back to top
View user's profile Send private message
kolban
PostPosted: Tue Mar 12, 2002 10:07 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

The loop will contain an MQGET call with a wait interval, potentially infinite. While the MQGET call is blocked waiting for a message, it consumes no CPU.
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 JAva 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.