I am trying to send message to ActiveMQ server with my client app written on C# .NET. I have XML messages which I have converted into Zip stream and trying to send.
public IMessage SendMessage(string mqUri, string brokerUri, MemoryStream message, string username, string password)
{
Uri connecturi = new Uri(mqUri);
IConnectionFactory factory = new NMSConnectionFactory(connecturi);
using (IConnection connection = factory.CreateConnection(username, password))
using (ISession session = connection.CreateSession())
{
IDestination destination = SessionUtil.GetDestination(session, brokerUri);
using (IMessageProducer producer = session.CreateProducer(destination))
{
connection.Start();
IBytesMessage request = session.CreateBytesMessage(message.ToArray());
producer.Send(request);
return request;
}
}
}
On server side when parsing data got exception like:
Execution of JMS message listener failed. Caused by: [org.apache.camel.RuntimeCamelException - Failed to extract body due to: javax.jms.JMSException: Failed to build body from bytes. Reason: java.io.StreamCorruptedException: invalid stream header: 00010000. Message: ActiveMQObjectMessage.
When I debug the code and set break point, there is exception on Bodylength and content saying 'request.Content' threw an exception of type 'Apache.NMS.MessageNotReadableException'
Is there any special zip conversion to send message on ActiveMQ server? Please Help. Thanks