|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Adding your own MQRFH2 header + more |
« View previous topic :: View next topic » |
Author |
Message
|
Rudolf |
Posted: Tue Feb 01, 2005 4:44 am Post subject: Adding your own MQRFH2 header + more |
|
|
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 |
|
 |
jkoconnell |
Posted: Mon Feb 28, 2005 5:04 am Post subject: MQRFH2 using Java for MQI |
|
|
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 |
|
 |
prasannal |
Posted: Wed Mar 02, 2005 10:51 pm Post subject: Adding your own MQRFH2 header + more |
|
|
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 |
|
 |
|
|
 |
|
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
|
|
|
|