Author |
Message
|
amitjain |
Posted: Fri Feb 27, 2015 3:51 am Post subject: Websphere MQ 8 - how to keep Message copy |
|
|
 Apprentice
Joined: 14 Jan 2015 Posts: 39
|
Hi,
I have program which puts message on A_QUEUE and other program which gets message from the queue.
Now I want to keep a copy of all messages sent to A_QUEUE on B_QUEUE for monitoring the flow.
I have read in forum saying we can define A_QUEUE with base object of topic so when sender send message to A_QUEUE , I can have 2 subscriber queue B_QUEUE and C_QUEUE and I can modify my other program to read from C_QUEUE.
could you point to me some example script to define queue with base object of topic and how to define subscriber queues.
Thanks. |
|
Back to top |
|
 |
exerk |
Posted: Fri Feb 27, 2015 4:45 am Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
Search on the site for 'MirrorQ - anybody using in production' - PeterPotkay gives an excellent example of how to do it... _________________ 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 |
|
 |
zpat |
Posted: Fri Feb 27, 2015 5:09 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Don't use mirrorQ, it's a low level exit and unsupported.
Use a topic alias queue and two administrative subscriptions.
Ensure the PSMODE enabled (only need do this once).
ALTER QMGR PSMODE(ENABLED)
Define topic object with fixed topic string (of your choice)
DEFINE TOPIC(TEST.DUP) TOPICSTR('/MQ/DUPLICATE/TEST.QUEUE1')) DURSUB(YES) REPLACE
Define topic alias queue using topic object
DEFINE QALIAS(TEST.ALIAS) DEFPSIST(YES) TARGTYPE(TOPIC) TARGET(TEST.DUP) REPLACE
Define local queues to receive the messages (they could also be remote queues as needed)
DEFINE QLOCAL(TEST.QUEUE1) DEFPSIST(YES) REPLACE
DEFINE QLOCAL(TEST.QUEUE2) DEFPSIST(YES) REPLACE
Define admin durable subscriptions
DELETE SUB(TEST.SUB1)
DEFINE SUB(TEST.SUB1) DEST(TEST.QUEUE1) TOPICOBJ(TEST.DUP) PSPROP(NONE)
DELETE SUB(TEST.SUB2)
DEFINE SUB(TEST.SUB2) DEST(TEST.QUEUE2) TOPICOBJ(TEST.DUP) PSPROP(NONE)
Now - just put a message to TEST.ALIAS and it should appear on both local queues _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
exerk |
Posted: Fri Feb 27, 2015 5:17 am Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
My point was, had the OP found the post he/she would also have found the background to why not to use MirrorQ, and the explanation of how to use Pub/Sub... _________________ 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 |
|
 |
zpat |
Posted: Fri Feb 27, 2015 5:30 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
It was ambiguous (not to me of course) but a bear-trap for newbies.  _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
rammer |
Posted: Fri Feb 27, 2015 5:38 am Post subject: |
|
|
Partisan
Joined: 02 May 2002 Posts: 359 Location: England
|
Zpat.
Thanks for that example. for some reason Ive had a mental block on Pub / Sub but that works great and easily explained. |
|
Back to top |
|
 |
amitjain |
Posted: Fri Feb 27, 2015 5:54 am Post subject: |
|
|
 Apprentice
Joined: 14 Jan 2015 Posts: 39
|
Hi zpat,
Thanks for the script. It is working perfectly.
I am using MQ version 8 and looks like PSMODE is by default enabled on it.
One query , will it copy all MQ header fields it receives on TEST.ALIAS to subscriber queue ?
Is it enough to do setmqaut on TEST.ALIAS or I need to give setmqaut to TEST.DUP also. |
|
Back to top |
|
 |
zpat |
Posted: Fri Feb 27, 2015 5:59 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Hmm, one weakness of pub/sub is that it doesn't preserve certain MQMD fields like msgid and correlid.
If the subscription is owned by mqm, then I don't think permissions will be an issue. _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
amitjain |
Posted: Fri Feb 27, 2015 6:08 am Post subject: |
|
|
 Apprentice
