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 » Adding your own MQRFH2 header + more

Post new topic  Reply to topic
 Adding your own MQRFH2 header + more « View previous topic :: View next topic » 
Author Message
Rudolf
PostPosted: Tue Feb 01, 2005 4:44 am    Post subject: Adding your own MQRFH2 header + more Reply with quote

Newbie

Joined: 24 Nov 2004
Posts: 7
Location: Netherlands

I have seen a lot of questions about how to add a MQRFH2 header using Java for MQI. You can of course have a look at the C examples or use DataOutputStream, but I have used Javolution (have a look at http://javolution.org/).

One of the things you can do is use class Struct as your base class and derive a struct like class from this base class, so e.g. for MQRFH2 this would be

public class MQRFH2 extends Struct {

public MQRFH2(ByteBuffer bb) {
setByteBuffer(bb, 0);
}

public Utf8String StructId = new Utf8String(4); /*
* Character set identifier of
* NameValueData
*/

public int Version; /* Structure version number */

public int StrucLength; /*
* 36 for fixed + some variable part */

public int Encoding; /*
* Numeric encoding of data that follows NameValueString
*/

public int CodedCharSetId; /*
* Character set identifier of data that follows
* NameValueString
*/

public Utf8String Format = new Utf8String(; /*
* Format name of data that follows
* NameValueString
*/

public int Flags; /* Flags */

public int NameValueCCSID; /*
* Character set identifier of NameValueData
*/
}

In the constructor you pass a byte array that is wrapped by ByteBuffer (java.nio package). Now you can assign values to the class and the byte buffer will be automagically filled... this exactly matches the C struct and you can write out this byte array to an MQMessage.


Kind regards,
Rudolf de Grijs
Back to top
View user's profile Send private message
jkoconnell
PostPosted: Mon Feb 28, 2005 5:04 am    Post subject: MQRFH2 using Java for MQI Reply with quote

Newbie

Joined: 24 Feb 2005
Posts: 8

Rudolf,

Thanks for the tip about javolution struct classes.

I'm having a little trouble populating and putting MQRFH2 using your snippet.
Do you have a more complet code sample that shows populating the MQRFH2 struct, setting the length fields, and putting the message on a queue?

Kind Regards,

John O'Connell
Back to top
View user's profile Send private message
prasannal
PostPosted: Wed Mar 02, 2005 10:51 pm    Post subject: Adding your own MQRFH2 header + more Reply with quote

Apprentice

Joined: 04 Aug 2003
Posts: 44

Hi John,
You can use IBM MQ JMS API with which it is much easier to create FRH2 header.

Here is a small snippet:
session = connection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
ioQueue = session.createQueue(queueName);
qsender = session.createSender(ioQueue);
TextMessage textMessage = session.createTextMessage();
textMessage.setStringProperty("userdefinedkey", "userdefinedvalue or variable");

Thanks,
Prasanna
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 » Adding your own MQRFH2 header + more
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.