|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Newbie Questions - using Put in Java API |
« View previous topic :: View next topic » |
Author |
Message
|
pilotError |
Posted: Fri Apr 19, 2002 8:37 am Post subject: |
|
|
Newbie
Joined: 18 Apr 2002 Posts: 4
|
Hi,
I'm looking to poll a database and send any records found to an MQ queue. I just started using MQ, and don't really know much about architecting App's under MQ.
My question is when I get the records from the database, should I be creating an MQMessage for each row, or can I do a loop, ie.
MQMessage m = new MQMessage();
while ( (String s = getNextRow()) != null)
{
m.clearMessage();
m.writeBytes(s);
// put it to the queue
}
Thanks,
Mike... |
|
Back to top |
|
 |
i015875 |
Posted: Fri Apr 19, 2002 9:30 am Post subject: |
|
|
Newbie
Joined: 17 Apr 2002 Posts: 2
|
Well, there is an overhead to create a new message : I would rather put many records in the same message. Of course if you have to return a lot of records, creating a monster message of hundreds of Megabytes may not be the best thing to do. The "go between" would be to create reasonnably sized messages : put all the records in the message until you've finished or reach a certain size.
The final answer depends on the context of your applications. |
|
Back to top |
|
 |
AlexeiSkate |
Posted: Fri Apr 19, 2002 9:32 am Post subject: |
|
|
Centurion
Joined: 10 Apr 2002 Posts: 123
|
I'm also new to MQSeries. I wrote a simple put program that placed each record read from an input file onto the queue. My logic was pretty much the same as yours, and it seemed to put stuff onto the queue ok. |
|
Back to top |
|
 |
pilotError |
Posted: Fri Apr 19, 2002 10:49 am Post subject: |
|
|
Newbie
Joined: 18 Apr 2002 Posts: 4
|
Hi,
I wasn't aware that you could put multiple messages into an MQMessage. I thought each writeBytes just appended to the same message. Would I keep calling writeBytes, or is there a call to indicate that this is a seperate message.
Thanks for the quick reply, It's nice to finally find a good forum to ask these questions.
Is there a book or a document that better describes how to use the API's?
Mike... |
|
Back to top |
|
 |
AlexeiSkate |
Posted: Fri Apr 19, 2002 10:59 am Post subject: |
|
|
Centurion
Joined: 10 Apr 2002 Posts: 123
|
I believe that if you do a mqmessage.clearMessage() at the beginning of each loop iteration, it should clear out the existing message, so that you can put another message into it. I'm not sure if you also have to set the messageId and the correlationId to MQC.MQMI_NONE for each iteration so that each physical msg will get its own unique id or if the clearMessage() invokation takes care of that automatically.
You will want to look at the ibm redbook "MQSeries Using Java" (SC34-5456). I wish the book has more than two simple Java examples, but it's better than nothing. This site also contains other MQS redbooks that you might be interested in:
http://www-4.ibm.com/software/ts/mqseries/library/manuals/index.htm
[ This Message was edited by: AlexeiSkate on 2002-04-19 12:08 ] |
|
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
|
|
|
|