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 » WebSphere Message Broker (ACE) Support » Issue on processing message from MQ

Post new topic  Reply to topic
 Issue on processing message from MQ « View previous topic :: View next topic » 
Author Message
sivaks
PostPosted: Wed Jan 11, 2012 7:24 am    Post subject: Issue on processing message from MQ Reply with quote

Newbie

Joined: 11 Jan 2012
Posts: 3

Hi,

I am reading messages from MQ through JavaCompute node(MQInput). After completing process that message, I lookup MQ directly to find out any more messages are available to process. The reason is that i wanted to perform batchInsert to avoid 1 DB call per transaction, since the amount of inserts are really huge. I have posted around 100 messages to MQ. Once the control goes to evaluate method, I am processing the first message. After that, reading the message from MQ directly. I am able to process that message from queue without any issues. This process will be in loop. It will be reading from the queue continously until it reaches its max count. I have set max count as 50. When it starts reading the second message, I get the below exception.

com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2033

It clearly indicates that there are no more messages available in the queue. It is not correct, I am able to see the messages in the queue. At that time, i am seeing queue depth as 78, it means that more messages available in that queue.

But I see that, evaluate method of JavaCompute node gets invoked again and process 2 messages and throws the above exception again.

This process continues until it process all the 100 messages in the queue.

I am not able to understand, why it throws that exception after reading 2 messages and starts processing again. I did set WAIT time(variation of 1000/5000/10000 milliseconds), so that it waits for some time to read the message from queue, since MQInput java compute node process it so quickly.

I tried both ways, without WAIT and with WAIT time, still it process the same way. I tried submitting 10 or 50 or 100 messages. All the time, it process only 2 messages at a time. One more point, it is just one thread.

String queueManager = getBroker().getQueueManagerName();
MQQueueManager qMgr = new MQQueueManager(queueManager);
int openOptions = 17;
MQQueue queue = qMgr.accessQueue(QName, openOptions);
MQMessage msg = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = CMQC.MQGMO_WAIT;
gmo.waitInterval = 10000;
for(int i=1; i<= recordCount; i++){
/* keep getting messages until it reaches the recordCount */
queue.get(msg,gmo);
if(msg != null){
String Str = msg.toString();
byte msgLength[]=new byte[msg.getDataLength()];
msg.readFully(msgLength);
String msgFull = new String(msgLength);
processMessage(msgFull);
}
}

Request your input on this.

Regards,
Siva
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jan 11, 2012 7:27 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Don't do this.
Use a collector node or something to generate batch inserts.

Secondly, you're asking it to get the next message with the same message id as the last message. MQ programming 101.

This is *another* reason why you shouldn't do this.
Back to top
View user's profile Send private message
sivaks
PostPosted: Wed Jan 11, 2012 7:41 am    Post subject: Reply with quote

Newbie

Joined: 11 Jan 2012
Posts: 3

Thanks a lot Jeff for your quick feedback!!

I will into this alternative approach.
Back to top
View user's profile Send private message
zpat
PostPosted: Wed Jan 11, 2012 8:27 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

You are reading MQ messages directly from your own Java code inside WMB - this has to be a horrendous abuse of WMB - which has more built in facilities to access MQ messages than you could ever wish for.

Why are you doing this in your own code, when you have WMB? This is exactly the sort of problem that allowing Java inside WMB causes.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jan 11, 2012 8:42 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

zpat wrote:
You are reading MQ messages directly from your own Java code inside WMB - this has to be a horrendous abuse of WMB - which has more built in facilities to access MQ messages than you could ever wish for.


As well as being an issue with transactionality as it bypasses WMB's controls.
_________________
Honesty is the best policy.
Insanity is the best defence.
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 » WebSphere Message Broker (ACE) Support » Issue on processing message from MQ
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.