Author |
Message
|
pgovinda |
Posted: Wed Nov 25, 2009 10:29 am Post subject: Can we get persistence property of a queue with java apis |
|
|
Novice
Joined: 27 Feb 2008 Posts: 10
|
Hello -
While defining MQ Queues, the user can specify the persistence type of the queue to be Persistent/Non-Persistent.
From our application we would like to get a hold of this property to make sure that things are setup correctly.
I was wondering if the mq java package provides a way to get a hold of this property? I dont see a method for this in the MQQueue.java class.
If any of you have done this before, I'd greatly appreciate it if you can share your thoughts.
Thanks
Prashanth |
|
Back to top |
|
 |
Vitor |
Posted: Wed Nov 25, 2009 12:05 pm Post subject: Re: Can we get persistence property of a queue with java api |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
pgovinda wrote: |
While defining MQ Queues, the user can specify the persistence type of the queue to be Persistent/Non-Persistent. |
No they don't - the admin sets it up. And it's the default persistence (as has been mentioned many times in this forum); queues are neither persistent nor non-persistent, it's a message property.
pgovinda wrote: |
From our application we would like to get a hold of this property to make sure that things are setup correctly. |
This is a very odd thing to do from an application - if you don't just your administrator to set up the queues correctly, how do you know anything else is working?
It's also unnecessary. As I said above, persistence is a message property. If your application wants to enforce persistence (or non-persistence) all it needs to do is explicitly set the property on the message when it puts it rather than just take the queue default. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mvic |
Posted: Wed Nov 25, 2009 2:14 pm Post subject: Re: Can we get persistence property of a queue with java api |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
pgovinda wrote: |
If any of you have done this before, I'd greatly appreciate it if you can share your thoughts. |
There are 2 ways to go relating to message persistence in an application, and the architect should decide which one is to be used.
1. In the application code, choose to defer the choice of message persistence to the DefPersistence (DEFPSIST) property of the queue definition held by the queue manager. MQPER_PERSISTENCE_AS_Q_DEF is the MQI constant to look up in the manuals. It is then the responsibility of the MQ administrators to set the default persistence correctly on the queue.
2. In the application code, choose deliberately what persistence setting your message will have. MQPER_PERSISTENT and MQPER_NOT_PERSISTENT are the MQI constants to look up. Messages put in this way are not influenced by any changes to the default persistence on the queue definition. |
|
Back to top |
|
 |
pgovinda |
Posted: Wed Nov 25, 2009 2:23 pm Post subject: |
|
|
Novice
Joined: 27 Feb 2008 Posts: 10
|
Hi -
In our application, we have the user define the MQ Manager and the MQ Queue. And we just ask for the name of the qmanager and queue to which we need to put the message into.
Because some customers have dedicated MQ Admins, we dont mess with creating their MQ objects for them.
We take the settings in the queue for persistence and dont make it part of our message settings.
But however we want to check that the queue was created properly. When I go through the MQ Queue creation wizard, there is an option to set the persistence type for the queue and the default is "Non Persistent".
So I was just wondering if we can check the queue property programatically using the apis in com.ibm.mq package
Thanks |
|
Back to top |
|
 |
