|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
Perl script to Move messages between queues & retain con |
« View previous topic :: View next topic » |
Author |
Message
|
LouML |
Posted: Mon Feb 01, 2016 7:19 am Post subject: Perl script to Move messages between queues & retain con |
|
|
Partisan
Joined: 10 Nov 2005 Posts: 305 Location: Jersey City, NJ / Bethpage, NY
|
Running MQServer 8.0.0.2 on a Linux VM. I'm trying to create a Perl script to MOVE messages from one queue to another. It also needs to:
A - Use MQClient::MQSeries so I can connect to remote queue managers for both the Source and Target systems
B - Retain and pass context info
I know there are existing options out there but I haven't been able to get any of them to connect to two remote queue managers and retain context.
So, first thing I did was create a Perl script that:
A - Connects to the 1st remote queue manager
B - Opens a source queue using MQOO_FAIL_IF_QUIESCING | MQOO_SAVE_ALL_CONTEXT | MQOO_INPUT_AS_Q_DEF
C - Connects to the 2nd remote queue manager
D - Opens a target queue using MQOO_FAIL_IF_QUIESCING | MQOO_PASS_ALL_CONTEXT | MQOO_OUTPUT
E - GETS a message from the source queue using MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_SYNCPOINT options
F - PUTS a message to the target queue using MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT | MQPMO_PASS_ALL_CONTEXT options.
It fails on the MQPUT with Reason Code 2097 (2097 (X'0831') MQRC_CONTEXT_HANDLE_ERROR)
I notice I get the same Queue Handle value for both the Source and Target queues (101). Is this normal since the HConn is different for each queue?
Code: |
[mqm@mqm3d ~]$ ./Queue2QueueNEW.pl -m1 QMTEST1 -q1 QL.DEV.TEST1 -x1 'NMS.SVRCONN/TCP/mqdev(1418)' -m2 QMTEST2 –q2 QL.DEV.TEST2 -x2 'NMS.SVRCONN/TCP/mqdev(1419)'
----------- Start Date/Time = Mon Feb 1 09:35:22 2016 -----------
Using MQClient::MQSeries Perl Libraries
---------------------------- Move FROM -----------------------------
MQ Queue Manager = QMTEST1
Queue Name = QL.DEV.TEST1
MQSERVER = NMS.SVRCONN/TCP/mqdev(1418)
Channel = NMS.SVRCONN
Transport = TCP
Hostname(port) = mqdev(1418)
---------------------------- TO -------------------------------------
MQ Queue Manager = QMTEST2
Queue Name = QL.DEV.TEST2
MQSERVER = NMS.SVRCONN/TCP/mqdev(1419)
Channel = NMS.SVRCONN
Transport = TCP
Hostname(port) = mqdev(1419)
---------------------------------------------------------------------
Connected to QMTEST1 (HConn1 = 16777222) at mqdev(1418) using channel NMS.SVRCONN
Opened Queue QL.DEV.TEST1 (HobjIP = 101) using MQOO_FAIL_IF_QUIESCING | MQOO_SAVE_ALL_CONTEXT | MQOO_INPUT_AS_Q_DEF
---------------------------------------------------------------------
Connected to QMTEST2 (HConn2 = 16777224) at mqdev(1419) using channel NMS.SVRCONN
Opened Queue QL.DEV.TEST2 (HobjOP = 101) using MQOO_FAIL_IF_QUIESCING | MQOO_PASS_ALL_CONTEXT | MQOO_OUTPUT
---------------------------------------------------------------------
MQGET Successful using Options MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_SYNCPOINT
Attempting MQPUT using Options MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT | MQPMO_PASS_ALL_CONTEXT
MQPUT ERROR: Problem Putting to Queue: QL.DEV.TEST1, 2097: Queue handle referred to does not save context.
MQBACK called
Closed Queue QL.DEV.TEST1
Closed Queue QL.DEV.TEST2
Disconnected from QMTEST1
Disconnected from QMTEST2
----------- Start Date/Time = Mon Feb 1 09:35:22 2016
----------- End Date/Time = Mon Feb 1 09:35:22 2016
------------------- Run Time = 00:00:00
[mqm@mqm3d ~]$
[mqm@mqm3d ~]$ ./mqrc2.sh 2097
2097 (X'0831') MQRC_CONTEXT_HANDLE_ERROR
Explanation:
On an MQPUT or MQPUT1 call, MQPMO_PASS_IDENTITY_CONTEXT or MQPMO_PASS_ALL_CONTEXT was specified, but the handle specified in the Context field of the PutMsgOpts parameter is either not a valid queue handle, or it is a valid queue handle but the queue was not opened with MQOO_SAVE_ALL_CONTEXT.
Completion Code:
MQCC_FAILED
Programmer Response:
Specify MQOO_SAVE_ALL_CONTEXT when the queue referred to is opened.
[mqm@mqm3d ~]$
|
If I remove the context options, the script works:
A - Connects to the 1st remote queue manager
B - Opens a source queue using MQOO_FAIL_IF_QUIESCING | MQOO_INPUT_AS_Q_DEF
C - Connects to the 2nd remote queue manager
D - Opens a target queue using MQOO_FAIL_IF_QUIESCING | | MQOO_OUTPUT
E - GETS a message from the source queue using MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_SYNCPOINT options
F - PUTS a message to the target queue using MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT options.
I still get the same Queue Handle value for both the Source and Target queues (101).
Code: |
[mqm@mqm3d ~]$ ./Queue2QueueNEW.pl -m1 QMTEST1 -q1 QL.DEV.TEST1 -x1 'NMS.SVRCONN/TCP/mqdev(1418)' -m2 QMTEST2 –q2 QL.DEV.TEST2 -x2 'NMS.SVRCONN/TCP/mqdev(1419)'
----------- Start Date/Time = Mon Feb 1 09:03:09 2016 -----------
Using MQClient::MQSeries Perl Libraries
---------------------------- Move FROM -----------------------------
MQ Queue Manager = QMTEST1
Queue Name = QL.DEV.TEST1
MQSERVER = NMS.SVRCONN/TCP/mqdev(1418)
Channel = NMS.SVRCONN
Transport = TCP
Hostname(port) = mqdev(1418)
---------------------------- TO -------------------------------------
MQ Queue Manager = QMTEST2
Queue Name = QL.DEV.TEST2
MQSERVER = NMS.SVRCONN/TCP/mqdev(1419)
Channel = NMS.SVRCONN
Transport = TCP
Hostname(port) = mqdev(1419)
---------------------------------------------------------------------
Connected to QMTEST1 (HConn1 = 16777222) at mqdev(1418) using channel NMS.SVRCONN
Opened Queue QL.DEV.TEST1 (HobjIP = 101) using MQOO_FAIL_IF_QUIESCING | MQOO_INPUT_AS_Q_DEF
---------------------------------------------------------------------
Connected to QMTEST2 (HConn2 = 16777224) at mqdev(1419) using channel NMS.SVRCONN
Opened Queue QL.DEV.TEST2 (HobjOP = 101) using MQOO_FAIL_IF_QUIESCING | MQOO_OUTPUT
---------------------------------------------------------------------
MQGET Successful using Options MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_SYNCPOINT
Attempting MQPUT using Options MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT
>>>>> Message 1 was moved from QL.DEV.TEST1 in QM.aewappqa.01 to QL.DEV.TEST2 in QM.fixclqa.01 >>>>>
MQGET Successful using Options MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_SYNCPOINT
Attempting MQPUT using Options MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT
>>>>> Message 2 was moved from QL.DEV.TEST1 in QM.aewappqa.01 to QL.DEV.TEST2 in QM.fixclqa.01 >>>>>
MQGET Successful using Options MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_SYNCPOINT
Attempting MQPUT using Options MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT
>>>>> Message 3 was moved from QL.DEV.TEST1 in QMTEST1 to QL.DEV.TEST2 in QMTEST2 >>>>>
>>>>> There are no more messages on the queue. Total Messages moved - 3
Closed Queue QL.DEV.TEST1
Closed Queue QL.DEV.TEST2
Disconnected from QMTEST1
Disconnected from QMTEST2
----------- Start Date/Time = Mon Feb 1 09:03:09 2016
----------- End Date/Time = Mon Feb 1 09:03:09 2016
------------------- Run Time = 00:00:00
[mqm@mqm3d ~]$
[mqm@mqm3d ~]$
[mqm@mqm3d ~]$
[mqm@mqm3d ~]$
|
Any ideas? _________________ Yeah, well, you know, that's just, like, your opinion, man. - The Dude |
|
Back to top |
|
|
mqjeff |
Posted: Mon Feb 01, 2016 7:25 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
... does it change the behavior if you connect to both queue managers before opening the queues? _________________ chmod -R ugo-wx / |
|
Back to top |
|
|
bruce2359 |
Posted: Mon Feb 01, 2016 8:13 am Post subject: |
|
|
Poobah
Joined: 05 Jan 2008 Posts: 9442 Location: US: west coast, almost. Otherwise, enroute.
|
You didn't include your code for the MQCONN, MQOPEN, MQGET, MQPUT calls, so we can't really do more than guess as to exactly what you coded.
But, two possibilities come to mind.
In your MQPUT call, did you specify HCONN2? Does your code have separate HCONNs for each qmgr?
My second guess is that SAVE_ALL and PASS_ALL need to be within the same qmgr. I've used both, but within the same qmgr.
Does your MQGET call specify MQGMO_BROWSE?
Quote: |
A message retrieved using one of the MQGMO_BROWSE_* browse options does not have its context information saved ... |
http://www-01.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.ref.dev.doc/q101870_.htm
http://www-01.ibm.com/support/knowledgecenter/SSFKSJ_7.0.1/com.ibm.mq.csqsao.doc/fm12910_1.htm _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Last edited by bruce2359 on Mon Feb 01, 2016 8:21 am; edited 1 time in total |
|
Back to top |
|
|
mqjeff |
Posted: Mon Feb 01, 2016 8:18 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You may also need to put the two connections in separate threads. _________________ chmod -R ugo-wx / |
|
Back to top |
|
|
LouML |
Posted: Tue Feb 02, 2016 1:57 am Post subject: |
|
|
Partisan
Joined: 10 Nov 2005 Posts: 305 Location: Jersey City, NJ / Bethpage, NY
|
mqjeff wrote: |
... does it change the behavior if you connect to both queue managers before opening the queues? |
mqjeff wrote: |
You may also need to put the two connections in separate threads. |
The same code works when I Get/Put between two queues in the same queue manager (using the same HConn). _________________ Yeah, well, you know, that's just, like, your opinion, man. - The Dude |
|
Back to top |
|
|
LouML |
Posted: Tue Feb 02, 2016 2:10 am Post subject: |
|
|
Partisan
Joined: 10 Nov 2005 Posts: 305 Location: Jersey City, NJ / Bethpage, NY
|
Yes, I have a separate HConn for each QMgr.
No, I am not using Browse. I'm aware of this. My code will be able to do a COPY (using browse but no context saving) or a MOVE (not using browse but saving context).
Here are my MQ calls:
Code: |
$coption = { 'ChannelName' => $Chan1,
'TransportType' => $Tran1,
'ConnectionName' => $Host1,
};
$HConn1 = MQCONNX($QM1, { 'ClientConn' => $coption, , }, $CompCode, $Reason);
if ($CompCode != 0){
print "ERROR: Problem Connecting to Queue Manager $QM1 $Reason: ", MQReasonToText($Reason), "\n";
exit(0);
} else {
print "Connected to $QM1 (HConn1 = $HConn1) at $Host1 using channel $Chan1\n";
# $OpenOptionsIP = MQOO_FAIL_IF_QUIESCING | MQOO_SAVE_ALL_CONTEXT | MQOO_INPUT_AS_Q_DEF | MQOO_BROWSE;
$OpenOptionsIP = MQOO_FAIL_IF_QUIESCING | MQOO_SAVE_ALL_CONTEXT | MQOO_INPUT_AS_Q_DEF;
$ObjDescIP = {
ObjectName => $QName1,
};
$HobjIP = MQOPEN($HConn2, $ObjDescIP, $OpenOptionsIP, $CompCode, $Reason);
if ($CompCode != 0){
print "ERROR: Problem Connecting to Queue: ,$ObjDescIP->{ObjectName}, $Reason: ", MQReasonToText($Reason), "\n";
exit(0);
} else {
# print "Opened Queue $QName1 (HobjIP = $HobjIP)\tusing MQOO_FAIL_IF_QUIESCING | MQOO_SAVE_ALL_CONTEXT | MQOO_INPUT_AS_Q_DEF | MQOO_BROWSE\n";
print "Opened Queue $QName1 (HobjIP = $HobjIP)\tusing MQOO_FAIL_IF_QUIESCING | MQOO_SAVE_ALL_CONTEXT | MQOO_INPUT_AS_Q_DEF\n";
}
}
print "---------------------------------------------------------------------\n";
$coption = { 'ChannelName' => $Chan2,
'TransportType' => $Tran2,
'ConnectionName' => $Host2,
};
$HConn2 = MQCONNX($QM2, { 'ClientConn' => $coption, , }, $CompCode, $Reason);
if ($CompCode != 0){
print "ERROR: Problem Connecting to Queue Manager $QM2 $Reason: ", MQReasonToText($Reason), "\n";
exit(0);
} else {
print "Connected to $QM2 (HConn2 = $HConn2) at $Host2 using channel $Chan2\n";
$OpenOptionsOP = MQOO_FAIL_IF_QUIESCING | MQOO_PASS_ALL_CONTEXT | MQOO_OUTPUT;
# $OpenOptionsOP = MQOO_FAIL_IF_QUIESCING | MQOO_OUTPUT;
$ObjDescOP = {
ObjectName => $QName2,
};
$HobjOP = MQOPEN($HConn2, $ObjDescOP, $OpenOptionsOP, $CompCode, $Reason);
if ($CompCode != 0){
print "ERROR: Problem Connecting to Queue: ,$ObjDescOP->{ObjectName}, $Reason: ", MQReasonToText($Reason), "\n";
exit(0);
} else {
print "Opened Queue $QName2 (HobjOP = $HobjOP)\tusing MQOO_FAIL_IF_QUIESCING | MQOO_PASS_ALL_CONTEXT | MQOO_OUTPUT\n";
# print "Opened Queue $QName2 (HobjOP = $HobjOP)\tusing MQOO_FAIL_IF_QUIESCING | MQOO_OUTPUT\n";
}
}
}
my $GetMsgDesc = {};
# $GetMsgOpt = MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_SYNCPOINT | MQGMO_BROWSE_NEXT;
$GetMsgOpt = MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_SYNCPOINT;
my $GetMsgOpts = {
Options => $GetMsgOpt,
WaitInterval => -1, ## in milliseconds. 10,000 is 10 seconds, etc.
};
my $BufferLength = 4096000; ## 4k input buffer. Change as necessary.
$Buffer = MQGET($HConn1, $HobjIP, $GetMsgDesc, $GetMsgOpts, $BufferLength, $CompCode, $Reason);
if ($CompCode != 0){
if ( $Reason != 2033 ) {
print "MQGET ERROR: MQGET was unsuccessful: $Reason ", MQReasonToText($Reason), "\n";
} else {
print ">>>>> There are no more messages on the queue. Total Messages $Mode2 - $MsgCnt\n";
}
} else { # Start of code to PUT messages to QName2 in QM2
# print "MQGET Successful using Options MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_SYNCPOINT | MQGMO_BROWSE_NEXT\n";
print "MQGET Successful using Options MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_SYNCPOINT\n";
my $PutMsgDesc = {persistence => MQPER_PERSISTENT};
$PutMsgOpt = MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT | MQPMO_PASS_ALL_CONTEXT;
# $PutMsgOpt = MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT;
my $PutMsgOpts = {
Options => $PutMsgOpt,
Context => $HobjIP,
# Context => $ObjDescIP->{ObjectName},
};
print "Attempting MQPUT using Options MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT | MQPMO_PASS_ALL_CONTEXT\n";
# print "Attempting MQPUT using Options MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT\n";
my $Resp = MQPUT($HConn2, $HobjOP, $PutMsgDesc, $PutMsgOpts, $Buffer, $CompCode, $Reason);
if ($CompCode != 0){
print "MQPUT ERROR: Problem Putting to Queue: $ObjDescIP->{ObjectName}, $Reason: ", MQReasonToText($Reason), "\n";
MQBACK($HConn1, $CompCode, $Reason);
if ($CompCode != 0){
print LOGFILE "MQBACK ERROR: MQBACK failed: $Reason: ", MQReasonToText($Reason), "\n";
}
$CompCode = 99;
} else {
MQCMIT($HConn1, $CompCode, $Reason);
if ($CompCode != 0){
print LOGFILE "MQCMIT ERROR: MQCMIT failed: $Reason: ", MQReasonToText($Reason), "\n";
}
$CompCode = 0;
$MsgCnt++;
$| = 1;
print ">>>>> Message $MsgCnt was $Mode2 from $QName1 in $QM1 to $QName2 in $QM2 >>>>>\n";
print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n$Buffer\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" if $debug;
}
}
|
The commented out options are for when I switch between COPY mode and MOVE mode.
As for my issue with the HObj number being the same, I guess it's specific to each HConn. When I shared the HConn, the HObj's were 101 and 102. When I used a different HConn, each HObj was 101. _________________ Yeah, well, you know, that's just, like, your opinion, man. - The Dude |
|
Back to top |
|
|
zpat |
Posted: Tue Feb 02, 2016 2:17 am Post subject: |
|
|
Jedi Council
Joined: 19 May 2001 Posts: 5856 Location: UK
|
I assume you are doing this for educational reasons?
Otherwise there are ready to use options such as the q or qload program (which are now part of the IBM product under other names).
The PERL MQ interface is not officially IBM supported of course. If it stops working on a later version, you are on your own. _________________ 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 |
|
|
PaulClarke |
Posted: Tue Feb 02, 2016 2:24 am Post subject: |
|
|
Grand Master
Joined: 17 Nov 2005 Posts: 1002 Location: New Zealand
|
I don't understand how you would expect MQOO_SAVE_ALL_CONTEXT to work if you are putting the message to a different Queue Manager.
The only way I can see something like this working is to use MQOO_SET_ALL_CONTEXT which, of course, requires a fair amount of authority.
If memory serves Q allows you to do this using two different connections over client connections already.
Regards,
Paul. _________________ Paul Clarke
MQGem Software
www.mqgem.com |
|
Back to top |
|
|
LouML |
Posted: Tue Feb 02, 2016 2:36 am Post subject: |
|
|
Partisan
Joined: 10 Nov 2005 Posts: 305 Location: Jersey City, NJ / Bethpage, NY
|
PaulClarke wrote: |
I don't understand how you would expect MQOO_SAVE_ALL_CONTEXT to work if you are putting the message to a different Queue Manager.
The only way I can see something like this working is to use MQOO_SET_ALL_CONTEXT which, of course, requires a fair amount of authority.
If memory serves Q allows you to do this using two different connections over client connections already.
Regards,
Paul. |
zpat wrote: |
I assume you are doing this for educational reasons?
Otherwise there are ready to use options such as the q or qload program (which are now part of the IBM product under other names).
The PERL MQ interface is not officially IBM supported of course. If it stops working on a later version, you are on your own. |
Thank you both for the prompt replies.
I'm doing this because we lost a production data center a few weeks ago. We switched to DR. When Prod came back up, there were messages on DR that needed to be sent to the queues in Prod (we can discuss our DR failures at another time).
I need a way to offload messages from one queue manager to another
As I stated in my original post, I know there are existing options out there but I haven't been able to get any of them to connect to two remote queue managers and retain context.
I may have missed it but I haven't found a way to use q in client mode connecting to two different queue managers. I'm sure I'm missing something. Perhaps you could point me in the right direction:
Code: |
[mqm@mqm3d Linux Intel 64]$ ./q
MQSeries Q Program by Paul Clarke [ V5.0.0 Build:Jul 17 2008 ]
(c) Copyright IBM Corp. 1995, 2008
Usage: Q <Optional flags as below>
[-a[dnpqcRrstfFaAcD] Message attributes
p:Persistent,n:Non-Persisent,q:Persistence as Q,s:Allow Segmentation
c:complete message,d:Datagram,R:Request,r:Reply,t:Report
f:Async put, F:no async put
a:Read Ahead, A:No Read Ahead
C:Close Quiesce, D:Close Delete
2:Force message properties as MQRFH2s
[-A[i|o|a]<value> Application Identity|Origin Data|Acct Token
(c) [-b Browse input Q (DEP:use i rather than I]
[-cCCSid[:X'Encoding'] Convert]
[-C[a][i][A][I] Context]
a: pass all context i: pass identity context
A: set all context I: set identity context
n: no context
(c) [-d[h][f][n][w<width>][1][2][3] Display Detail
h:Print message in hex n:Don't print message
d/D:Print out MQMD o/O:Print out MQOD
More <Press Enter>...
p/P:Print out MQPMO g/G:Print out MQGMO
s/S:Print out MQSD r/R:Print out MQSRO
x:Use XML Shortform X:No XML Auto detect
l:Print message length f:Format recognised messages
1:Low level of detail 2:Medium level of detail
3:High level of detail
[-e Echo to Reply Queue]
[-E Echo to Reply Queue and set Reply QMgr]
[-f Input file] Each line is one message
[-F Load/Unload file] Entire file for one message
[-X Load a file in hex as one message
[-g[p][x][C][m|c|g]identifier Get or Put by identifier
x:ID is in hex p:Put with ID C:Use MQCI New session
m:Message ID c:Correlation ID g:Group ID
[-h Filter string]
[-H Selection string]
(c) [-i Input Queue (browse)]
(c) [-I Input Queue (get)]
[-j Specify format name ] [-k Browse Lock]
[-L Message Limit] Maximum number of messages to process
[-m LocalQueueManager] [-M Simple text message]
More <Press Enter>...
[-n"Confirm options" below :-
[ca|cad|cafd] [cd|cdd|cdfd] [e|ed|efd] [x|xd|xfd]
[pan][nan][newm][passm][copym][disc][passd][act]
(c) {-o Output Queue} Multiple use uses distribution list
{-O Output Queue} Bind on Open version of above
[-p Commit interval] [-P Message Priority]
[-q Quiet....don't write messages to screen
[-r[+] Reply Queue] [-s Force msg output to stdout]
[-$ Queue Separator character]
[-t Print timings
[-U[+] User Identifier [+]: Alternate Userid
[-v[p|P|1|2|3|4|5] Verbose Level
p: Pause, P: Cmd line parms >=1: Message info,>=2: API info]
[-V[z][c] Return value, default MQRC]
z:Force zero return c:MQCC mapped to 0,4,8
(c) [-w Wait for messages (in seconds)]
[-W Sleep before issuing MQGET (in milliseconds)]
[-x[f][s][i][b|n][c][q][N][t][u] Use MQCONNX]
f:Fast binding s:Standard binding i:Isolated
b:Shared Blocking Connection n:Shared Nonblocking Connection
c:Specify channel on MQCONNX
More <Press Enter>...
q:No fail if quiescing N:No MQDISC
t:Specify connection tag on MQCONNX
u:Specify User ID and Password MQCONNX
[-y Expire time in 1/10th's second
[-z Zero out MsgId before MQPUT
[-Z TimeZone (hours) Put Date/Time
[-1 Use MQPUT1 rather than MQPUT
[-# Structure versions] eg. #m1p2g2o1x4 or #c for current
[-* Repeat execution]
[-=[n] Set Max Msg Length - 'n' will not truncate]
[-! Do not use exithandler]
[-S[o:TopicObject] Subscribe to Topic Object
[ [s:TopicString] Subscribe to Topic String
[ [n:SubName] Subscription Name
[ [u:SubUserData] Subscription User Data
[ [l SubLevel] Subscription Level
[ [c][r][a] [d][v][f][g] [N][R] [C][T]
c:Create (def) r:Resume a:Alter subscription
d:Durable
v:Any User f:Fixed User g:Group Sub
N:New pubs only R:Pubs on request
More <Press Enter>...
C:Wildcard Char T:Wildcard Topic
D:Delete durable sub
[-T[o:TopicObject] Publish to Topic Object
[ [s:TopicString] Publish to Topic String
[ [r][p][n]
r:Retain p:Supress ReplyTo
n:Not own Subs
Common options marked with (c)
Examples
--------
Write to a queue : q -oQ1
Write to two queues (Dist list) : q -oQ1 -oQ2
Write to a queue on remote Qmgr : q -oQM2/Q1
Read from a queue : q -IQ1
Browse from a queue : q -iQ1
Show Message Descriptor : q -iQ1 -dd3
Wait for messages : q -IQ1 -w60
Move messages between Queues : q -IQ1 -oQ2
Copy messages between Queues : q -iQ1 -oQ2
More <Press Enter>...
Subscribe to a topic : q -Ss:TopicStr -w60
Make a durable subscription : q -Sds:TopicStr -Sn:MySubName -w60
Publish on a topic : q -Ts:TopicStr
You have new mail in /var/spool/mail/mqm
[mqm@mqm3d Linux Intel 64]$
|
_________________ Yeah, well, you know, that's just, like, your opinion, man. - The Dude |
|
Back to top |
|
|
zpat |
Posted: Tue Feb 02, 2016 4:31 am Post subject: |
|
|
Jedi Council
Joined: 19 May 2001 Posts: 5856 Location: UK
|
I was thinking more of queue to file, then file to queue (two invocations) but if you can do it in one, fine. _________________ 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 |
|
|
fjb_saper |
Posted: Tue Feb 02, 2016 6:06 am Post subject: |
|
|
Grand High Poobah
Joined: 18 Nov 2003 Posts: 20729 Location: LI,NY
|
Also you may not want to use ACCEPT_TRUNC_MSG as this would not guarantee data integrity... _________________ MQ & Broker admin |
|
Back to top |
|
|
PaulClarke |
Posted: Tue Feb 02, 2016 6:44 am Post subject: |
|
|
Grand Master
Joined: 17 Nov 2005 Posts: 1002 Location: New Zealand
|
Yes it is not immediately obvious that queue can do this and it couldn't in the early version. To be honest I am not sure exactly what version allowed it but it was certainly a long time ago. The key is to use the -m parameter twice. Flags after the first -m apply to the first connection. Flags after the second -m apply to the second. So, for example:
Code: |
q -m QM1 -iQ1 -m QM2 -oQ2 -xb |
This command will copy all the messages from Q1 on QM1 to Q2 on QM2. Thhe -xb parameter tells MQ to use shared handles since, by default, MQ doesn't like to have two connection handles open in the same thread.
I hope that helps.
Regards,
Paul. _________________ Paul Clarke
MQGem Software
www.mqgem.com |
|
Back to top |
|
|
mqjeff |
Posted: Tue Feb 02, 2016 6:50 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
LouML wrote: |
mqjeff wrote: |
... does it change the behavior if you connect to both queue managers before opening the queues? |
mqjeff wrote: |
You may also need to put the two connections in separate threads. |
The same code works when I Get/Put between two queues in the same queue manager (using the same HConn). |
Yes. But, again. I'm suggesting two things. One : connect to both qmgrs before opening any queues. Two: Put each queue manager connection in a separate thread. _________________ chmod -R ugo-wx / |
|
Back to top |
|
|
LouML |
Posted: Wed Feb 03, 2016 5:35 am Post subject: |
|
|
Partisan
Joined: 10 Nov 2005 Posts: 305 Location: Jersey City, NJ / Bethpage, NY
|
mqjeff wrote: |
LouML wrote: |
mqjeff wrote: |
... does it change the behavior if you connect to both queue managers before opening the queues? |
mqjeff wrote: |
You may also need to put the two connections in separate threads. |
The same code works when I Get/Put between two queues in the same queue manager (using the same HConn). |
Yes. But, again. I'm suggesting two things. One : connect to both qmgrs before opening any queues. Two: Put each queue manager connection in a separate thread. |
I haven't tried the seperate threads yet. Same issue when doing the MQCONN's first:
Code: |
[mqm@mqm3d ~]$ ./Queue2QueueNEW.pl -m1 QMTEST1 -q1 QL.DEV.TEST2 -x1 'NMS.SVRCONN/TCP/mqdev(1418)' -m2 QMTEST2 -q2 QL.DEV.TEST2 -x2 'NMS.SVRCONN/TCP/mqdev(1419)'
----------- Start Date/Time = Wed Feb 3 06:48:07 2016 -----------
Using MQClient::MQSeries Perl Libraries
---------------------------- Move FROM -----------------------------
MQ Queue Manager = QMTEST1
Queue Name = QL.DEV.TEST2
MQSERVER = NMS.SVRCONN/TCP/mqdev(1418)
Channel = NMS.SVRCONN
Transport = TCP
Hostname(port) = mqdev(1418)
---------------------------- TO -------------------------------------
MQ Queue Manager = QMTEST2
Queue Name = QL.DEV.TEST2
MQSERVER = NMS.SVRCONN/TCP/mqdev(1419)
Channel = NMS.SVRCONN
Transport = TCP
Hostname(port) = mqdev(1419)
---------------------------------------------------------------------
Connected to QMTEST1 (HConn1 = 16777222) at mqdev(1418) using channel NMS.SVRCONN
Connected to QMTEST2 (HConn2 = 16777224) at mqdev(1419) using channel NMS.SVRCONN
---------------------------------------------------------------------
MQOO_FAIL_IF_QUIESCING = 8192
MQOO_INPUT_AS_Q_DEF = 1
MQOO_SAVE_ALL_CONTEXT = 128
OpenOptionsIP = 8321
Opened Queue QL.DEV.TEST2 (HobjIP = 101) using MQOO_FAIL_IF_QUIESCING | MQOO_INPUT_AS_Q_DEF | MQOO_SAVE_ALL_CONTEXT
---------------------------------------------------------------------
MQOO_FAIL_IF_QUIESCING = 8192
MQOO_OUTPUT = 16
MQOO_PASS_ALL_CONTEXT = 512
OpenOptionsOP = 8720
Opened Queue QL.DEV.TEST2 (HobjOP = 101) using MQOO_FAIL_IF_QUIESCING | MQOO_OUTPUT | MQOO_PASS_ALL_CONTEXT
---------------------------------------------------------------------
MQGET Successful using MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG
Attempting MQPUT using MQPMO_FAIL_IF_QUIESCING | MQPMO_PASS_ALL_CONTEXT | MQPMO_SYNCPOINT
MQPUT ERROR: Putting to Queue: QL.DEV.TEST2, 2097: Queue handle referred to does not save context.
MQBACK called
Closed Queue QL.DEV.TEST2
Closed Queue QL.DEV.TEST2
Disconnected from QMTEST1
Disconnected from QMTEST2
----------- Start Date/Time = Wed Feb 3 06:48:07 2016
----------- End Date/Time = Wed Feb 3 06:48:07 2016
------------------- Run Time = 00:00:00
[mqm@mqm3d ~]$ |
When using this code to COPY (using Browse and context options), it works:
Code: |
[mqm@mqm3d ~]$ ./Queue2QueueNEW.pl -m2 QMTEST1 -q2 QL.DEV.TEST2 -x2 'NMS.SVRCONN/TCP/mqdev(1418)' -m1 QMTEST2 -q1 QL.DEV.TEST2 -x1 'NMS.SVRCONN/TCP/mqdev(1419)' -c
----------- Start Date/Time = Wed Feb 3 06:12:22 2016 -----------
Using MQClient::MQSeries Perl Libraries
---------------------------- Copy FROM -----------------------------
MQ Queue Manager = QMTEST2
Queue Name = QL.DEV.TEST2
MQSERVER = NMS.SVRCONN/TCP/mqdev(1419)
Channel = NMS.SVRCONN
Transport = TCP
Hostname(port) = mqdev(1419)
---------------------------- TO -------------------------------------
MQ Queue Manager = QMTEST1
Queue Name = QL.DEV.TEST2
MQSERVER = NMS.SVRCONN/TCP/mqdev(1418)
Channel = NMS.SVRCONN
Transport = TCP
Hostname(port) = mqdev(1418)
---------------------------------------------------------------------
Connected to QMTEST2 (HConn1 = 16777222) at mqdev(1419) using channel NMS.SVRCONN
Connected to QMTEST1 (HConn2 = 16777224) at mqdev(1418) using channel NMS.SVRCONN
---------------------------------------------------------------------
MQOO_FAIL_IF_QUIESCING = 8192
MQOO_INPUT_AS_Q_DEF = 1
MQOO_BROWSE = 8
OpenOptionsIP = 8201
Opened Queue QL.DEV.TEST2 (HobjIP = 101) using MQOO_FAIL_IF_QUIESCING | MQOO_INPUT_AS_Q_DEF | MQOO_BROWSE
---------------------------------------------------------------------
MQOO_FAIL_IF_QUIESCING = 8192
MQOO_OUTPUT = 16
OpenOptionsOP = 8208
Opened Queue QL.DEV.TEST2 (HobjOP = 101) using MQOO_FAIL_IF_QUIESCING | MQOO_OUTPUT
---------------------------------------------------------------------
MQGET Successful using MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_BROWSE_NEXT
Attempting MQPUT using MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT
MQCMIT called
>>>>> Message 1 was copied from QL.DEV.TEST2 in QMTEST2 to QL.DEV.TEST2 in QMTEST1 >>>>>
MQGET Successful using MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_BROWSE_NEXT
Attempting MQPUT using MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT
MQCMIT called
>>>>> Message 2 was copied from QL.DEV.TEST2 in QMTEST2 to QL.DEV.TEST2 in QMTEST1 >>>>>
MQGET Successful using MQGMO_FAIL_IF_QUIESCING | MQGMO_ACCEPT_TRUNCATED_MSG | MQGMO_BROWSE_NEXT
Attempting MQPUT using MQPMO_FAIL_IF_QUIESCING | MQPMO_SYNCPOINT
MQCMIT called
>>>>> Message 3 was copied from QL.DEV.TEST2 in QMTEST2 to QL.DEV.TEST2 in QMTEST1 >>>>>
>>>>> There are no more messages on the queue. Total Messages copied - 3
Closed Queue QL.DEV.TEST2
Closed Queue QL.DEV.TEST2
Disconnected from QMTEST2
Disconnected from QMTEST1
----------- Start Date/Time = Wed Feb 3 06:12:22 2016
----------- End Date/Time = Wed Feb 3 06:12:22 2016
------------------- Run Time = 00:00:00
[mqm@mqm3d ~]$
|
Of course, when I remove the Context options, this works for both a MOVE and a COPY. _________________ Yeah, well, you know, that's just, like, your opinion, man. - The Dude |
|
Back to top |
|
|
mqjeff |
Posted: Wed Feb 03, 2016 5:37 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It's odd that adding the context would alter which mqconn you get. But there at least were some old restrictions on using more than one qmgr connection in a single thread - that you would always get the same handle back. This does match your situation, except for the part about working without context options. _________________ chmod -R ugo-wx / |
|
Back to top |
|
|
|
|
|
Goto page 1, 2 Next |
Page 1 of 2 |
|
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
|
|
|
|