Amin Sh
Amin Sh

Reputation: 2814

Set Object properties in activemq messages

How can I set Object properties in activemq messages?

When I use this method, with Apache Camel I get nothing!

In Activemq:

        BytesMessage byteMessage = session.createBytesMessage();
        byteMessage.writeBytes(new byte[1]);
        byteMessage.setJMSReplyTo(tempDest);
        String correlationId = this.createRandomString();
        byteMessage.setJMSCorrelationID(correlationId);

        byteMessage.setStringProperty("param1", "x");

        HashMap<String, String> map = new HashMap<String, String>();
        map.put("param3", "y");
        map.put("param4", "z");
        byteMessage.setObjectProperty("param2", map);

Then in Camel:

....
    .process(new Processor() {
        public void process(Exchange exchange) throws Exception {
            Message in = exchange.getIn();
            System.out.println(in.getHeaders().keySet());

            Object map= in.getHeaders().get("param2");
            System.out.println(map);
            }
        })
    ;

in keySet() there is no param2! and the result of the last line is NULL!

Upvotes: 0

Views: 2768

Answers (1)

Tracy Snell
Tracy Snell

Reputation: 1408

A Map isn't a valid object for setObjectProperty. From the Javadoc for Message:

"Property values can be boolean, byte, short, int, long, float, double, and String."

http://docs.oracle.com/javaee/1.4/api/javax/jms/Message.html

Upvotes: 2

Related Questions