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 IBM MQ Support » mirrorq

Post new topic  Reply to topic
 mirrorq « View previous topic :: View next topic » 
Author Message
mq_crazy
PostPosted: Fri Jul 21, 2006 7:27 am    Post subject: mirrorq Reply with quote

Master

Joined: 30 Jun 2004
Posts: 295

I have setup the mirrorq and when the messages arrive in the stageq i see that the messages going into the other two mirror queues are getting truncated. We get big messages around 5-10MB, do i need to do anything in the mirrorq program?? does it truncate?? i thought it just copies the messages exactly the same no matter the size. Please help...

Windows 2003
MQ 5.3 CSD08
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Fri Jul 21, 2006 8:02 am    Post subject: Reply with quote

Jedi Knight

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

Hi,

You are using an unsupported MQ SupportPac. Therefore, what does the code say / do?

Regards,
Roger Lacroix
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
mq_crazy
PostPosted: Fri Jul 21, 2006 8:15 am    Post subject: Reply with quote

Master

Joined: 30 Jun 2004
Posts: 295

Here is the code:

/*****************************************************************************/
/* */
/* (c) Copyright IBM Corp. 2002 All rights reserved. */
/* */
/* This sample program is owned by International Business Machines */
/* Corporation or one of its subsidiaries ("IBM") and is copyrighted */
/* and licensed, not sold. */
/* */
/* You may copy, modify, and distribute this sample program in any */
/* form without payment to IBM, for any purpose including developing, */
/* using, marketing or distributing programs that include or are */
/* derivative works of the sample program. */
/* */
/* The sample program is provided to you on an "AS IS" basis, without */
/* warranty of any kind. IBM HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES, */
/* EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
/* Some jurisdictions do not allow for the exclusion or limitation of */
/* implied warranties, so the above limitations or exclusions may not */
/* apply to you. IBM shall not be liable for any damages you suffer as */
/* a result of using, modifying or distributing the sample program or */
/* its derivatives. */
/* */
/*****************************************************************************/
/* */
/* Program name: mirrorq */
/* */
/* Description: Sample c++ that shows how to move messages from a queue to */
/* two queues under mqi triggering mechanism. The net result */
/* is to mirror the contents or a queue to a copy queue. */
/* */
/* Function: This program is launched by the mqi trigger mechanism. */
/* When triggered, it reads a message from the source queue */
/* and puts the message to a distribution list of two queues */
/* until all messages are removed from the source queue. The */
/* The distribution list is generated from the two queue names */
/* of the userdata field of the trigger process definition. */
/* */
/* This program is run as follows: */
/* */
/* This program is not intended to be started by a user. It */
/* must be started by the trigger process to properly setup */
/* the environment */
/* */
/* Setup: */
/* */
/* See the readme.txt file included with this package for the */
/* complete setup required to initiate this program through */
/* MQSeries triggering. */
/* */
/* Build: */
/* This program has been tested with Microsoft Visual C++ 6.0 */
/* and MQSeries V5.2 CSD4 on Windows/2000. Compile it with: */
/* */
/* cl mirrorq.cpp imqb23vn.lib imqs23vn.lib */
/*****************************************************************************/

#include <iostream.h>
//include file for MQSeries C++ mqi
#include <imqi.hpp>


const int WAITINTERVAL = 5000; // 5 second wait on GETs

