use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_InternalTest method testReplyToConversionWhenExchangeSpecified.
public void testReplyToConversionWhenExchangeSpecified() {
final String exchangeName = "amq.direct";
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setReplyTo(new ReplyTo(exchangeName, null));
MessageTransferMessage message = createTestMessage(messageProperties);
final InternalMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
assertEquals("Unexpected reply-to", exchangeName, convertedMessage.getMessageHeader().getReplyTo());
}
use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_InternalTest method testCorrelationIdConversionWhenNotString.
public void testCorrelationIdConversionWhenNotString() {
final byte[] correlationId = new byte[] { (byte) 0xc3, 0x28 };
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setCorrelationId(correlationId);
MessageTransferMessage message = createTestMessage(messageProperties);
final InternalMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
assertEquals("Unexpected correlationId", new String(correlationId, UTF_8), convertedMessage.getMessageHeader().getCorrelationId());
}
use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_InternalTest method testJmsTypeConversion.
public void testJmsTypeConversion() {
final String type = "test-type";
final Map<String, Object> headers = Collections.singletonMap("x-jms-type", type);
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setApplicationHeaders(headers);
MessageTransferMessage message = createTestMessage(messageProperties);
final InternalMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
assertEquals("Unexpected subject", type, convertedMessage.getMessageHeader().getType());
}
use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_InternalTest method testApplicationIdConversion.
public void testApplicationIdConversion() {
String applicationId = "testAppId";
MessageProperties messageProperties = new MessageProperties();
messageProperties.setAppId(applicationId.getBytes(UTF_8));
MessageTransferMessage message = createTestMessage(messageProperties);
final InternalMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
assertEquals("Unexpected app-id", applicationId, convertedMessage.getMessageHeader().getAppId());
}
use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.
the class MessageConverter_Internal_to_v0_10 method convertMetaData.
private MessageMetaData_0_10 convertMetaData(final InternalMessage serverMsg, final NamedAddressSpace addressSpace, final String bodyMimeType, final int size) {
DeliveryProperties deliveryProps = new DeliveryProperties();
MessageProperties messageProps = new MessageProperties();
deliveryProps.setDeliveryMode(serverMsg.isPersistent() ? MessageDeliveryMode.PERSISTENT : MessageDeliveryMode.NON_PERSISTENT);
long expiration = serverMsg.getExpiration();
if (expiration > 0) {
deliveryProps.setExpiration(expiration);
deliveryProps.setTtl(Math.max(0, expiration - serverMsg.getArrivalTime()));
}
InternalMessageHeader messageHeader = serverMsg.getMessageHeader();
deliveryProps.setPriority(MessageDeliveryPriority.get(messageHeader.getPriority()));
convertToAndInitialRoutingKey(serverMsg, deliveryProps, addressSpace);
deliveryProps.setTimestamp(messageHeader.getTimestamp());
messageProps.setContentEncoding(ensureStr8("content-encoding", messageHeader.getEncoding()));
messageProps.setContentLength(size);
messageProps.setContentType(bodyMimeType);
if (messageHeader.getCorrelationId() != null) {
messageProps.setCorrelationId(ensureVBin16("correlation-id", messageHeader.getCorrelationId().getBytes(UTF_8)));
}
validateValue(messageHeader.getHeaderMap(), "application-headers");
messageProps.setApplicationHeaders(messageHeader.getHeaderMap());
String messageIdAsString = messageHeader.getMessageId();
if (messageIdAsString != null) {
try {
if (messageIdAsString.startsWith("ID:")) {
messageIdAsString = messageIdAsString.substring(3);
}
messageProps.setMessageId(UUID.fromString(messageIdAsString));
} catch (IllegalArgumentException iae) {
// ignore message id is not a UUID
}
}
String userId = messageHeader.getUserId();
if (userId != null) {
byte[] bytes = userId.getBytes(UTF_8);
if (bytes.length <= MAX_VBIN16_LENGTH) {
messageProps.setUserId(bytes);
}
}
final String origReplyTo = messageHeader.getReplyTo();
if (origReplyTo != null && !origReplyTo.equals("")) {
messageProps.setReplyTo(getReplyTo(addressSpace, origReplyTo));
}
Header header = new Header(deliveryProps, messageProps, null);
return new MessageMetaData_0_10(header, size, serverMsg.getArrivalTime());
}
Aggregations