Joined: 14 Jan 2015 Posts: 39
|
If I put message directly on TEST.QUEUE1 it display my userid but if message is put on TEST.ALIAS , it appears on TEST.QUEUE1 as mqm.
Is there a way to keep original user identifier of message?
or can I log information in MQ log who was the user putting message on TEST.ALIAS
Thanks. |
|
Back to top |
|
 |
zpat |
Posted: Fri Feb 27, 2015 7:16 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Why does it matter? If you create the sub with id "x" then that is what will be used.
Quote: |
When making a subscription you can choose to set your identity context fields for publications that are sent to you. The option MQSO_SET_IDENTITY_CONTEXT indicates you want to do this and then the MQSD. PubAccountingToken and MQSD.PubApplIdentityData fields become input fields. The other identity context field is your user ID (which may be an alternate one from above). As with MQOPEN you must have appropriate authority to be able to set your identity context |
This is for programmatic sub - for admin sub - any options will be in the define sub documentation.
Now you want to log who has put to a queue? Why? What happens if you get a million puts - you want a log file of a million records?
Anyone who has put authority can put to that queue. Use access control rules to restrict it.
I agree it would be nice for admin subs to leave the MQMD alone.
VOTE FOR IT HERE
https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=35062
General Info here
ftp://public.dhe.ibm.com/software/integration/support/supportpacs/individual/ma0dmqv7.pdf _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
rammer |
Posted: Fri Feb 27, 2015 7:23 am Post subject: |
|
|
Partisan
Joined: 02 May 2002 Posts: 359 Location: England
|
Hi Zpat
How does this bit actually work
<<TOPICSTR('/MQ/DUPLICATE/TEST.QUEUE1'))>>
I ask as I have just tested your scripts and it worked great, but cant see anything that actually references TOPICSTR.
Thanks |
|
Back to top |
|
 |
zpat |
Posted: Fri Feb 27, 2015 7:57 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
That topic string is stored in the topic object. The other defines reference the topic object (and therefore implicitly the topic string).
This topic string can be any (unique and valid) value. It does not have to contain the queue name.
The topic object also controls the security access. You grant permissions on this name, (object type topic) using setmqaut commands. _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
tczielke |
Posted: Sat Feb 28, 2015 6:15 am Post subject: Re: Websphere MQ 8 - how to keep Message copy |
|
|
Guardian
Joined: 08 Jul 2010 Posts: 941 Location: Illinois, USA
|
amitjain wrote: |
Now I want to keep a copy of all messages sent to A_QUEUE on B_QUEUE for monitoring the flow. |
I am not sure what all of your requirements are, but you may also want to review the Application Activity Trace (available at version 7.1 and higher), if you haven't already. The Activity Trace has functionality to record the entire message, plus you get extra application behavioral details that can be helpful for monitoring an application. _________________ Working with MQ since 2010. |
|
Back to top |
|
 |
amitjain |
Posted: Thu Mar 05, 2015 2:40 am Post subject: |
|
|
 Apprentice
Joined: 14 Jan 2015 Posts: 39
|
Hi Tczielke,
I read in the forum suggesting that enabling application activity trace leads to performance issue and also need to have some periodic cleanup job to clean the recorded messages in log file.
I am using the copy message in test environment as both sender and receiver application are integrating first time over MQ and in case of some bug in application messages may be lost , so If I have a copy I can re-push to sender/receiver application without asking actual application to redo anything.
Since I have multiple sender , I just wanted to save original user in MQMD to identify original buggy sender application. |
|
Back to top |
|
 |
tczielke |
Posted: Thu Mar 05, 2015 5:31 am Post subject: |
|
|
Guardian
Joined: 08 Jul 2010 Posts: 941 Location: Illinois, USA
|
Based on a better understanding of your requirements, it doesn't sound like the Activity Trace is a good fit then.
If I understand correctly, this "mirror queue" will be an ongoing approach to collect messages that these sender applications are producing for the needs of sender application identification or replaying the message. Out of curiousity, how will you handle the maintenance on this mirror queue from an ongoing standpoint (i.e. removing messages on the mirror queue so it does not fill up, storing the removed messages and for how long, etc.)? _________________ Working with MQ since 2010. |
|
Back to top |
|
 |
|