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 » How to use message grouping in Java

Post new topic  Reply to topic
 How to use message grouping in Java « View previous topic :: View next topic » 
Author Message
rajesh
PostPosted: Wed Oct 31, 2001 5:03 pm    Post subject: Reply with quote

Newbie

Joined: 30 Oct 2001
Posts: 5

Does anyone have a sample JAVA code that utilizes message grouping. I am having trouble in grouping messages together. I can put the messages on a queue , but the messages do not appear as grouped.

Thanks,
Rajesh.
Back to top
View user's profile Send private message
bduncan
PostPosted: Thu Nov 01, 2001 11:16 am    Post subject: Reply with quote

Padawan

Joined: 11 Apr 2001
Posts: 1554
Location: Silicon Valley

Rajesh,
I'm still trying to dig up some code for you, but in the meanwhile, perhaps you could explain in more detail what the messages look like on the queue. Do a browse on the queue, and then see if all the messages in the group have the same GroupId in their headers. Then check to see if each message in the group has the correct MsgType field. I believe all messages in the group should have MsgType=8, except for the last message in the group which should be MsgType=24... What you may find is that all the messages are type 24, in which case you have a bunch of groups of size 1, or they have different GroupIds which means you have a bunch of incomplete groups (assuming all their MsgTypes = 8 )


_________________
Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator

[ This Message was edited by: bduncan on 2001-11-01 18:00 ]
Back to top
View user's profile Send private message Visit poster's website AIM Address
rajesh
PostPosted: Thu Nov 01, 2001 5:24 pm    Post subject: Reply with quote

Newbie

Joined: 30 Oct 2001
Posts: 5

Brandon,

My code is here. I am not able to set the msgFlags on the message object. Do you know how to set the message flag ?

int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT ;

// Now specify the queue that we wish to open,
// and the open options...
MQQueue obj_local_queue =
obj_qMgr.accessQueue(QueueName,
openOptions,
null, // default qmanager
null, // no dynamic qname
null); // no alternate user id
System.out.println("In MQOpen: Queuename is : " + QMgrName + QueueName );


// Define a simple MQSeries message, and write some text in UTF format..

MQMessage mq_message = new MQMessage();

// specify the message options...

MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults,
// same as MQPMO_DEFAULT

int putOptions = MQC.MQPMO_LOGICAL_ORDER | MQC.MQPMO_SYNCPOINT;// | MQC.MQMF_MSG_IN_GROUP;

//pmo.Version = MQC.MQPMO_VERSION_2;
pmo.options = putOptions;

mq_message.clearMessage();

byte [] group = new byte[3];
group[0] = 6;
group[1] = 7;
group[2] = 7;
//byte [] group = MQC.MQGI_NONE;
//mq_message.version = MQC.MQMD_VERSION_2;

//mq_message.setMsgFlags(MQC.MQMF_MSG_IN_GROUP | MQC.MQMF_LAST_MSG_IN_GROUP ; NOT WORKING
//mq_message.setProperty(MQC.MQMF_MSG_IN_GROUP); NOT WORKING ??
mq_message.messageSequenceNumber = j++;
mq_message.writeUTF(header);
obj_local_queue.put(mq_message,pmo);

Thanks,
Rajesh.
Back to top
View user's profile Send private message
bduncan
PostPosted: Thu Nov 01, 2001 6:26 pm    Post subject: Reply with quote

Padawan

Joined: 11 Apr 2001
Posts: 1554
Location: Silicon Valley

Rajesh,
It looks like you are opening the queue correctly. From your code it looks like you were trying to set the message flags in the Message object. This is the correct thinking, it's just the syntax isn't quite right. If you take the line:
mq_message.setProperty(MQC.MQMF_MSG_IN_GROUP);

you should change it to:
mq_message.messageFlags=MQC.MQMF_MSG_IN_GROUP

The other thing I didn't like about the code was this line:
mq_message.messageSequenceNumber = j++;

Now, I'm not 100% (and anyone else feel free to correct me if I'm wrong) but I believe the queue manager handles this variable for you automatically. In other words, when you do your first PUT and specify that this message belongs to a group (MQC.MQMF_MSG_IN_GROUP) the queue manager automatically creates a new GroupId and sets the sequence number for this message to 1. On any subsequent PUTs where you also specify MQC.MQMF_MSG_IN_GROUP, the queue manager will know that this message is in the same group as the previous message you PUT, and will therefore increase the sequence number by 1 automatically. It will continue to do this for you until you PUT a message and specify MQC.MQMF_LAST_MSG_IN_GROUP. I noticed that this isn't in your code. Make sure that on the last message in the group you do this, or the queue manager will treat it as an incomplete group.
So try removing that line and testing your code again. Put several messages to a queue, and then browse the queue to confirm that the queue manager automatically increased the sequence numbers for you.



_________________
Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator
Back to top
View user's profile Send private message Visit poster's website AIM Address
rajesh
PostPosted: Mon Nov 05, 2001 2:38 pm    Post subject: Reply with quote

Newbie

Joined: 30 Oct 2001
Posts: 5

Thanks brandon, that worked. Now I have another issue while pulling these messages from the Queue on mainframe.
According to MQ-Series Application programming reference , MQGMO_ALL_MSGS_AVAILABLE is not supported on OS/390. So how do I read these grouped messages on mainframe together. Please reply as I am stuck at this point.

Thanks,
Rajesh.

