Header header = new Header();
header.setDurable(serverMessage.isPersistent());
BasicContentHeaderProperties contentHeader =
(BasicContentHeaderProperties) serverMessage.getContentHeaderBody().getProperties();
header.setPriority(UnsignedByte.valueOf(contentHeader.getPriority()));
final long expiration = serverMessage.getExpiration();
final long arrivalTime = serverMessage.getArrivalTime();
if(expiration > arrivalTime)
{
header.setTtl(UnsignedInteger.valueOf(expiration - arrivalTime));
}
sections.add(header);
Properties props = new Properties();
props.setContentEncoding(Symbol.valueOf(contentHeader.getEncodingAsString()));
props.setContentType(Symbol.valueOf(contentHeader.getContentTypeAsString()));
// Modify the content type when we are dealing with java object messages produced by the Qpid 0.x client
if(props.getContentType() == Symbol.valueOf("application/java-object-stream"))
{
props.setContentType(Symbol.valueOf("application/x-java-serialized-object"));
}
final AMQShortString correlationId = contentHeader.getCorrelationId();
if(correlationId != null)
{
props.setCorrelationId(new Binary(correlationId.getBytes()));
}
// props.setCreationTime();
// props.setGroupId();
// props.setGroupSequence();
final AMQShortString messageId = contentHeader.getMessageId();
if(messageId != null)
{
props.setMessageId(new Binary(messageId.getBytes()));
}
props.setReplyTo(String.valueOf(contentHeader.getReplyTo()));
// props.setReplyToGroupId();
props.setSubject(serverMessage.getRoutingKey());
// props.setTo();
if(contentHeader.getUserId() != null)
{
props.setUserId(new Binary(contentHeader.getUserId().getBytes()));
}
sections.add(props);
sections.add(new ApplicationProperties(FieldTable.convertToMap(contentHeader.getHeaders())));
return new MessageMetaData_1_0(sections, _sectionEncoder);
}