int main(int argc, char **argv)
{

if (argc < 2)
{
cerr << "MIRRORQ must be started by trigger process." << endl;
return(99);
}


/******************************************************************/
/* Set the program argument into the trigger message. */
/* Check the struc_id of the trigger message for validity. */
/* NOTE: The system supplied trigger monitor (RUNMQTRM) passes */
/* the MQTMC2 structure so the C++ class ImqTrigger cannot be */
/* used with this sample. ImqTrigger uses the MQTMC structure. */
/* If you write your own trigger monitor using the ImqTrigger */
/* class, modify this sample to also use ImqTrigger. */
/******************************************************************/
MQTMC2 *trig = (MQTMC2*)argv[1];

if (memcmp(trig->StrucId,MQTMC_STRUC_ID,sizeof(MQCHAR4)) != 0)
{
cerr << "Invalid input trigger message provided." << endl;
return(99);
}


/******************************************************************/
/* Get queue manager name from the MQTMC2 structure and connect */
/* to the queue manager. */
/******************************************************************/
ImqString qMgrName (trig->QMgrName);
qMgrName.stripTrailing ();
ImqQueueManager qMgr (qMgrName);

if ( !qMgr.connect () )
{
cerr << "Unable to connect to queue manager "
<< qMgrName
<< ". Reason code "
<< qMgr.reasonCode () << endl;

return(qMgr.reasonCode ());
}


/******************************************************************/
/* Set up distribution list. */
/* The 2 queues to be copied to are expected to be in the */
/* userdata field of the process definition. The queue names are */
/* delimited by a space. For this sample, these queue reside in */
/* the same queue manager as the source queue. */
/******************************************************************/
ImqDistributionList distList;
ImqQueue targetQ1;
ImqQueue targetQ2;

distList.setConnectionReference (qMgr);

targetQ1.setConnectionReference (qMgr);
targetQ2.setConnectionReference (qMgr);

ImqString userDataStr (trig->UserData);
ImqString queue;
ImqBoolean parseError = TRUE;

if ( userDataStr.cutOut (queue) )
{
targetQ1.setName (queue);
targetQ1.setQueueManagerName( (char *)qMgrName );
targetQ1.setDistributionListReference( distList );
if ( userDataStr.cutOut (queue) )
{
targetQ2.setName (queue);
targetQ2.setQueueManagerName( (char *)qMgrName );
targetQ2.setDistributionListReference( distList );
parseError = FALSE;
}
}

if ( parseError )
{
cerr << "Unable to parse target queue." << endl;
cerr << "Check userdata parm in the process definition." << endl;
cerr << "Current userdata: " << userDataStr << endl;
cerr << "Expected userdata: MIRRORQ.BUSINESSQ MIRRORQ.MIRRORQ" << endl;

if ( !qMgr.disconnect () )
{
cerr << "Disconnect failed with reason code " ;
cerr << qMgr.reasonCode () << endl;
}
return(99);
}


/******************************************************************/
/* Open the source queue for input. */
/******************************************************************/
ImqString sourceQName (trig->QName);
sourceQName.stripTrailing ();
ImqQueue sourceQ (sourceQName);
sourceQ.setConnectionReference (qMgr);
sourceQ.setOpenOptions (MQOO_INPUT_SHARED
+ MQOO_SAVE_ALL_CONTEXT
+ MQOO_FAIL_IF_QUIESCING);
sourceQ.open ();

if ( sourceQ.reasonCode () || sourceQ.completionCode( ) == MQCC_FAILED )
{
cerr << "Unable to open queue "
<< sourceQName
<< ". Completion code "
<< sourceQ.completionCode ()
<< ". Reason code "
<< sourceQ.reasonCode () << endl;
}


/******************************************************************/
/* Setup the distribution list and open the 2 queue in the list. */
/******************************************************************/

distList.setOpenOptions( MQOO_OUTPUT
+ MQOO_PASS_ALL_CONTEXT
+ MQOO_FAIL_IF_QUIESCING );
distList.open ();

if ( distList.reasonCode () || distList.completionCode( ) == MQCC_FAILED )
{
cerr << "Unable to open distribution list "
<< ". Completion code "
<< distList.completionCode ()
<< ". Reason code "
<< distList.reasonCode () << endl
<< targetQ1.name () << " Reason code "
<< targetQ1.reasonCode () << endl
<< targetQ2.name () << " Reason code "
<< targetQ2.reasonCode () << endl;

if ( !qMgr.disconnect () )
{
cerr << "Disconnect failed with reason code "
<< qMgr.reasonCode () << endl;
}
return(99);
}


/******************************************************************/
/* Get messages from the source queue and copy to the 2 target */
/* queues until there are no more messages on the queue. */
/******************************************************************/

ImqMessage message;
ImqGetMessageOptions gmo;

// let the system manage the buffer size
message.useEmptyBuffer (0, 0);

gmo.setOptions (MQGMO_WAIT | MQGMO_FAIL_IF_QUIESCING );
gmo.setWaitInterval (WAITINTERVAL);

while ( sourceQ.completionCode( ) != MQCC_FAILED )
{

/*******************************************************/
/* The message ID and correlation ID must be preserved */
/* from the source queue and moved with the message */
/* to the target queues. */
/* The message context is also inherited from the */
/* original message */
/*******************************************************/
message.setMessageId ();
message.setCorrelationId ();

if ( sourceQ.get (message, gmo) )
{
ImqPutMessageOptions pmo;
pmo.setOptions (MQPMO_PASS_ALL_CONTEXT);
pmo.setContextReference (sourceQ);

// Put the message using the original
// message's context
if ( !distList.put (message, pmo) )
{
cerr << "Put message failed with reason code "
<< distList.reasonCode ();
}
}
else
{
if ( sourceQ.reasonCode( ) == MQRC_NO_MSG_AVAILABLE )
{
cout << "no more messages to move" << endl;
}
else
{
cerr << "Get message failed with reason code "
<< sourceQ.reasonCode () << endl;
}
}

} // end while


/******************************************************************/
/* Cleanup the open resources. */
/******************************************************************/

if ( !sourceQ.close () )
{
cerr << "Close queue failed with reason code "
<< sourceQ.reasonCode () << endl;

}

if ( !distList.close () )
{
cerr << "Close distribution list failed with reason code "
<< distList.reasonCode () << endl;

}

if (! qMgr.disconnect () )
{
cerr << "Disconnect failed with reason code "
<< qMgr.reasonCode () << endl;
}

return(0);
}
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Fri Jul 21, 2006 8:23 am    Post subject: Reply with quote

Jedi Knight

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

RogerLacroix wrote:
You are using an unsupported MQ SupportPac. Therefore, what does the code say / do?


mq_crazy wrote:
Here is the code:


That was a rhetorical question. If I wanted to review the code then I would have download it. I want you to review it and think about what it does.

Regards,
Roger Lacroix
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
mq_crazy
PostPosted: Fri Jul 21, 2006 8:51 am    Post subject: Reply with quote

Master

Joined: 30 Jun 2004
Posts: 295

Maybe the mirroq works fine. I am trying to wonder since the messages that got truncated came in from the dead letter queue would the dead letter handler has truncated them while putting them on the staging queue?? As i chose header(No) while running the dead letter handler.
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 IBM MQ Support » mirrorq
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.