tags:

views:

32

answers:

1

Hi, I am building a small api around the JMS API for a project of mine. Essentially, we are building code that will handle the connection logic, and will simplify publishing messages by providing a method like Client.send(String message).

One of the ideas being discussed right now is that we provide a means for the users to attach interceptors to this client. We will apply the interceptors after preparing the JMS message and before publishing it.

For example, if we want to timestamp a message and wrote an interceptor for that, then this is how we would apply that

...some code ...

Message message = session.createMessage()

..do all the current processing on the message and set the body

for(interceptor:listOfInterceptors){
   interceptor.apply(message)
}

One of the intrerceptors we though of was to compress the message body. But when we try to read the body of the message in the interceptor, we are getting a MessageNotReadableException. In the past, I normally compressed the content before setting it as the body of the message - so never had to worry about this exception.

Is there any way of getting around this exception?

A: 

It looks like your JMS client attempts to read a write-only message. Your interceptor cannot work this way, please elaborate how you were compressing message earlier.

Ravi Gupta
What we did previously was to take the message, convert it to bytes and then compress it using java compression libraries and set the compressed bytes as a body of a BytesMessage.Now we want to try this interceptor where we set the body of the message as text, and optionally enable the interceptor which will compress the body of the message for us.
Hari