use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class MessageConverter_v0_8_to_Internal method convertHeader.
private AMQMessageHeader convertHeader(final AMQMessage serverMessage, final NamedAddressSpace addressSpace, final Object convertedBodyObject, final String encoding) {
final String convertedMimeType = getInternalConvertedMimeType(serverMessage, convertedBodyObject);
final AMQMessageHeader messageHeader = serverMessage.getMessageHeader();
Map<String, Object> headers = new HashMap<>();
messageHeader.getHeaderNames().forEach(headerName -> headers.put(headerName, messageHeader.getHeader(headerName)));
final InternalMessageHeader header = new InternalMessageHeader(headers, messageHeader.getCorrelationId(), messageHeader.getExpiration(), messageHeader.getUserId(), messageHeader.getAppId(), messageHeader.getMessageId(), convertedMimeType, messageHeader.getEncoding(), messageHeader.getPriority(), messageHeader.getTimestamp(), messageHeader.getNotValidBefore(), messageHeader.getType(), messageHeader.getReplyTo(), serverMessage.getArrivalTime());
return new DelegatingMessageHeader(header, encoding);
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class MessageConverter_v0_10_to_Internal method convertHeader.
private AMQMessageHeader convertHeader(final MessageTransferMessage serverMessage, final NamedAddressSpace addressSpace, final Object convertedBodyObject, final String encoding) {
final String convertedMimeType = getInternalConvertedMimeType(serverMessage, convertedBodyObject);
final AMQMessageHeader messageHeader = serverMessage.getMessageHeader();
Map<String, Object> headers = new HashMap<>();
messageHeader.getHeaderNames().forEach(headerName -> headers.put(headerName, messageHeader.getHeader(headerName)));
final InternalMessageHeader header = new InternalMessageHeader(headers, messageHeader.getCorrelationId(), messageHeader.getExpiration(), messageHeader.getUserId(), messageHeader.getAppId(), messageHeader.getMessageId(), convertedMimeType, messageHeader.getEncoding(), messageHeader.getPriority(), messageHeader.getTimestamp(), messageHeader.getNotValidBefore(), messageHeader.getType(), messageHeader.getReplyTo(), serverMessage.getArrivalTime());
MessageProperties messageProps = serverMessage.getHeader().getMessageProperties();
final ReplyTo replyTo = messageProps == null ? null : messageProps.getReplyTo();
return new DelegatingMessageHeader(header, replyTo, encoding);
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testUserIdConversion.
public void testUserIdConversion() {
final String userId = "testUserId";
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getUserId()).thenReturn(userId);
InternalMessage originalMessage = createTestMessage(header);
AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected userId", userId, convertedMessage.getContentHeaderBody().getProperties().getUserIdAsString());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testReplyToConversionWhenNonExistingExchangeAndRoutingKeyAreSpecified.
public void testReplyToConversionWhenNonExistingExchangeAndRoutingKeyAreSpecified() {
final String exchangeName = "testExchange";
final String routingKey = "testKey";
final String replyTo = String.format("%s/%s", exchangeName, routingKey);
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getReplyTo()).thenReturn(replyTo);
InternalMessage originalMessage = createTestMessage(header);
AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected reply-to", "direct:////?routingkey='" + replyTo + "'", convertedMessage.getContentHeaderBody().getProperties().getReplyToAsString());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testUserIdConversionWhenLengthExceeds255.
public void testUserIdConversionWhenLengthExceeds255() {
final String userId = generateLongString();
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getUserId()).thenReturn(userId);
InternalMessage originalMessage = createTestMessage(header);
AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertNull("Unexpected userId", convertedMessage.getContentHeaderBody().getProperties().getUserId());
}
Aggregations