use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_0_10Test method testTimestampConversion.
public void testTimestampConversion() {
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
final long timestamp = System.currentTimeMillis() - 10000;
basicContentHeaderProperties.setTimestamp(timestamp);
AMQMessage message = createTestMessage(basicContentHeaderProperties);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
assertEquals("Unexpected timestamp", timestamp, deliveryProperties.getTimestamp());
}
use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_0_10Test method testContentLengthConversion.
public void testContentLengthConversion() {
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
final byte[] content = { (byte) 1, (byte) 2 };
AMQMessage message = createTestMessage(basicContentHeaderProperties, content, 0);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertEquals("Unexpected content-length", content.length, messageProperties.getContentLength());
}
use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_0_10Test method testPersistentDeliveryModeConversion.
public void testPersistentDeliveryModeConversion() {
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
basicContentHeaderProperties.setDeliveryMode(BasicContentHeaderProperties.PERSISTENT);
AMQMessage message = createTestMessage(basicContentHeaderProperties);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
assertEquals("Unexpected deliveryMode", MessageDeliveryMode.PERSISTENT, deliveryProperties.getDeliveryMode());
}
use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_8 method convertMetaData.
private MessageMetaData convertMetaData(final Message_1_0 serverMsg, final String bodyMimeType, final int size, final NamedAddressSpace addressSpace) {
final MessageMetaData_1_0.MessageHeader_1_0 header = serverMsg.getMessageHeader();
final BasicContentHeaderProperties props = new BasicContentHeaderProperties();
props.setAppId(serverMsg.getMessageHeader().getAppId());
props.setContentType(bodyMimeType);
props.setEncoding(convertToShortStringForProperty("content-encoding", serverMsg.getMessageHeader().getEncoding()));
props.setCorrelationId(getCorrelationIdAsShortString(serverMsg));
props.setDeliveryMode(serverMsg.isPersistent() ? BasicContentHeaderProperties.PERSISTENT : BasicContentHeaderProperties.NON_PERSISTENT);
final Date absoluteExpiryTime = getAbsoluteExpiryTime(serverMsg);
if (absoluteExpiryTime != null) {
props.setExpiration(absoluteExpiryTime.getTime());
} else {
Long ttl = getTtl(serverMsg);
if (ttl != null) {
props.setExpiration(ttl + serverMsg.getArrivalTime());
}
}
props.setMessageId(getMessageIdAsShortString(serverMsg));
props.setPriority(serverMsg.getMessageHeader().getPriority());
props.setReplyTo(getReplyTo(serverMsg, addressSpace));
Date timestamp = getCreationTime(serverMsg);
if (timestamp != null) {
props.setTimestamp(timestamp.getTime());
} else {
props.setTimestamp(serverMsg.getArrivalTime());
}
props.setUserId(getUserIdAsShortString(serverMsg));
Map<String, Object> headerProps = new LinkedHashMap<>();
if (header.getSubject() != null) {
headerProps.put("qpid.subject", header.getSubject());
props.setType(convertToShortStringForProperty("subject", header.getSubject()));
}
String groupId = getGroupId(serverMsg);
if (groupId != null) {
headerProps.put("JMSXGroupID", groupId);
}
UnsignedInteger groupSequence = getGroupSequence(serverMsg);
if (groupSequence != null) {
headerProps.put("JMSXGroupSeq", groupSequence.intValue());
}
for (String headerName : serverMsg.getMessageHeader().getHeaderNames()) {
headerProps.put(headerName, convertValue(serverMsg.getMessageHeader().getHeader(headerName)));
}
final FieldTable headers;
try {
headers = FieldTable.convertToFieldTable(headerProps);
} catch (IllegalArgumentException e) {
throw new MessageConversionException("Could not convert message from 1.0 to 0-8 because conversion of 'application-properties' failed.", e);
}
props.setHeaders(headers);
final ContentHeaderBody chb = new ContentHeaderBody(props);
chb.setBodySize(size);
MessagePublishInfo publishInfo = createMessagePublishInfo(header, addressSpace);
return new MessageMetaData(publishInfo, chb, serverMsg.getArrivalTime());
}
use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties in project qpid-broker-j by apache.
the class BDBMessageStoreTest method createAndStoreSingleChunkMessage_0_8.
private StoredMessage<MessageMetaData> createAndStoreSingleChunkMessage_0_8(MessageStore store) {
QpidByteBuffer chunk1 = QpidByteBuffer.wrap(CONTENT_BYTES);
int bodySize = CONTENT_BYTES.length;
// create and store the message using the MessageStore interface
MessagePublishInfo pubInfoBody_0_8 = createPublishInfoBody_0_8();
BasicContentHeaderProperties props_0_8 = createContentHeaderProperties_0_8();
ContentHeaderBody chb_0_8 = createContentHeaderBody_0_8(props_0_8, bodySize);
MessageMetaData messageMetaData_0_8 = new MessageMetaData(pubInfoBody_0_8, chb_0_8);
MessageHandle<MessageMetaData> storedMessage_0_8 = store.addMessage(messageMetaData_0_8);
storedMessage_0_8.addContent(chunk1);
((AbstractBDBMessageStore.StoredBDBMessage) storedMessage_0_8).flushToStore();
return storedMessage_0_8.allContentAdded();
}
Aggregations