Author |
Message
|
syed javid |
Posted: Sat Mar 20, 2004 11:12 pm Post subject: Reading message in bulk and sending a message in transaction |
|
|
Newbie
Joined: 20 Mar 2004 Posts: 4
|
hi all,
i am new to this tech and also to you
i started with sending and reading messages to mq series using c#.
i have two things to do
- to read messages from mq series in bulk
- to send a message in transaction to mq series
help needed
thanks |
|
Back to top |
|
 |
bower5932 |
Posted: Sun Mar 21, 2004 5:41 pm Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
I'm not sure what reading in bulk means. If you'll search on syncpoint, you'll find some information on sending messages as part of a transaction. You can also look for mqsync.* at http://www.developer.ibm.com/tech/sampmq.html |
|
Back to top |
|
 |
syed javid |
Posted: Mon Mar 22, 2004 6:41 am Post subject: |
|
|
Newbie
Joined: 20 Mar 2004 Posts: 4
|
hi,
i have this code to send a message to MQ in Transaction
but this is not working can you look at it , it is in C#
thanks.
MQQueueManager ObjMQQM = null;
MQQueue ObjQueue = null;
MQMessage ObjMQMsg = null;
MQPutMessageOptions ObjPutMsgOpts = null;
string strQueueManger = "";
string strChannel = "";
string strMQServer = "";
string strQueue_IN = "";
string strMutamerXML = "Message";
try
{
GetConfigurationValue("MQQueue_IN",ref strQueue_IN);
GetConfigurationValue("MQQueueManager",ref strQueueManger);
GetConfigurationValue("MQChannel",ref strChannel);
GetConfigurationValue("MQServer",ref strMQServer);
//Define the QM and Channel
ObjMQQM = new MQQueueManager(strQueueManger,strChannel,strMQServer);
for(int i=0; i<10; i++)
{
ObjMQQM.Begin();
//Open the Queue
ObjQueue = ObjMQQM.AccessQueue( strQueue_IN, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);
//Read the msg and put the msg in the Q
ObjMQMsg = new MQMessage();
ObjMQMsg.CharacterSet = 1200;
ObjMQMsg.Encoding = 785;
ObjMQMsg.WriteString(strMutamerXML);
//Define the Format of the msg and message type.
ObjMQMsg.Format = MQC.MQFMT_STRING;
//ObjMQMsg.MessageType = MQC.MQMT_REQUEST;
ObjMQMsg.Expiry = 1000;
ObjPutMsgOpts = new MQPutMessageOptions();
ObjPutMsgOpts.Options = MQC.MQPMO_SYNCPOINT;
ObjQueue.Put( ObjMQMsg, ObjPutMsgOpts );
ObjMQQM.Commit();
if (i == 5)
{
throw new Exception("Go Out");
}
}
}
catch (Exception mqe)
{
ObjMQQM.Backout();
Response.Write(mqe);
}
finally
{
ObjQueue.Close();
ObjMQQM.Disconnect();
} |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Mar 22, 2004 6:50 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
syed javid wrote: |
this is not working |
How do you know it isn't working? What error is it giving you? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
syed javid |
Posted: Mon Mar 22, 2004 8:06 am Post subject: |
|
|
Newbie
Joined: 20 Mar 2004 Posts: 4
|
no error , it is just not removing the messages from MQ series Q |
|
Back to top |
|
 |
vennela |
Posted: Mon Mar 22, 2004 9:02 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
That's because you are committing after putting every message. As soon as you PUT a message you are committing.
Change your program this way:
Code: |
for(int i=0; i<10; i++)
{
ObjMQQM.Begin();
//Open the Queue
ObjQueue = ObjMQQM.AccessQueue( strQueue_IN, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);
//Read the msg and put the msg in the Q
ObjMQMsg = new MQMessage();
ObjMQMsg.CharacterSet = 1200;
ObjMQMsg.Encoding = 785;
ObjMQMsg.WriteString(strMutamerXML);
//Define the Format of the msg and message type.
ObjMQMsg.Format = MQC.MQFMT_STRING;
//ObjMQMsg.MessageType = MQC.MQMT_REQUEST;
ObjMQMsg.Expiry = 1000;
ObjPutMsgOpts = new MQPutMessageOptions();
ObjPutMsgOpts.Options = MQC.MQPMO_SYNCPOINT;
ObjQueue.Put( ObjMQMsg, ObjPutMsgOpts );
if (i == 5)
{
throw new Exception("Go Out");
}
}
ObjMQQM.Commit();
}
catch (Exception mqe)
{
ObjMQQM.Backout();
Response.Write(mqe);
}
finally
{
ObjQueue.Close();
ObjMQQM.Disconnect();
} |
|
|
Back to top |
|
 |
gunter |
Posted: Mon Mar 22, 2004 9:09 am Post subject: |
|
|
Partisan
Joined: 21 Jan 2004 Posts: 307 Location: Germany, Frankfurt
|
It can't remove messages, it's only put. _________________ Gunter Jeschawitz
IBM Certified System Administrator - Websphere MQ, 5.3 |
|
Back to top |
|
 |
vennela |
Posted: Mon Mar 22, 2004 9:35 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
From what I understood:
He is PUTting messages under syncpoint. He PUTs 5 messages and inducing an exception after that. At this point he is trying to rollback the 5 messages he PUT ( and that is what he is calling not removing the messages from MQ series Q). |
|
Back to top |
|
 |
gunter |
Posted: Mon Mar 22, 2004 11:06 am Post subject: |
|
|
Partisan
Joined: 21 Jan 2004 Posts: 307 Location: Germany, Frankfurt
|
Sorry, I misunderstand the problem.
He should put ObjMQQM.Begin(); befor and ObjMQQM.Commit(); behind the loop. _________________ Gunter Jeschawitz
IBM Certified System Administrator - Websphere MQ, 5.3 |
|
Back to top |
|
 |
EddieA |
Posted: Mon Mar 22, 2004 11:33 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
This is only needed if you are co-ordinating external resources. If you aren't, then this give a Warning return in the 'normal' MQ API. Don't know about Java though.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
syed javid |
Posted: Tue Mar 23, 2004 4:05 am Post subject: |
|
|
Newbie
Joined: 20 Mar 2004 Posts: 4
|
thanks guys, the BackOut is working.
the other thing is how to read a bunch of messages from MQ series Q.
thank once again.
syed javid |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Mar 23, 2004 4:30 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
syed javid wrote: |
the other thing is how to read a bunch of messages from MQ series Q. |
One at a time, with a Get. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|