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 Discussion » copying a message

Post new topic  Reply to topic
 copying a message « View previous topic :: View next topic » 
Author Message
vibhu007
PostPosted: Tue Aug 30, 2005 4:16 pm    Post subject: copying a message Reply with quote

Newbie

Joined: 29 Aug 2005
Posts: 6

Hi,

I have a requirement where a message put on a queue(Q1) should get copied to one more queue(Q2). Any idea how this can be achieved.
This is on unix.

Thanks.
Back to top
View user's profile Send private message
wschutz
PostPosted: Tue Aug 30, 2005 4:22 pm    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

look at the mq docs for "Distribution Lists"
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
hopsala
PostPosted: Tue Aug 30, 2005 4:45 pm    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

Several options:

1. Use a distribution list - In the sending application, instead of MQOPENing one queue, you open a list containing both, and when you MQPUT to the list the same message is sent to both. Read the Programming Guide on how to use distribution lists.

2. In the sending application - open two queues, MQPUT twice the same message...

3. If, for some reason, you cannot change sending application code do the following: Say you had application APPLA sending to Q1 on remote qmanager QM, this is done with a remote queue called QR1 and a transmission queue called TO.QM (these are terrible names, just for this example, never to be used again).
What you do is change QR1 so that it is directed to a new local queue called TOQ1, create another remote queue called QR1REAL which is defined like QR1 was defined before, and define QR2 to Q2. Write a small application (about 10 lines) which simply reads everything in TOQ1 and sends it to QR1REAL and to QR2 using either destination lists or two MQPUTs. No code changes to application.

So if once the flow looked like this: APPLA -> QR1 -> TO.QM (transmission) -> Q1
It will now look like this: APPLA -> QR1 -> TOQ1 (local) -> splitting application -> put to QR1REAL and QR2 -> TO.QM and Q2

You should only use this solution if it is only temporary, otherwise change the sending application. It is not exactly a "robust" solution, but merely a patch, and patches tend to unweave...

4. If you meant (it is not clear from your post) real message duplication only AFTER the message is in Q1, then simply have the application reading that queue MQPUT every message it MQGETs under syncpoint.

There are probably other options, but I haven't enough info on your problem to offer more.
Back to top
View user's profile Send private message
EddieA
PostPosted: Tue Aug 30, 2005 6:09 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Search for MirrorQ.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Tue Aug 30, 2005 6:41 pm    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
Location: London, ON Canada

Hi,

MirrorQ is a message exit and a lot of people use it.

Years ago, I wrote a program called: mmx (Message Multi-Plexer). It is a simple program to move a message from a source queue to 'n' target queues (replicates MQMD & data). You can download it and the 'C' source for it from:
http://www.capitalware.biz/mq_code_c.html

Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
bower5932
PostPosted: Wed Aug 31, 2005 7:10 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

And there are two versions of mirrorq. One of them uses triggering and the other uses API exits:

http://www.developer.ibm.com/isv/tech/sampmq.html
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
paulgroo
PostPosted: Fri Sep 02, 2005 6:16 am    Post subject: Reply with quote

Centurion

Joined: 07 Jul 2005
Posts: 138
Location: Ireland

I have this workiong on a system here. I have created a shadow queue that gets a copy of everything that gets sent to the main queue. I had to create an Initiation Queue and Process Triggerbut it works fine.
Back to top
View user's profile Send private message MSN Messenger
zpat
PostPosted: Fri Sep 02, 2005 7:01 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

