Search in sources :

Example 36 with ApplicationProperties

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;
}
Also used : MessageMetaData_1_0(org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) LinkedHashMap(java.util.LinkedHashMap)

Example 37 with 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 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));
}
Also used : HashMap(java.util.HashMap) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0)

Example 38 with 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"));
}
Also used : MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 39 with ApplicationProperties

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"));
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) DeliveryAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 40 with ApplicationProperties

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());
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) DeliveryAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Aggregations

Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)31 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)23 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)21 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)16 HashMap (java.util.HashMap)15 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)15 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)14 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)13 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)12 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)11 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)10 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)10 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)10 Matchers.anyString (org.mockito.Matchers.anyString)10 Date (java.util.Date)8 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)7 MessageMetaData_1_0 (org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0)7 Footer (org.apache.qpid.server.protocol.v1_0.type.messaging.Footer)7 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)5 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)5