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 » General IBM MQ Support » C# How to set message expiration

Post new topic  Reply to topic Goto page 1, 2  Next
 C# How to set message expiration « View previous topic :: View next topic » 
Author Message
zenstudent
PostPosted: Wed Sep 26, 2012 7:55 pm    Post subject: C# How to set message expiration Reply with quote

Newbie

Joined: 26 Sep 2012
Posts: 6

I am using C# and currently sending a message to a queue. Once message arrives at the target queue, I would like for the message to expire within two minutes to prevent queue buildup. How do I do that?
Back to top
View user's profile Send private message
exerk
PostPosted: Thu Sep 27, 2012 12:51 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

Set the appropriate expiry time in your messages, allowing for any transit time through networks. The Application Programming Guide (APG) is your friend in this endeavour.
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
zpat
PostPosted: Thu Sep 27, 2012 1:07 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

Of course this only matters if the message is not processed (consumed).

This sounds like a strange requirement.

Why would you not expect messages to be consumed normally? If non-consumption is exceptional then having a longer expiry (e.g. one day) would normally be enough to prevent a build-up of orphaned messages - this usually only applies when messages are consumed selectively (i.e. by matching the msgid or correlid).

Non-selective (unconditional) consumption should keep the queue clear anyway.

If you just want the latest status of something (like a share price) you should look at pub/sub and retained publications.

Better to give us the overall requirements and let us advise, than to ask a specific question about expiry.
Back to top
View user's profile Send private message
zenstudent
PostPosted: Thu Sep 27, 2012 9:22 am    Post subject: Reply with quote

Newbie

Joined: 26 Sep 2012
Posts: 6

I know this is a strange requirement, but it is what it is.

This is the snippet of code I am using to send the message:
Hashtable envr = new Hashtable();
envr.Add(MQC.CHANNEL_PROPERTY, channelName);
envr.Add(MQC.PORT_PROPERTY, port);
envr.Add(MQC.HOST_NAME_PROPERTY, hostName);
envr.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
envr.Add(MQC.MQRO_EXPIRATION, 120000);
if (!string.IsNullOrEmpty(sslCipherSpec) && !string.IsNullOrEmpty(sslCertStore))
{
envr.Add(MQC.SSL_CIPHER_SPEC_PROPERTY, sslCipherSpec);
envr.Add(MQC.SSL_CERT_STORE_PROPERTY, sslCertStore);
}
mqQMgr = new MQQueueManager(qManager, envr);
mqQueue = mqQMgr.AccessQueue(outputQname, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);
queueMessage = new MQMessage();
queueMessage.WriteString(message);
queueMessage.Format = MQC.MQFMT_STRING;
mqQueue.Put(queueMessage);

I added, "envr.Add(MQC.MQRO_EXPIRATION, 120000)", in my existing code to satisfy the expiry of 2 mins. Will this code be able to set the expiry of message to 2 mins?
Back to top
View user's profile Send private message
zpat
PostPosted: Thu Sep 27, 2012 9:55 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

Setting expiry is NOT the requirement. It is your idea of how to meet the requirement.

What is the actual requirement?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Sep 27, 2012 9:59 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You need to set the expiry on each specific message in it's mqmd, not on the connection or the environment.
Back to top
View user's profile Send private message
zenstudent
PostPosted: Thu Sep 27, 2012 10:44 am    Post subject: Reply with quote

Newbie

Joined: 26 Sep 2012
Posts: 6

mqjeff: could you provide the sample code pls. Thanks in advance.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Sep 27, 2012 5:08 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

http://pic.dhe.ibm.com/infocenter/wmqv7/v7r5/topic/com.ibm.mq.doc/un10900_.htm
Back to top
View user's profile Send private message
zenstudent
PostPosted: Thu Sep 27, 2012 7:09 pm    Post subject: Reply with quote

Newbie

Joined: 26 Sep 2012
Posts: 6

I have set the Expiry property to two mins.
Thank you so much!
Back to top
View user's profile Send private message
zpat
PostPosted: Fri Sep 28, 2012 1:16 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

Even though it may be the wrong design - oh well.....
Back to top
View user's profile Send private message
zenstudent
PostPosted: Fri Oct 05, 2012 10:13 pm    Post subject: Reply with quote

Newbie

Joined: 26 Sep 2012
Posts: 6

Code: message.Expiry = 120000;

I am setting the expiry property in the message, but the message is still not expiring. Do I need to set another parameter? Need help with the actual code pls.
Any help would be greatly appreciated.
Back to top
View user's profile Send private message
exerk
PostPosted: Sat Oct 06, 2012 1:04 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

zenstudent wrote:
Code: message.Expiry = 120000;

I am setting the expiry property in the message, but the message is still not expiring. Do I need to set another parameter? Need help with the actual code pls.
Any help would be greatly appreciated.

See note 2 HERE.
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Sat Oct 06, 2012 4:43 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

zenstudent wrote:
Code: message.Expiry = 120000;

I am setting the expiry property in the message, but the message is still not expiring. Do I need to set another parameter? Need help with the actual code pls.
Any help would be greatly appreciated.

How do you know that the messages are not expiring? Can you browse/get them from the queue?
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
zenstudent
PostPosted: Sat Oct 06, 2012 9:19 pm    Post subject: Reply with quote

Newbie

Joined: 26 Sep 2012
Posts: 6

That the messages are not expiring was confirmed by the other team which is reading the queue. The queue was building up and the messages are not getting deleted from the queue.

Any help with trying to figure out how to fix the code will be greatly appreciated.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Sun Oct 07, 2012 4:36 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Messages sitting on a queue and not getting deleted doesn't mean that they're not expired.

It only means that they're not expired if the app does NOT get an MQRC 2033 for an MQGET that matches any message.

Expired messages are removed from queues - at current releases of MQ that is - by a background process that acts at intervals. Messages are *not* immediately removed from the queue at the exact second that they are expired.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » General IBM MQ Support » C# How to set message expiration
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.