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 Java / JMS » Newbie Questions - using Put in Java API

Post new topic  Reply to topic
 Newbie Questions - using Put in Java API « View previous topic :: View next topic » 
Author Message
pilotError
PostPosted: Fri Apr 19, 2002 8:37 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
i015875
PostPosted: Fri Apr 19, 2002 9:30 am    Post subject: Reply with quote

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
View user's profile Send private message
AlexeiSkate
PostPosted: Fri Apr 19, 2002 9:32 am    Post subject: Reply with quote

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
View user's profile Send private message
pilotError
PostPosted: Fri Apr 19, 2002 10:49 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
AlexeiSkate
PostPosted: Fri Apr 19, 2002 10:59 am    Post subject: Reply with quote

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
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 Java / JMS » Newbie Questions - using Put in Java API
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.