diff options
4 files changed, 60 insertions, 8 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java index e4873de80c..7cac9773b0 100644 --- a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java +++ b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java @@ -5,9 +5,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -19,6 +19,7 @@ package org.apache.qpid.client; import org.apache.qpid.client.protocol.AMQProtocolHandler; import org.apache.qpid.client.message.AbstractJMSMessage; +import org.apache.qpid.client.message.FiledTableSupport; import org.apache.qpid.framing.BasicContentHeaderProperties; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.url.AMQBindingURL; @@ -115,12 +116,18 @@ public class BasicMessageProducer_0_10 extends BasicMessageProducer qpidityMessage.getMessageProperties() .setReplyTo(new ReplyTo(dest.getExchangeName().toString(), dest.getRoutingKey().toString())); } + if (contentHeaderProperties.getHeaders() != null) { // todo use the new fieldTable - qpidityMessage.getMessageProperties().setApplicationHeaders(null); + qpidityMessage.getMessageProperties().setApplicationHeaders(FiledTableSupport.convertToMap(contentHeaderProperties.getHeaders())); + + for(String key:qpidityMessage.getMessageProperties().getApplicationHeaders().keySet()) + { + System.out.println(key + "=" + qpidityMessage.getMessageProperties().getApplicationHeaders().get(key)); + } } - // send the message + // send the message try { ((AMQSession_0_10) getSession()).getQpidSession().messageTransfer(destination.getExchangeName().toString(), diff --git a/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java b/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java index 2e407eabf0..9313149442 100644 --- a/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java +++ b/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java @@ -139,6 +139,9 @@ public abstract class AbstractJMSMessageFactory implements MessageFactory props.setTimestamp(devprop.getTimestamp()); props.setType(mprop.getType()); props.setUserId(mprop.getUserId()); + + props.setHeaders(FiledTableSupport.convertToFieldTable(mprop.getApplicationHeaders())); + return createMessage(messageNbr, data, exchange, routingKey, props); } diff --git a/java/client/src/main/java/org/apache/qpid/client/message/FiledTableSupport.java b/java/client/src/main/java/org/apache/qpid/client/message/FiledTableSupport.java new file mode 100644 index 0000000000..ff7e1f72fb --- /dev/null +++ b/java/client/src/main/java/org/apache/qpid/client/message/FiledTableSupport.java @@ -0,0 +1,34 @@ +package org.apache.qpid.client.message; + +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import org.apache.qpid.framing.AMQShortString; +import org.apache.qpid.framing.FieldTable; + +public class FiledTableSupport +{ + public static FieldTable convertToFieldTable(Map<String,?> props) + { + FieldTable ft = new FieldTable(); + for (String key : props.keySet()) + { + ft.setObject(key, props.get(key)); + } + + return ft; + } + + public static Map<String,Object> convertToMap(FieldTable ft) + { + Map<String,Object> map = new HashMap<String,Object>(); + for (Enumeration keys = ft.getPropertyNames(); keys.hasMoreElements();) + { + AMQShortString key = (AMQShortString)keys.nextElement(); + map.put(key.asString(), ft.getObject(key)); + } + + return map; + } +} diff --git a/java/client/src/main/java/org/apache/qpidity/nclient/interop/BasicInteropTest.java b/java/client/src/main/java/org/apache/qpidity/nclient/interop/BasicInteropTest.java index afd14aac06..993b0870aa 100644 --- a/java/client/src/main/java/org/apache/qpidity/nclient/interop/BasicInteropTest.java +++ b/java/client/src/main/java/org/apache/qpidity/nclient/interop/BasicInteropTest.java @@ -1,5 +1,8 @@ package org.apache.qpidity.nclient.interop; +import java.util.HashMap; +import java.util.Map; + import org.apache.qpidity.ErrorCode; import org.apache.qpidity.QpidException; import org.apache.qpidity.api.Message; @@ -10,6 +13,7 @@ import org.apache.qpidity.nclient.Session; import org.apache.qpidity.nclient.util.MessageListener; import org.apache.qpidity.nclient.util.MessagePartListenerAdapter; import org.apache.qpidity.transport.DeliveryProperties; +import org.apache.qpidity.transport.MessageProperties; import org.apache.qpidity.transport.RangeSet; public class BasicInteropTest implements ClosedListener @@ -70,7 +74,13 @@ public class BasicInteropTest implements ClosedListener public void testSendMessage(){ System.out.println("------- Sending a message --------"); session.messageTransfer("test", Session.TRANSFER_CONFIRM_MODE_REQUIRED, Session.TRANSFER_ACQUIRE_MODE_PRE_ACQUIRE); - session.header(new DeliveryProperties().setRoutingKey("testKey")); + + Map<String,Object> props = new HashMap<String,Object>(); + props.put("name", "rajith"); + props.put("age", 10); + props.put("spf", 8.5); + session.header(new DeliveryProperties().setRoutingKey("testKey"),new MessageProperties().setApplicationHeaders(props)); + session.data("TestMessage"); session.endData(); session.sync(); @@ -122,7 +132,7 @@ public class BasicInteropTest implements ClosedListener public static void main(String[] args) throws QpidException { - /*String host = "0.0.0.0"; + String host = "0.0.0.0"; if (args.length>0) { host = args[0]; @@ -137,8 +147,6 @@ public class BasicInteropTest implements ClosedListener t.testSendMessage(); t.testMessageFlush(); t.close(); - */ - System.out.print(Integer.toHexString(-1)); } } |