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 » IBM MQ API Support » Reading message in bulk and sending a message in transaction

Post new topic  Reply to topic
 Reading message in bulk and sending a message in transaction « View previous topic :: View next topic » 
Author Message
syed javid
PostPosted: Sat Mar 20, 2004 11:12 pm    Post subject: Reading message in bulk and sending a message in transaction Reply with quote

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
View user's profile Send private message Send e-mail
bower5932
PostPosted: Sun Mar 21, 2004 5:41 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
syed javid
PostPosted: Mon Mar 22, 2004 6:41 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Mon Mar 22, 2004 6:50 am    Post subject: Reply with quote

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
View user's profile Send private message
syed javid
PostPosted: Mon Mar 22, 2004 8:06 am    Post subject: Reply with quote

Newbie

Joined: 20 Mar 2004
Posts: 4

no error , it is just not removing the messages from MQ series Q
Back to top
View user's profile Send private message Send e-mail
vennela
PostPosted: Mon Mar 22, 2004 9:02 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
gunter
PostPosted: Mon Mar 22, 2004 9:09 am    Post subject: Reply with quote

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
View user's profile Send private message
vennela
PostPosted: Mon Mar 22, 2004 9:35 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
gunter
PostPosted: Mon Mar 22, 2004 11:06 am    Post subject: Reply with quote

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
View user's profile Send private message
EddieA
PostPosted: Mon Mar 22, 2004 11:33 am    Post subject: Reply with quote

Jedi

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

Quote:
ObjMQQM.Begin();

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
View user's profile Send private message
syed javid
PostPosted: Tue Mar 23, 2004 4:05 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Tue Mar 23, 2004 4:30 am    Post subject: Reply with quote

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
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 » IBM MQ API Support » Reading message in bulk and sending a message in transaction
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.