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 » Problem in Java MQ pooling - urgent

Post new topic  Reply to topic
 Problem in Java MQ pooling - urgent « View previous topic :: View next topic » 
Author Message
gobi_nathan
PostPosted: Wed May 21, 2003 5:30 am    Post subject: Problem in Java MQ pooling - urgent Reply with quote

Acolyte

Joined: 08 Jan 2003
Posts: 69

Hi ,

I have problem in Java - MQ pooling program.I have written the java pooling program that connects with the MQ- server through the server connection channel.This program keeps the queuemanger and queue open and keep pooling for the message at defined interval.

when the program reads the certain number of messages it works well.after some messages the program not able to read the messages from the queue.I don't know,what gets wrong here.I am not getting any error messages.

That pooling program started when the websphere server start,initiated through the servlet.

-Gobi
Back to top
View user's profile Send private message
zpat
PostPosted: Wed May 21, 2003 6:00 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

Do you mean polling?

As a general point, you should NOT poll for messages on a queue.

Issue MQGET with the WAIT option (eg for 30 seconds). Check for your application closing and if not, repeat the MQGET with WAIT - obviously processing any messages as they arrived.

Let the queue manager wait as it will immediately return any messages when available - there will be NO latency.

If your application does the waits then it will have on average a latency before getting the next message, or an incredible overhead if the wait interval is low.

If you keep checking the queue it will cause network traffic on a MQ Client connection to the Queue manager. The effect is less damaging if the Queue Manager is local.
Back to top
View user's profile Send private message
gobi_nathan
PostPosted: Wed May 21, 2003 9:49 pm    Post subject: Reply with quote

Acolyte

Joined: 08 Jan 2003
Posts: 69

Thanks zpad,

Following is the logic i am using in my program, I haven't get where the exact problem is.

    I have set the wait interval unlimited.
    And i am issueing th MQGET without the wait interval.
    If any message comes application reads the message and start process.
    Again, issues MQGET immediately,( this i try after some wait interval also).

Still the same problem is present ,I want to where the bottleneck is?



Here is the code i am using

//Sets get Message Option
MsgReceiver objMsgReceiver = new MsgReceiver();


//Read options MQC.MQGMO_FAIL_IF_QUIESCING | MQC.MQGMO_CONVERT |
MQC.MQGMO_WAIT | MQC.MQGMO_COMPLETE_MSG | MQC.MQGMO_ACCEPT_TRUNCATED_MSG


objMsgReceiver.setMessageOptions(MQConstants.MQ_MESSAGE_READ_OPTIONS);

//Receiving message option MQC.MQOO_INPUT_SHARED | MQC.MQOO_FAIL_IF_QUIESCING


//Setting the wait interval unlimited

objMsgReceiver.setWaitInterval(MQC.MQWI_UNLIMITED);
//Open queue option for getting the message
int gopenOptions = MQConstants.MQ_READ_QUEUE_OPEN_OPTION ;
try{
//Create QueueManager
qMgr = new QueueManager( MQConstants.REQUEST_QUEUE_MANAGER );
objProcManager = new ProcessManager();
mqInQueue = qMgr.accessQueue(MQConstants.REQUEST_QUEUE, gopenOptions,null,null,null);

while ( true )
{ Message retrievedMessage = new Message();
retrievedMessage.setMessageType(MQC.MQMT_REQUEST);
mqInQueue.get( retrievedMessage , objMsgReceiver , MQConstants.MAX_MSG_LENGTH );
// creates the request processing thread
objProcManager.processRequestMsg(retrievedMessage);
/* try{
Thread.sleep(MQConstants.MQ_POOLING_INTERVAL);
}catch(InterruptedException itrExp )
{
}*/
}//runs indefinite time interval
}catch (MQException mqExp) {
}

Thanks in advance ,
Gobi.
Back to top
View user's profile Send private message
zpat
PostPosted: Thu May 22, 2003 12:12 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

I am not a Java programmer - but you ARE polling the queue and waiting in your program, this is not the optimum design.

Using pseduo code, I would do this:
Code:

MQCONN
MQOPEN
set GET options WAIT (30 secs), CONVERT, FAILIFQUIESCING etc

DO WHILE (not closing application and not quiescing queue manager)
     MQGET
     if "no message available" then
        null (this wait expired with no msg on queue)
     else
        process the message
END (WHILE)

MQCLOSE
MQDISC

--------------

This code will give an IMMEDIATE response to available messages, but it will still allow the application to close down within 30 seconds of a request to do so and it will not issue MQGET more often than once every 30 seconds.

You can use other values (eg between 10 to 300 seconds), the only reason not to use an indefinite wait is that it is then hard to close the application down cleanly on request.

If you are issuing MQGETs too frequently, you will cause MQI overhead and network traffic from a MQ client as all MQI operations are performed on the server.

We had a vendor who, despite being told the above, insisted on "polling" a mainframe queue ten times a second, the application had terrible performance and this was one of the reasons they lost a multi million pound deal with us.

DON'T POLL THE QUEUE, DON'T SLEEP IN YOUR THREAD. LET MQ SLEEP FOR YOU IN THE MQGET with WAIT.
Back to top
View user's profile Send private message
gobi_nathan
PostPosted: Thu May 22, 2003 9:55 am    Post subject: Reply with quote

Acolyte

Joined: 08 Jan 2003
Posts: 69

Hi zpat ,

I got what you are saying, will change my logic accordingly.thanks you very much.

-Gobi
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 » Problem in Java MQ pooling - urgent
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.