You could also write a small "broker" application to read an input queue and write the messages to two output queues, that way the original applications do not have to be changed (which is sometimes more trouble that it's worth).

If you have the IBM Message Broker - a message flow to do this could be developed in a few minutes, otherwise use a programming language.
Back to top
View user's profile Send private message
vinoth
PostPosted: Fri Sep 02, 2005 9:56 pm    Post subject: Reply with quote

Apprentice

Joined: 03 Mar 2005
Posts: 31

Simplest of all is using the q utility given by IBM, just define the q utility in the process definition, and call it once a message appears in ur main queue.
download the utility from the following link.
http://www-1.ibm.com/support/docview.wss?uid=swg24000647
Back to top
View user's profile Send private message Send e-mail
hopsala
PostPosted: Sat Sep 03, 2005 5:20 am    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

vinoth wrote:
Simplest of all is using the q utility given by IBM, just define the q utility in the process definition, and call it once a message appears in ur main queue.

First of all, I would like to emphesize this is not reallt "given by IBM" but just "may be downloaded from IBM's site" - this is a category 2 support pack, which means
IBM wrote:
Technical support
Category 2 SupportPacs are provided in good faith and AS-IS. There is no warranty or further service implied or committed and any supplied sample code is not supported via IBM product service channels.

So one cannot use unlicensed progs, or simply doesn't trust them, he shouldn't use this solution.
Back to top
View user's profile Send private message
hopsala
PostPosted: Sat Sep 03, 2005 5:38 am    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

vinoth wrote:
Simplest of all is using the q utility given by IBM, just define the q utility in the process definition, and call it once a message appears in ur main queue.

Second, there are a few small probs with ma01 concerning the given scenario: naturally you'll want to start it using the runmqtrm, thing is it doesn't receive parameters like runmqtrm supplies them - so you'll have to hardcode the queue, qm and other parms in the PROCESS def. This is OK, but if you have more than one queue from which you wish to duplicate, then you'll have to have another trigger monitor - one for each such queue.
A good solution for this would be to write a batch file, which receives parameters in the order given by runmqtrm and translates to the parmameters which ma01 expects.

Another option is using "-*" which supposedly should do an endless loop MQGETting the queue, but for some silly reason asks you each time "Do you want to connect again (y/n) ?" - however you can simply create a file with 100000 "y"+CR\LF and send it to standard input.

I had just downloaded it, so if i'm wrong about anything I will happily stand corrected.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Sep 03, 2005 7:41 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

hopsala wrote:
vinoth wrote:
Simplest of all is using the q utility given by IBM, just define the q utility in the process definition, and call it once a message appears in ur main queue.

Second, there are a few small probs with ma01 concerning the given scenario: naturally you'll want to start it using the runmqtrm, thing is it doesn't receive parameters like runmqtrm supplies them - so you'll have to hardcode the queue, qm and other parms in the PROCESS def. This is OK, but if you have more than one queue from which you wish to duplicate, then you'll have to have another trigger monitor - one for each such queue.
A good solution for this would be to write a batch file, which receives parameters in the order given by runmqtrm and translates to the parmameters which ma01 expects.

Another option is using "-*" which supposedly should do an endless loop MQGETting the queue, but for some silly reason asks you each time "Do you want to connect again (y/n) ?" - however you can simply create a file with 100000 "y"+CR\LF and send it to standard input.

I had just downloaded it, so if i'm wrong about anything I will happily stand corrected.


Why more than one trigger monitor. I thought it would suffice to have one process for each queue concerned and when starting it in the background you could have more than one queue using the same trigger monitor.

Am I being naive or missing something there ?
Back to top
View user's profile Send private message Send e-mail
hopsala
PostPosted: Sun Sep 04, 2005 1:27 am    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

Hm, you are generally right, but I just did a re-check of this and there's another prob: The runmqtrm activates progs with the following parms "<ApplId> <MQTMC2> <EnvData>", so theoretically you should be able to create a process with ApplId="q.exe -m QMNAME -i INQNAME -o OUTQNAME. Thing is, ma01 does not accept redundant parameters, so the MQTMC2 does not let the executable run (you get a "usage" printout)
There is a silly workaround - putting in the PROCESS ApplId="q.exe -m QMNAME -i INQNAME -o OUTQNAME | echo " or something similar, thus the MQTMC2 is sent to echo and is effectively ignored.

With all that in mind, you're right on the dot - no need for two trig monitors, just two process defs; I err, am only human y'know
(As said, had only d/l ma01 after vinoth's post)
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sun Sep 04, 2005 4:37 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

hopsala wrote:
There is a silly workaround - putting in the PROCESS ApplId="q.exe -m QMNAME -i INQNAME -o OUTQNAME | echo " or something similar, thus the MQTMC2 is sent to echo and is effectively ignored.


I'd probably go for a shell script that ignores the MQTMC2 (%1| ${1}) parameter and passes the subsequent ones...

Code:
# case 1
# move the parm list 1 to the left
shift
# pass all remaining parms and start in background
start q.exe %*
# alternatively case 2
start q.exe %2 %3 %4 %5 %6 %7 %8 %9


Please forgive any Unix/MS DOS differences.
Back to top
View user's profile Send private message Send e-mail
hopsala
PostPosted: Mon Sep 05, 2005 7:06 pm    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

Agreed, that's why I said a few posts back that the best solution is a batch file; however, it is always better to post the actual code than talking about it (a code snippet is worth a thousand words) - future generations thank you
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General Discussion » copying a message
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.