Vitor |
Posted: Wed Nov 25, 2009 2:33 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
pgovinda wrote: |
We take the settings in the queue for persistence and dont make it part of our message settings. |
Why? If it's important, why not enforce it with the application as the software is designed to do?
pgovinda wrote: |
But however we want to check that the queue was created properly. |
Again why? If it's important, use the application.
pgovinda wrote: |
When I go through the MQ Queue creation wizard, there is an option to set the persistence type for the queue and the default is "Non Persistent". |
And if, like many people, the queues have not been created using the wizard (becuase it's not the easiest way) the queue could default to either setting. Because there are many ways to set a "default" for new queues.
pgovinda wrote: |
So I was just wondering if we can check the queue property programatically using the apis in com.ibm.mq package |
No, but you could write an application that issuses PCF messages. I still ask why bother? It's easier to enforce persistence with the application, and only slightly more difficult to enforce standards with the admins to create queues properly.
Certainly easier than letting the queues be created, check them with this new application then go back to the admins and have the queue settings changed imho. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
PeterPotkay |
Posted: Wed Nov 25, 2009 2:34 pm Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
pgovinda wrote: |
But however we want to check that the queue was created properly. |
So you figure out how to do this, the queue is set properly when you check at 12:00:00, and then I go and switch it at 12:00:01.
If you want persistent messages, code your app to produce persistent messages.
If you want non-persistent messages, code your app to produce non-persistent messages.
End of story.
Personally I think anyone that relies on the queue attribute to set the message's persistence is being a lazy programmer. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
mvic |
Posted: Wed Nov 25, 2009 2:35 pm Post subject: |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
pgovinda wrote: |
So I was just wondering if we can check the queue property programatically using the apis in com.ibm.mq package |
There is no need.
If you need the message to be persistent, add this setting to the message before sending.
If you need the message to be non-persistent, add this setting to the message before sending.
If you need the message to inherit the default persistence on the queue, then add this "as-q-def" setting to the message before sending. |
|
Back to top |
|
 |
pgovinda |
Posted: Wed Nov 25, 2009 2:45 pm Post subject: |
|
|
Novice
Joined: 27 Feb 2008 Posts: 10
|
Sure ... I can code it to have persistent messages...but its not as simple since its a different team that puts the message on the queue...
Anyways ... the only responses I see here is that change ur code.... can someone just tell me whether its possible to do the check or not ?
Thanks |
|
Back to top |
|
 |
Vitor |
Posted: Wed Nov 25, 2009 3:02 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
pgovinda wrote: |
Anyways ... the only responses I see here is that change ur code.... can someone just tell me whether its possible to do the check or not ? |
My comment about PCF messages was typed in invisible type? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
pgovinda |
Posted: Wed Nov 25, 2009 3:12 pm Post subject: |
|
|
Novice
Joined: 27 Feb 2008 Posts: 10
|
oh ok .... sorry i wasnt quite sure by what the sentence meant because it started with a No
[No, but you could write an application that issuses PCF messages. I still ask why bother?]
I now realize that its possible... Sorry I am a newbie to these apis as well....so i am not really sure what pcf is also...but I guess I can look it up.
Thanks
[/quote] |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Nov 25, 2009 3:56 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
pgovinda wrote: |
Sure ... I can code it to have persistent messages...but its not as simple since its a different team that puts the message on the queue...
Anyways ... the only responses I see here is that change ur code.... can someone just tell me whether its possible to do the check or not ?
Thanks |
I may not be as simple but it is the Applications Team's RESPONSIBILITY.
The application dictates the persistency of the message.
As for the PCF messages check support pack MS0B (java).  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Vitor |
Posted: Wed Nov 25, 2009 4:00 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
pgovinda wrote: |
oh ok .... sorry i wasnt quite sure by what the sentence meant because it started with a No |
Followed by a but however. I could have been clearer.
pgovinda wrote: |
I now realize that its possible... Sorry I am a newbie to these apis as well....so i am not really sure what pcf is also...but I guess I can look it up. |
Programmable Command Format. If you're a newbie you may need a few attempts - it's a more advanced topic that simple messaging. But PCF is fully documented.
One of the reasons everybody's advising you to force persistence with the application. The options are far more complex and costly to maintain.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
gunter |
Posted: Thu Nov 26, 2009 12:28 am Post subject: |
|
|
Partisan
Joined: 21 Jan 2004 Posts: 307 Location: Germany, Frankfurt
|
Hi,
you asked for a way to do it, not for a reason not to do it.
- look for MQINQ (I never used it, because ... see the other posts)
or
- use PCF commands or easier to handle MQAI
For MQINQ your application need the accessright on the object.
PCF- and MQAI-commands are administration tasks, they need a running command server and you have to be a memeber of the group mqm.
Quote: |
Sorry I am a newbie to these apis as well |
PCF and MQAI are not easiest way to start programming mq _________________ Gunter Jeschawitz
IBM Certified System Administrator - Websphere MQ, 5.3 |
|
Back to top |
|
 |
Vitor |
Posted: Thu Nov 26, 2009 7:39 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
gunter wrote: |
PCF- and MQAI-commands are administration tasks, they need a running command server and you have to be a memeber of the group mqm. |
Another valid reason not to do this - it means your applications need to run with administrative authority. This means any malicious application has full control over the WMQ estate.
You may not consider this a serious risk. Whoever does security for your client sites may have a different view, and might refuse such access. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Nov 27, 2009 4:05 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
gunter wrote: |
you have to be a memeber of the group mqm. |
No this is not strictly true.
You need sufficient privileges to open a reply queue and put messages to the command queue.
And you need sufficient privileges to execute the PCF command you want.
In *some* cases, that privilege requires mqm membership, but not in all. INQUIRE QNAMES for example. |
|
Back to top |
|
 |
|