Author |
Message
|
dunesand |
Posted: Fri Jan 14, 2005 1:46 am Post subject: persistent / not-persistent messages in c# .Net |
|
|
 Acolyte
Joined: 17 Nov 2003 Posts: 65 Location: Cambridgeshire, UK
|
Hi all,
I've written an application that puts and gets messages on numerous MQ queues using c# (MQ 5.3 CSD05).
The other morning my client lost a whole load of messages and the MQ guys have said they're changing some config on the queues.
Is there anything I may be doing to set the messages as non-persistent?
From what I can tell, the message takes on the property of the queue on which it is placed?
Is there anyway to override this so that all messages are persistent?
Is this advisable?
Thanks for your help. (again!)
Here's the code I use to create and send messages with (removed error handling to make snippet more concise):
Code: |
//
// create QM object
queueManager = new MQQueueManager( queueManagerName );
//
// create the queue
MQQueue queue = null;
queue = queueManager.AccessQueue( queueName,
MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING );
MQMessage mqMsg = new MQMessage();
//
// Send the message
mqMsg.WriteString( data );
mqMsg.Format = MQC.MQFMT_STRING;
queue.Put( mqMsg );
|
|
|
Back to top |
|
 |
zpat |
Posted: Fri Jan 14, 2005 2:25 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Set the MQMD value for message persistence to PERSISTENT.
If this field is defaulted, it takes the queue default persistence value.
Don't forget if using ALIAS queues (a good idea) that then the default persistence attribute is taken from the alias definition.
This can be used as a way to make some messages persistent and other not (even when all programs are defaulting the persistence), by referencing different queue aliases.
However if you can change the program code and are certain that you always will want persistent messages, setting the MQMD as such is fine. |
|
Back to top |
|
 |
dunesand |
Posted: Fri Jan 14, 2005 2:35 am Post subject: |
|
|
 Acolyte
Joined: 17 Nov 2003 Posts: 65 Location: Cambridgeshire, UK
|
unfortunately that's the catch, I'm not sure how to do this with the .Net interface I'm using.
Thanks for your reply. |
|
Back to top |
|
 |
dunesand |
Posted: Fri Jan 14, 2005 3:19 am Post subject: |
|
|
 Acolyte
Joined: 17 Nov 2003 Posts: 65 Location: Cambridgeshire, UK
|
found it...
Code: |
//
// Send the message
MQMessage mqMsg = new MQMessage();
mqMsg.WriteString( data );
mqMsg.Format = MQC.MQFMT_STRING;
mqMsg.Persistence = MQC.MQPER_PERSISTENT;
queue.Put( mqMsg );
|
|
|
Back to top |
|
 |
PeterPotkay |
Posted: Fri Jan 14, 2005 2:12 pm Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
Persitent message are a drag on performance. You asked if you should make all you messages persistent. No. Only the ones that need to be, i.e. they need to survive a QM restart. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
any2xml |
Posted: Mon Feb 21, 2005 8:22 pm Post subject: |
|
|
Apprentice
Joined: 18 May 2004 Posts: 42
|
PeterPotkay wrote: |
Persitent message are a drag on performance. You asked if you should make all you messages persistent. No. Only the ones that need to be, i.e. they need to survive a QM restart. |
I have turned on DefaultPersist (DEFPSIST in Linux) to YES in my XMITQ and receive queues so it survives a restart. It works fine. But do I also have to turn it on for the remote queue? Are there situations where the remote queue may have some messages waiting to go? It is important that all messages through my sender and receive channels persist. _________________ A Perl Hacker
http://www.goreliance.com
http://www.any2xml.com |
|
Back to top |
|
 |
EddieA |
Posted: Mon Feb 21, 2005 11:15 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
I have turned on DefaultPersist (DEFPSIST in Linux) to YES in my XMITQ and receive queues so it survives a restart |
That isn't how it works. Persistence is an attribute of a message which is set when the message is PUT. From that point on, the message has the same persistence, no matter what the attribute of the queues it lands on in it's journey.
Take a look at this: http://www.mqseries.net/phpBB2/viewtopic.php?t=20329&highlight=, where persistence is discussed.
Quote: |
Are there situations where the remote queue may have some messages waiting to go |
I'm not sure what you mean by this. A remote queue is nothing but a definition that names the eventual Q/QM where a message is destined, and the XMITQ where it should be placed to start it's journey. (OK, it can be used for aliasing as well, but that isn't what's asked here. )
Quote: |
It is important that all messages through my sender and receive channels persist |
Only you, or the system designer, can answer that one.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
|