skyscreamer / nevado

A JMS driver for Amazon SQS.

Home Page:http://nevado.skyscreamer.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Message deserialization fails with an exception

madganti opened this issue · comments

Trying to send a simple string message through SQS and listening for it. Getting the stack trace -

Unable to deserialized message: expected Hessian message ('p') at 0xb2 (²)
com.caucho.hessian.io.HessianProtocolException: expected Hessian message ('p') at 0xb2 (²)
at com.caucho.hessian.io.Hessian2Input.error(Hessian2Input.java:2882) ~[hessian-4.0.7.jar:na]
at com.caucho.hessian.io.Hessian2Input.startMessage(Hessian2Input.java:479) ~[hessian-4.0.7.jar:na]
at org.skyscreamer.nevado.jms.util.SerializeUtil.deserialize(SerializeUtil.java:56) ~[nevado-jms-1.3.2-SNAPSHOT.jar:1.3.2-SNAPSHOT]
at org.skyscreamer.nevado.jms.util.SerializeUtil.deserializeFromString(SerializeUtil.java:48) ~[nevado-jms-1.3.2-SNAPSHOT.jar:1.3.2-SNAPSHOT]
at org.skyscreamer.nevado.jms.connector.AbstractSQSConnector.deserializeMessage(AbstractSQSConnector.java:295) [nevado-jms-1.3.2-SNAPSHOT.jar:1.3.2-SNAPSHOT]
at org.skyscreamer.nevado.jms.connector.AbstractSQSConnector.convertSqsMessage(AbstractSQSConnector.java:238) [nevado-jms-1.3.2-SNAPSHOT.jar:1.3.2-SNAPSHOT]
at org.skyscreamer.nevado.jms.connector.amazonaws.AmazonAwsSQSConnector.convertSqsMessage(AmazonAwsSQSConnector.java:204) [nevado-jms-1.3.2-SNAPSHOT.jar:1.3.2-SNAPSHOT]
at org.skyscreamer.nevado.jms.connector.AbstractSQSConnector.receiveMessage(AbstractSQSConnector.java:113) [nevado-jms-1.3.2-SNAPSHOT.jar:1.3.2-SNAPSHOT]
at org.skyscreamer.nevado.jms.NevadoSession.getUnfilteredMessage(NevadoSession.java:471) [nevado-jms-1.3.2-SNAPSHOT.jar:1.3.2-SNAPSHOT]
at org.skyscreamer.nevado.jms.NevadoSession.receiveMessage(NevadoSession.java:434) [nevado-jms-1.3.2-SNAPSHOT.jar:1.3.2-SNAPSHOT]
at org.skyscreamer.nevado.jms.NevadoMessageConsumer.processAsyncMessage(NevadoMessageConsumer.java:133) [nevado-jms-1.3.2-SNAPSHOT.jar:1.3.2-SNAPSHOT]
at org.skyscreamer.nevado.jms.AsyncConsumerRunner.processMessage(AsyncConsumerRunner.java:77) [nevado-jms-1.3.2-SNAPSHOT.jar:1.3.2-SNAPSHOT]
at org.skyscreamer.nevado.jms.AsyncConsumerRunner.run(AsyncConsumerRunner.java:38) [nevado-jms-1.3.2-SNAPSHOT.jar:1.3.2-SNAPSHOT]

When debugging I see that the serialized message in SerializeUtil class is the right message, but something is messing up the deserialization.

This is the code from Hessian2Input's startMessage method (which is where the exception happens) -

public int startMessage() throws IOException {
int tag = read();
if (tag == 'p')
_isStreaming = false;
else if (tag == 'P')
_isStreaming = true;
else
throw error("expected Hessian message ('p') at " + codeName(tag));
....

This happens when you send a message by a means other than Nevado. Unfortunately, Nevado can only read messages that were published by Nevado. This is because of the metadata that needs to be sent with the message to be JMS compliant. SQS does not support arbitrary metadata so it has to be serialized and base64 encoded.

HI Carter,
I am manually inserting a message into the queue using AWS console. I get this exception. How can we control what is used to send message into the queue? As an AWS user, we can only consume messages from SQS. Please share any other option to get this resolved.

You must use Nevado to send and receive all messages. If you are not sending messages with Nevado, you cannot receive with Nevado. If you are receiving message with something besides Nevado, you cannot send with Nevado. It is a design decision to favor fidelity to JMS over compatibility with other mechanisms. If this doesn't work for you, the best choice is to use the Amazon AWS SDK to send/receive messages directly.