[ This Message was edited by: rajesh on 2001-11-05 14:38 ]
Back to top
View user's profile Send private message
bduncan
PostPosted: Mon Nov 05, 2001 4:55 pm    Post subject: Reply with quote

Padawan

Joined: 11 Apr 2001
Posts: 1554
Location: Silicon Valley

Rajesh,
I wasn't aware that OS/390 didn't support this option, but sure enough, it isn't listed as one of the supported platforms in the Application Programming Reference. If someone knows to the contrary, please chime in... But this doesn't mean you're out of options. Basically there is a way to deal with this, though it isn't as elegant as the MQGMO_ALL_MSGS_AVAILABLE parameter.
This solution assumes that you are setting the MQGMO_LOGICAL_ORDER parameter which is available on OS/390. This guarantees everything in the group will be retrieved in order. Now, what you do is wrap your MQGET command in a loop. The condition to continue looping will be if the MQGET returns a 2033 (no messages available). You can combine this loop with the MQGMO_WAIT parameter to decrease the CPU overhead associated with looping. In other words, once I get the first message in a group, I will keep looping until I get the second message, and so on until the entire group has been retrieved. The loop guarantees that I will keep trying until I get the message I need. Of course, this isn't optimal, because I might be looping for a long time trying to get a message from a group that isn't complete yet, while other complete groups are waiting on the queue. The odds of this scenario isn't very high though, because MQSeries guarantees FIFO, so if you only have one application on the sending side putting groups of messages, they should end up on the transmission queue in order - in other words, you wouldn't expect to see message groups interleaved on the destination queue.


_________________
Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator
Back to top
View user's profile Send private message Visit poster's website AIM Address
EddieA
PostPosted: Tue Nov 06, 2001 6:27 am    Post subject: Reply with quote

Jedi

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

Rajesh,

Another solution, which also is a bit of a kludge, might be to use BROWSE when checking for all the messages and only when you know they are 'all present and correct' do you re-read them with GETs. That way you don't have to handle the case where some of the messages come in quickly, but the final one(s) may be delayed because of a transmission outage.

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
middlewareonline
PostPosted: Tue Nov 06, 2001 9:30 am    Post subject: Reply with quote

Acolyte

Joined: 09 Jul 2001
Posts: 73

Last but not least, the old way of doing is to create your own batch header and trailer. Trailer contains total number of messages that you have put in. Validate this at the other end on OS/390.

MiddlewareOnline.COM

_________________
---------------------------------------------
IBM & SUN (J2EE) Certified Consultants,
http://www.MiddlewareOnline.com
A "SARVAM" Online Portal
http://www.SARVAM.com
---------------------------------------------
Back to top
View user's profile Send private message Visit poster's website
bduncan
PostPosted: Tue Nov 06, 2001 12:45 pm    Post subject: Reply with quote

Padawan

Joined: 11 Apr 2001
Posts: 1554
Location: Silicon Valley

Is this only an issue on older versions of MQSeries on OS/390, i.e., version 2.x, or does version 5.2 for OS/390 suffer from the same problem???


_________________
Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator
Back to top
View user's profile Send private message Visit poster's website AIM Address
middlewareonline
PostPosted: Tue Nov 06, 2001 1:31 pm    Post subject: Reply with quote

Acolyte

Joined: 09 Jul 2001
Posts: 73

My undestanding is that it is NOT a supported feature on OS/390.

MiddlewareOnline.COM
Back to top
View user's profile Send private message Visit poster's website
bduncan
PostPosted: Wed Nov 07, 2001 9:57 am    Post subject: Reply with quote

Padawan

Joined: 11 Apr 2001
Posts: 1554
Location: Silicon Valley

What I don't understand is why did they partially implement it? It's almost like, what good is allowing message grouping if you can't specify half the options when it comes to logical grouping. I wonder if this is some sort of OS or hardware limitation, or the software itself...


_________________
Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator
Back to top
View user's profile Send private message Visit poster's website AIM Address
middlewareonline
PostPosted: Wed Nov 07, 2001 12:23 pm    Post subject: Reply with quote

Acolyte

Joined: 09 Jul 2001
Posts: 73

Definetly has to do with O/S limitation. This is common practice that on different platform IBM does not implement all the features. For example Java Support for Mainframe, also there was no signal type of handling for MQGET() on UNIX flavors, where as it was supported on Mainframe.

MiddlewareOnline.com

_________________
---------------------------------------------
IBM & SUN (J2EE) Certified Consultants,
http://www.MiddlewareOnline.com
A "SARVAM" Online Portal
http://www.SARVAM.com
---------------------------------------------
Back to top
View user's profile Send private message Visit poster's website
ocenteno
PostPosted: Wed Dec 05, 2001 1:51 pm    Post subject: Reply with quote

Newbie

Joined: 04 Dec 2001
Posts: 1

HI,
Im working with message queuing with MQSeries.

I need my Java application to receive a set of groupped messages. I've looked for an example code or a guide for doing this without success.

Exactly, all I need is: having an id of a group of messages, get all of them. An example of how to send a group of messages and receive them will help lots to my proyect.

Could someone give me an advice or some sample code?
Ive seen the above sample but it doesn't show how to send and get all the group messages.

Thanks for any help.
You can email me at: ocenteno@infosgroup.com
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
alcorpe
PostPosted: Tue Jan 22, 2002 10:22 am    Post subject: Reply with quote

Newbie

Joined: 09 Jan 2002
Posts: 2

I need help with grouping messages in mq, specially with the put and get sintaxis.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » How to use message grouping in Java
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.