use of org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10 method getApplicationHeaders.
private Map<String, Object> getApplicationHeaders(final Message_1_0 serverMsg) {
final MessageMetaData_1_0.MessageHeader_1_0 origHeader = serverMsg.getMessageHeader();
final Map<String, Object> applicationProperties = serverMsg.getMessageHeader().getHeadersAsMap();
for (String key : applicationProperties.keySet()) {
ensureStr8("application-properties[\"" + key + "\"]", key);
}
Map<String, Object> appHeaders = new LinkedHashMap((Map<String, Object>) convertValue(applicationProperties));
if (origHeader.getSubject() != null) {
if (!appHeaders.containsKey("qpid.subject")) {
appHeaders.put("qpid.subject", origHeader.getSubject());
}
if (!appHeaders.containsKey("x-jms-type")) {
appHeaders.put("x-jms-type", origHeader.getSubject());
}
}
String groupId = getGroupId(serverMsg);
if (groupId != null && !appHeaders.containsKey("JMSXGroupID")) {
appHeaders.put("JMSXGroupID", groupId);
}
UnsignedInteger groupSequence = getGroupSequence(serverMsg);
if (groupSequence != null && !appHeaders.containsKey("JMSXGroupSeq")) {
appHeaders.put("JMSXGroupSeq", groupSequence.intValue());
}
return appHeaders;
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_1_0Test method testHeaderConversion.
public void testHeaderConversion() {
Map<String, Object> headers = new HashMap<>();
headers.put("testProperty1", "testProperty1Value");
headers.put("intProperty", 1);
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setApplicationHeaders(headers);
MessageTransferMessage message = createTestMessage(messageProperties);
final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
assertEquals("Unexpected applicationProperties", headers, new HashMap<>(applicationProperties));
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_1_0Test method testHeaderJMSXGroupIdConversion.
public void testHeaderJMSXGroupIdConversion() {
String testGroupId = "testGroupId";
Map<String, Object> headers = Collections.singletonMap("JMSXGroupID", testGroupId);
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setApplicationHeaders(headers);
MessageTransferMessage message = createTestMessage(messageProperties);
final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
Properties properties = convertedMessage.getPropertiesSection().getValue();
assertEquals("Unexpected group-id", testGroupId, properties.getGroupId());
Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
assertFalse("Unexpected JMSXGroupID in application properties", applicationProperties.containsKey("JMSXGroupID"));
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_10Test method testGroupSequenceDoesNotReplaceApplicationPropertiesJMSXGroupSeq.
public void testGroupSequenceDoesNotReplaceApplicationPropertiesJMSXGroupSeq() {
int testGroupSequence = 1;
Properties properties = new Properties();
properties.setGroupSequence(UnsignedInteger.valueOf(testGroupSequence));
final int JMSXGroupSeq = 2;
Map<String, Object> applicationPropertiesMap = Collections.singletonMap("JMSXGroupSeq", JMSXGroupSeq);
ApplicationProperties applicationProperties = new ApplicationProperties(applicationPropertiesMap);
Message_1_0 message = createTestMessage(new Header(), new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, applicationProperties, 0, null);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
final Map<String, Object> applicationHeaders = messageProperties.getApplicationHeaders();
assertEquals("Unexpected JMSXGroupSeq", JMSXGroupSeq, applicationHeaders.get("JMSXGroupSeq"));
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties in project qpid-broker-j by apache.
the class PropertyConverter_1_0_to_0_10Test method testSubjectDoesNoReplaceApplicationPropertyXJMSType.
public void testSubjectDoesNoReplaceApplicationPropertyXJMSType() {
final String subject = "testSubject";
Properties properties = new Properties();
properties.setSubject(subject);
final String jmsType = "testJmsType";
Map<String, Object> applicationPropertiesMap = Collections.singletonMap("x-jms-type", jmsType);
ApplicationProperties applicationProperties = new ApplicationProperties(applicationPropertiesMap);
Message_1_0 message = createTestMessage(new Header(), new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, applicationProperties, 0, null);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
final Map<String, Object> headers = messageProperties.getApplicationHeaders();
assertEquals("Unexpected qpid.subject is missing from headers", subject, headers.get("qpid.subject"));
assertEquals("Unexpected type", jmsType, headers.get("x-jms-type"));
final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
assertEquals("Unexpected routing-key", subject, deliveryProperties.getRoutingKey());
}
Aggregations