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 with putQueue.put() operation taking long time

Post new topic  Reply to topic
 Problem with putQueue.put() operation taking long time « View previous topic :: View next topic » 
Author Message
James_O_K
PostPosted: Thu Aug 24, 2006 3:41 am    Post subject: Problem with putQueue.put() operation taking long time Reply with quote

Apprentice

Joined: 09 Mar 2006
Posts: 39
Location: UK

Hello all,

I have an java app that listens for messages on a queue, processes them and then sends a response. It has several threads running that poll the queue using a static class with a getMessage() method. Ive recently changed this class to use MQGMO_WAIT with an interval of 5 seconds. Since this change when i use the classes putMessage() method it takes a few seconds to perform putQueue.put(message). Is this expected, and if not has anyone seen this before? If not any suggestions as to where to begin looking?

Heres the code associated:

private static int putOpenOptions = MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_OUTPUT;

/**
* Gets an mq message off the queue
* @return MQMessage - cps mq message
* @throws MQException
*/
public static MQMessage getMessage() throws MQException {
final String METHOD_NAME ="getMessage";
//LogHelper.methodEntry(PACKAGE_NAME, CLASS_NAME, METHOD_NAME);
MQMessage returnVal = null;
returnVal = mqGetMessage();
getQueue.get(returnVal , mqGetMessageoptions());
//LogHelper.methodExit(PACKAGE_NAME, CLASS_NAME, METHOD_NAME);
return returnVal;
}

/**
* Sets up get message options for use on get queues
* @return
*/
private static MQGetMessageOptions mqGetMessageoptions() {
MQGetMessageOptions getMessageOptions = new MQGetMessageOptions();
getMessageOptions.matchOptions = MQC.MQMO_NONE;
getMessageOptions.options = MQC.MQGMO_WAIT | MQC.MQGMO_ACCEPT_TRUNCATED_MSG | MQC.MQGMO_FAIL_IF_QUIESCING;
getMessageOptions.waitInterval = waitInterval;
return getMessageOptions;
}

/**
* Puts return message back on to queue
* @param message - message to send
* @param replyToQueueName - reply queue from request message
* @param replyToQmgrName - reply qgmr from request message
* @return
*/
public static void putMessage(MQMessage message, String replyToQueueName, String replyToQmgrName) {
final String METHOD_NAME = "putMessage";
LogHelper.methodEntry(PACKAGE_NAME, CLASS_NAME, METHOD_NAME);
boolean success = false;
try {
// get a handle on dynamic queue each time using replyToQueueName and replyToQmgrName
message.seek(0);
LogHelper.debug(PACKAGE_NAME, CLASS_NAME, METHOD_NAME, "text on put message: " +message.readString(message.getMessageLength()));
putQueue = queueManager.accessQueue(replyToQueueName, putOpenOptions, replyToQmgrName, null, null);
putQueue.put(message);
putQueue.close();
success = true;
putQueue = null;

} catch(MQException e) {
LogHelper.error(PACKAGE_NAME, CLASS_NAME, METHOD_NAME, e.getMessage());
e.printStackTrace();
CPSCommunicatorHelper.sendSupportEmail(PACKAGE_NAME,
CLASS_NAME, METHOD_NAME,
CPSConstants.EMAIL_SUBJECT_ERROR,
"Exception caught: " + e.getMessage(),
CPSConstants.getEmailServer(),
CPSConstants.getEmailAlertAddress());
} catch (IOException ioe){
LogHelper.error(PACKAGE_NAME, CLASS_NAME, METHOD_NAME, ioe.getMessage());
ioe.printStackTrace();
CPSCommunicatorHelper.sendSupportEmail(PACKAGE_NAME,
CLASS_NAME, METHOD_NAME,
CPSConstants.EMAIL_SUBJECT_ERROR,
"Exception caught: " + ioe.getMessage(),
CPSConstants.getEmailServer(),
CPSConstants.getEmailAlertAddress());
}
LogHelper.methodExit(PACKAGE_NAME, CLASS_NAME, METHOD_NAME);
//return success;
}

/**
* Create a get message
* @return MQMessage - basic get message
*/
private static MQMessage mqGetMessage() {
MQMessage message = new MQMessage();
message.messageId = MQC.MQMI_NONE;
message.correlationId = MQC.MQCI_NONE;
return message;
}
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Aug 24, 2006 4:11 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Create a new QueueManager object for your Puts.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
James_O_K
PostPosted: Thu Aug 24, 2006 5:45 am    Post subject: Reply with quote

Apprentice

Joined: 09 Mar 2006
Posts: 39
Location: UK

I should also mention that when not using MQGMO_WAIT the putQueue.put() action is instant.

Thanks

James.
Back to top
View user's profile Send private message
wschutz
PostPosted: Thu Aug 24, 2006 6:10 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

You can only do one operation at a time on a qmgr connection.... so the PUT doesn't happen until the GET completes... do as Jeff sugguests and do the PUTs on a differnt connection from the gets.
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
James_O_K
PostPosted: Thu Aug 24, 2006 6:40 am    Post subject: Reply with quote

Apprentice

Joined: 09 Mar 2006
Posts: 39
Location: UK

wschutz wrote:
You can only do one operation at a time on a qmgr connection.... so the PUT doesn't happen until the GET completes... do as Jeff sugguests and do the PUTs on a differnt connection from the gets.


Thanks for your reply. I guess that means then, that If I've got 4 threads doing the get, I also need 4 qmgr connections to get 4 simultaneously gets (rather than one every 5 secs as my waitinterval is 5 secs).
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Aug 24, 2006 7:22 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

In general, it's best to have one connection for each thread in a multi-threaded application, yes. Because, yes, otherwise you are single-threading your work through the single connection.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
James_O_K
PostPosted: Thu Aug 24, 2006 7:42 am    Post subject: Reply with quote

Apprentice

Joined: 09 Mar 2006
Posts: 39
Location: UK

jefflowrey wrote:
In general, it's best to have one connection for each thread in a multi-threaded application, yes. Because, yes, otherwise you are single-threading your work through the single connection.


Yes, makes perfect sense. Thanks Jeff
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 with putQueue.put() operation taking long time
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.