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 API Support » How to skip Message and move to the next one.

Post new topic  Reply to topic
 How to skip Message and move to the next one. « View previous topic :: View next topic » 
Author Message
bhu
PostPosted: Wed Sep 13, 2006 6:57 am    Post subject: How to skip Message and move to the next one. Reply with quote

Novice

Joined: 27 Jun 2006
Posts: 19

we are writing a batch process which will open the queue manger and starts reading the message one by one and do some work.

for some reason the work it does fails then we need to skip to the next message, how can we do this ?
the code is

queueManger = new MQQueueManager(QueueManagerName,channelName,connectionName);
queue = queueManger.AccessQueue(QueueName,MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE);
MQGetMessageOptions oGetMsgOption = new MQGetMessageOptions();
oGetMsgOption.Options = MQC.MQPMO_SYNCPOINT;
while(queue.CurrentDepth > 0)
{
queueMessage = new MQMessage();
queueMessage.Format = MQC.MQFMT_STRING;
queue.Get(queueMessage,oGetMsgOption);
OrderAckWS(queueMessage.ReadString(queueMessage.MessageLength)); //Failed need to skip here
queueManger.Commit();
}
queue.Close();
queueManger.Disconnect();

any idea
thanks
bhu
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Sep 13, 2006 7:48 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Define "skip"?

Do you mean "leave on the queue"?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
bhu
PostPosted: Wed Sep 13, 2006 8:06 am    Post subject: Reply with quote

Novice

Joined: 27 Jun 2006
Posts: 19

yes i mean leave it on the queue, and move to the next message,
when this batch runs again it will pick that message again, if error occurs again leave it and move to the next one.
thanks
bhu
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Sep 13, 2006 8:16 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You could skip the commit if an error occurs.

That would leave the message in an uncommitted get, and the next get would get the first uncommitted message.

Then do a rollback as the final step in your code, or otherwise make sure a rollback occurs. (read up on explicit versus implicit rollbacks).

The problem with this is that it's hard on the system and hard on the logs and etc.

Another option is to use a combination of Browse and destructive gets.

Both of these options mean that the queue is going to fill up over time with unprocessable messages.

This is why the recommended design pattern is to use a backout queue.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
tleichen
PostPosted: Wed Sep 13, 2006 8:18 am    Post subject: Reply with quote

Yatiri

Joined: 11 Apr 2005
Posts: 663
Location: Center of the USA

bhu wrote:
yes i mean leave it on the queue, and move to the next message,
when this batch runs again it will pick that message again, if error occurs again leave it and move to the next one.
thanks
bhu

If the first message fails processing, why would the second one not? Is the nature of the data varying, such that the process would vary as well? If so, maybe your MQSeries architecture needs to be reworked, as it sounds like you have varying types of messages on the same queue, that would be better facilitated on multiple queues. Just my two cents...
_________________
IBM Certified MQSeries Specialist
IBM Certified MQSeries Developer
Back to top
View user's profile Send private message
bhu
PostPosted: Wed Sep 13, 2006 10:12 am    Post subject: Reply with quote

Novice

Joined: 27 Jun 2006
Posts: 19

the messages are same, but say when we read the message and update a database and let u ssay it failed, due various reasons , basically i don;t want to come out of the program instead it will send a notification (Email) and move to the next message and update the database.

and we can go and find out what the issue with the database for that particular message and correct if possible.
thanks
bhu
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Sep 13, 2006 10:14 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

This is exactly the kind of thing a backout queue is designed for.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
bhu
PostPosted: Wed Sep 13, 2006 12:10 pm    Post subject: Reply with quote

Novice

Joined: 27 Jun 2006
Posts: 19

can u please tell me how to do it the (back out Queue ) or point to some sample. I want to Try it.
thanks
bhu
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Sep 13, 2006 12:21 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

basically, you just use Backout to fail the transaction. Then, when you get a message you check if the Backout count on the MQMD is greater than the Backout Threshold on the queue, and if it is then instead of backing the message out you put it to the Backout Queue named on the queue def.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
sanvij
PostPosted: Wed Sep 13, 2006 12:25 pm    Post subject: Reply with quote

Novice

Joined: 21 Mar 2003
Posts: 24

When a message fails to get processed the application should move the message to a ERROR /POINSON queue. This will clear the path for the forth coming messges to be worked on.
_________________
Sanvij
IBM Certified MQSeries Specialist
IBM Certified WebSphere MQ Solution Designer
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 API Support » How to skip Message and move to the next one.
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.