Author |
Message
|
nike0181 |
Posted: Sat Nov 10, 2012 8:35 pm Post subject: ALTER V/S DEFINE with REPLACE |
|
|
Newbie
Joined: 10 Nov 2012 Posts: 2
|
Hi Members,
Please help me in differentiating the use between ALTER and DEFINE with REPLACE. Why to use ALTER when we can use DEFINE with REPLACE. If we can use DEFINE with REPLACE for any MQ object, are there any limitations?
Please help me in differentiating between these 2 commands along with limitations and dependencies.
Thanks in advance. |
|
Back to top |
|
 |
exerk |
Posted: Sun Nov 11, 2012 4:23 am Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
They do what it says on the tin - one replaces an existing object with an object of the same name but possibly of different type, and the other changes an attribute, or attributes, of an existing object.
Why replace an object when only one or two attributed require altering? _________________ 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 |
|
 |
Vitor |
Posted: Sun Nov 11, 2012 5:41 am Post subject: Re: ALTER V/S DEFINE with REPLACE |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
nike0181 wrote: |
If we can use DEFINE with REPLACE for any MQ object, are there any limitations? |
Yes. If you use DEFINE with REPLACE to change the attributes of an object and misspell the object name (and by that I include getting the case of the name wrong) then the command will succeed but the object you expect to be changed will not be.
Likewise if you routinely use DEFINE with REPLACE to create new objects, and 2 people attempt to define the same object with different attributes, both commands will succeed but one person will get the wrong attributes.
Depends on how good your control processes are.
You also may not want to do a DEFINE with REPLACE when the alteration you're trying to do is PUT(DISABLE) because the queue has thousands of valid messages on it and you want to signal the putting application that the getting application's out to lunch. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
nike0181 |
Posted: Sun Nov 11, 2012 12:42 pm Post subject: |
|
|
Newbie
Joined: 10 Nov 2012 Posts: 2
|
Thanks Guys, Actually My MQ Objects have got 2 attributes which are to be altered like XMIT queue of Channel and TRIGDATA of XMIT queue. Now to alter them all the time it involves lot of logic and effort, So I was wondering if I can use REPLACE option.
P.S: I am new to MQ, so please suggest me one of the above method |
|
Back to top |
|
 |
mqjeff |
Posted: Sun Nov 11, 2012 2:54 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
...
You shouldn't be changing the XMITQ or TRIGDATA of a channel frequently.
Why are you trying to change these frequently? |
|
Back to top |
|
 |
Vitor |
Posted: Sun Nov 11, 2012 3:11 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqjeff wrote: |
You shouldn't be changing the XMITQ or TRIGDATA of a channel frequently.
Why are you trying to change these frequently? |
You want a suggestion? If you need to change these frequently, you're doing something wrong. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
exerk |
Posted: Mon Nov 12, 2012 12:45 am Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
nike0181 wrote: |
...to alter them all the time it involves lot of logic and effort... |
The effort to alter is the same as that to replace, and bearing in mind the comments of my fellow posters, whom I agree with, what is the reason you want to do this? _________________ 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 |
|
 |
PeterPotkay |
Posted: Mon Nov 12, 2012 7:04 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
The below basically repeats what Vitor said above, but with examples. I copy and pasted what I sent to someone asking the exact same question in house here.
I'd go with Alter. It preserves the original Create date/time.
Define with Replace is a bit dangerous, because it just blows away and recreates queues if they exist, or creates them if they don't, and the person running the script doesn't know which happened unless they go and cross check each queue.
If you want to change an existing MY.SCOTT queue, better to use the alter command. That way if you mess up and try to alter MY.SCOOT, your script will bark and you'll know you misspelled it. If you DEFINE/REPLACE and misspell it with MY.SCOOT, your script finishes, your MY.SCOTT didn't get changed, you added a bogus MY.SCOOT, and you give it to the customer who then has problems and you have extra bogus queues.
Even when building new queues to add to an existing QM, don't use DEFINE with REPLACE. Here's why: MY.PETER exists, and it’s a remote queue that aims at SOMEQM for example. You need to add a MY.PETER.1 queue to aim at SOMEOTHERQM. You use DEFINE/REPLACE, but mess up and forget to add the ".1" at the end of the new DEFINE statement. You run your script in Production, it works 100%, you go to bed, and you didn't realize that MY.PETER.1 never got created (customer #1 ticked off), but you also inadvertently screwed up MY.PETER which now aims at the wrong QM (customer #2 even more ticked off)
Don't use DEFINE/REPLACE! There's no harm really if your script is 100% correct, other than you erase the original create date, which you might want. But if your script is not 100%, it could execute as if it was and you'll never know until the problems start or you double check each and every line item in the output and hopefully catch the typo (that you didn't catch when you built the script to begin with).
You may or may not want to add the FORCE option on the ALTER. If a queue is open and you try to ALTER certain parameters, MQ won't let you if the queue is open, and the ALTER will fail. You might want to know that. Or, you use FORCE and make the change anyway, but then the app will get a MQRC that says the object changed and they will need to reopen the queue to pick up the change. Only certain parms need the FORCE if the queue is open, things like Remote QM name, or XMITQ, or Remote Q name, things that affect where messages go. Changing other things like Max Depth or Description doesn't care if the q is open or not. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Nov 12, 2012 7:40 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
There is also one aspect which has been "swept under the rug" here.
If you use define/replace the attributes not specified in the define/replace revert to the default attributes. Alter does not have that effect.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Vitor |
Posted: Mon Nov 12, 2012 7:43 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
fjb_saper wrote: |
There is also one aspect which has been "swept under the rug" here.
If you use define/replace the attributes not specified in the define/replace revert to the default attributes. Alter does not have that effect.  |
Very good point. Of course, you can always change the defaults if you want to, but it's absolutely the case that anything not specified on a define will become the defaults (however they're defined) _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mhashkhan |
Posted: Wed Feb 25, 2015 8:07 pm Post subject: |
|
|
 Apprentice
Joined: 01 Dec 2008 Posts: 28
|
Hi,
What changes it makes to authority given to the object.
I know alter doesn't impact the authorities, but does DEFINE with REPLACE will remove all given authorities? |
|
Back to top |
|
 |
JosephGramig |
Posted: Thu Feb 26, 2015 5:51 am Post subject: |
|
|
 Grand Master
Joined: 09 Feb 2006 Posts: 1244 Location: Gold Coast of Florida, USA
|
mhashkhan wrote: |
Hi,
What changes it makes to authority given to the object.
I know alter doesn't impact the authorities, but does DEFINE with REPLACE will remove all given authorities? |
DEFINE/REPLACE will not affect authorities. |
|
Back to top |
|
 |
|