|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Unable to post data to MQ Queue |
« View previous topic :: View next topic » |
Author |
Message
|
msvpraveen |
Posted: Tue Jul 19, 2005 7:51 am Post subject: Unable to post data to MQ Queue |
|
|
Novice
Joined: 07 Jul 2005 Posts: 12
|
I have a C++ program in which I am trying to get some data from a request queue and post the acknowledgement to a reply queue.I am able to get the data from the request queue.Though I am not getting any errors when I try to put the data in reply queue.No data is getting posted to the reply queue.
I have pasted the part of code where I am trying to post the data to reply queue. I tried with mesg.write as well as mesg.writeItem
Code: |
out_queue.setConnectionReference(mgr);
out_queue.setOpenOptions(MQOO_OUTPUT + MQOO_INQUIRE + MQOO_FAIL_IF_QUIESCING);
if( !out_queue.open()) {
cout<<"ImqQueue::open failed with reason code "
<<(long)out_queue.reasonCode( )<<endl;
log_fileout<<"ImqQueue::open failed with reason code "
<<(long)out_queue.reasonCode( )<<endl;
//Failure Occured
flag_success = 0;
}
/* Preparing the Acknowledgement */
mesg_data_buffer = new char[8];
msg.useEmptyBuffer(mesg_data_buffer,sizeof(mesg_data_buffer));
msg.setFormat(MQFMT_STRING);
//Add our acknowledgement string to the message.
ImqString successFlag("SUCCESS");
ImqString failureFlag("FAILURE");
if(flag_success)
{
strcpy(mesg_data_buffer,"SUCCESS");
writeItemFlag = msg.writeItem(successFlag);
}
else
{
strcpy(mesg_data_buffer,"FAILURE");
writeItemFlag = msg.writeItem(failureFlag);
}
cout<<"Posting data: "<<mesg_data_buffer<<endl;
log_fileout<<"Posting data: "<<mesg_data_buffer<<endl;
writeFlag = msg.write(8,mesg_data_buffer);
cout<<"Write Flag"<<writeFlag<<endl;
log_fileout<<"Write Flag"<<writeFlag<<endl;
cout<<"Write Item Flag"<<writeItemFlag<<endl;
log_fileout<<"Write Item Flag"<<writeItemFlag<<endl;
//msg.write(ourstr.length(), ourstr.c_str());
/*
msg.messageId().copyOut(msgId, MQ_MSG_ID_LENGTH, 0);
msg.setMessageId(msg.correlationId());
msg.setCorrelationId(msgId);
*/
// Sending the message to the reply queue.
if( !out_queue.put(msg, pmo) )
{
cout<<"ImqQueue::put failed with reason code "
<<(long)out_queue.reasonCode( )<<endl;
log_fileout<<"ImqQueue::put failed with reason code "
<<(long)out_queue.reasonCode( )<<endl;
}
cout<<"Posted the message...."<<endl;
log_fileout<<"Posted the message..."<<endl;
}
}
|
|
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jul 19, 2005 8:04 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Do you see any messages when using something like amqsbcg?
That is, are there new but blank messages, or are there no new messages? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
msvpraveen |
Posted: Tue Jul 19, 2005 1:37 pm Post subject: |
|
|
Novice
Joined: 07 Jul 2005 Posts: 12
|
No,there are no new messages in reply queue.
In the API it was specified that write and writeItem will return TRUE if
we are able to write to queue.I am not getting any return values for write or writeItem in my code. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jul 19, 2005 1:47 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
msvpraveen wrote: |
No,there are no new messages in reply queue.
In the API it was specified that write and writeItem will return TRUE if
we are able to write to queue.I am not getting any return values for write or writeItem in my code. |
write doesn't write to the queue. It writes to the message buffer.
put writes to the queue.
Make sure you stop the requesting application, so that it's not actually reading anything from the reply queue - or at least for testing purposes, comment out the code that is supposed to get the reply.
Then, clear the reply queue so that it is empty. Confirm that the qdepth is 0.
Then test your replying program, send it a request.
Confirm that the queue depth on the reply queue is still zero. Do this before you close the replying application.
You may be putting your replies in syncpoint, and not committing them. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
msvpraveen |
Posted: Wed Jul 20, 2005 10:01 am Post subject: |
|
|
Novice
Joined: 07 Jul 2005 Posts: 12
|
Quote: |
Make sure you stop the requesting application, so that it's not actually reading anything from the reply queue - or at least for testing purposes, comment out the code that is supposed to get the reply.
|
My get method is not reading from the same queue.Anyway I have commented out that code for testing now.
Quote: |
Then, clear the reply queue so that it is empty. Confirm that the qdepth is 0.
|
How can I check that my qdepth is 0 ?
Quote: |
You may be putting your replies in syncpoint, and not committing them.
|
Can you please elaborate on this.
[/quote] |
|
Back to top |
|
 |
bower5932 |
Posted: Wed Jul 20, 2005 10:44 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
You can use runmqsc to check your current depth. From a command prompt,
runmqsc "your.qmgr.name"
dis ql(YOUR.Q.NAME) curdepth
It will display the current depth of the queue. You could also run the amqsbcg sample against the queue to see if it finds all of these messages.
If you are putting your replies in syncpoint (ie, a unit of work), then you have to let the qmgr that you actually want them committed (mqcmit) in order for them to show up. Go look at the mqsync.* samples at:
http://www.developer.ibm.com/isv/tech/sampmq.html |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|