Few days ago Andreas described how to build interop between JMS and .NET applications based on XMS (IBM Message Service Client for .NET). In this post I will describe how to receive and decode a JMS message.
The example, which Andreas has posted, shows how to connect to messaging subsystem and how to receive the message. Following code snippet extends that example and shows how to read and decode the data from the message:
// Receives the binary message. IMessage recvMsg = consumer.Receive();
// Casts to type able to read binary data. IBytesMessage bMsg = recvMsg as IBytesMessage;
// Creates the buffer. byte[] buff = new byte[bMsg.BodyLength];
// Reads the data int n = bMsg.ReadBytes(buff, (int)bMsg.BodyLength);
// Decodes the data from UTF8 string message = Encoding.UTF8.GetString(buff);
Console.WriteLine(recvMsg); |
Posted
Apr 21 2007, 07:01 PM
by
Damir Dobric