You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by mta38 <mt...@orange-ftgroup.com> on 2008/11/24 12:43:55 UTC

JMS - javax.jms.BytesMessage - Properties can't be retrieved in JmsExchange

Hi all,

I have a producer that send BytesMessage object on a queue (ActiveMq is the
broker).

Here is the code of producer

BytesMessage message = queueSession.createBytesMessage();

byte[] body = prepareRequestBody();
message.writeBytes(body);

message.setStringProperty(Constants.MAINCLIENT, "TEST");
			
			
queueProducer.send(message);
			
QueueReceiver queueConsumer = queueSession.createReceiver(queueResponse);

All here is OK, message is sent to the jms endpoint. But when I explore the
Exchange object in the first processor which deals with the message I can
notice the IN message object have no property.

Following is my processor implementation

public void process(Exchange exchange) throws Exception {
try
   {
	JmsExchange jmse =(JmsExchange)exchange;
	BytesMessage jmsMsg = (BytesMessage)jmse.getIn();
					
	String ss = jmsMsg.getStringProperty(Constants.MAINCLIENT);
	System.out.println("PROPERTY ==> "+ss);
		
	UUID uuid = UUID.randomUUID();	
	exchange.getIn().setHeader(Constants.IDMESSAGE,  uuid.toString());	
				
}
catch(Exception ex)
{
	exchange.getFault().setBody(ex);
}

May be there are something wrong in my code but I can't see what :confused:.
Any help are welcome.
Thanks in advance 
Mta38

-- 
View this message in context: http://www.nabble.com/JMS---javax.jms.BytesMessage---Properties-can%27t-be-retrieved-in-JmsExchange-tp20659410s22882p20659410.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: JMS - javax.jms.BytesMessage - Properties can't be retrieved in JmsExchange

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Which version of Camel are you using?
And how is the string for your property key: Constants.MAINCLIENT

The JMS spec only allows primitives and String to be sent as JMS
properties so it might be dropped by Camel.

So if you send a property with the key: "foo" then it should get
there. Also be careful to use dots in the key as this is not allowed
on all brokers. So it's better to avoid them.



/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/



On Mon, Nov 24, 2008 at 12:43 PM, mta38 <mt...@orange-ftgroup.com> wrote:
>
> Hi all,
>
> I have a producer that send BytesMessage object on a queue (ActiveMq is the
> broker).
>
> Here is the code of producer
>
> BytesMessage message = queueSession.createBytesMessage();
>
> byte[] body = prepareRequestBody();
> message.writeBytes(body);
>
> message.setStringProperty(Constants.MAINCLIENT, "TEST");
>
>
> queueProducer.send(message);
>
> QueueReceiver queueConsumer = queueSession.createReceiver(queueResponse);
>
> All here is OK, message is sent to the jms endpoint. But when I explore the
> Exchange object in the first processor which deals with the message I can
> notice the IN message object have no property.
>
> Following is my processor implementation
>
> public void process(Exchange exchange) throws Exception {
> try
>   {
>        JmsExchange jmse =(JmsExchange)exchange;
>        BytesMessage jmsMsg = (BytesMessage)jmse.getIn();
>
>        String ss = jmsMsg.getStringProperty(Constants.MAINCLIENT);
>        System.out.println("PROPERTY ==> "+ss);
>
>        UUID uuid = UUID.randomUUID();
>        exchange.getIn().setHeader(Constants.IDMESSAGE,  uuid.toString());
>
> }
> catch(Exception ex)
> {
>        exchange.getFault().setBody(ex);
> }
>
> May be there are something wrong in my code but I can't see what :confused:.
> Any help are welcome.
> Thanks in advance
> Mta38
>
> --
> View this message in context: http://www.nabble.com/JMS---javax.jms.BytesMessage---Properties-can%27t-be-retrieved-in-JmsExchange-tp20659410s22882p20659410.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>