0
votes

I am performing some simple tests with ActiveMQ to see how it performs on a non stable network. The first test consists in a producer that sends messages to a remote queue. The message is of type ObjectMessage with serializable content inside (a list of Objects).

With a good network everything works correctly, but when I launch the same tests using netem to simulate packages losses, delays and corruptions I get the following error when consuming the messages when trying to extract the content of the Message:

2011-03-16 11:59:21,791 ERROR [com.my.MessageConsumer] Failed to build body from bytes. Reason: java.io.StreamCorruptedException: invalid handle value: 017E0007 javax.jms.JMSException: Failed to build body from bytes. Reason: java.io.StreamCorruptedException: invalid handle value: 017E0007

So it seems like the message was corrupted while sending to the remote Queue but anyway stored, and only when is consumed the consumer see that the message is corrupted.

After this I will use a local Queue and a Network Connector to forward the messages to the remote Queue, and that I hope it solve the problem, but I was surprised that there was not any kind of validation between the producer and the destination (at least a checksum or something like that) that guarantees a correct delivery, am I doing something wrong or is the normal behaviour?

I don't have the code here right now, but it was super simple, just a MessageListener:


public class myMessageConsumer implements MessageListener{

   public void onMessage(Message message){

        try
        {

             if (message instanceof ObjectMessage){
                  ObjectMessage myMessage = (ObjectMessage) message;
                  List dtoList = (List) myMessage.getObject();
             }
        } catch(Exception ex){
           ex.printStackTrace();
        }
   }
}

If the exact code is needed I'll put it when I go back from holidays, but it was exactly like that.

2
Well I don't think that broker is supposed to do any validation by unmarshalling your message. It is just supposed to send message to the destination (consumer) and that's where it is unmarshalled.anubhava
I didn't mean unmarshalling the message, but at least some integrity check?jasalguero

2 Answers

0
votes

The broker isn't going to validate the contents of each and every message that it processes, that would be a tremendous waste of time and slow down message dispatch significantly. The client received a bad message and threw a JMSException to indicate that the message contents were corrupted which should be sufficient for your app to respond correctly.

0
votes

Where's your code?

If that exception comes from your code, seems like it's possible that you've got a bug. For example, getting some JMS error receiving the message but messing up error handling and trying to process the results anyway. For a test like you describe, you'd need a good focus on error handling in your clients.

I don't have experience w/ ActiveMQ, but it seems very surprising that it'd allow corrupt message delivery. Not that I'm wanting the JMS implementation to unpack the ObjectMessage to check. Just that it should deliver a byte-for-byte uncorrupted copy of what was sent. Or error out if it can't.