use of org.apache.qpid.server.message.internal.InternalMessageHeader in project qpid-broker-j by apache.
the class TrustStoreMessageSource method createMessage.
private InternalMessage createMessage() {
List<Object> messageList = new ArrayList<>();
for (Certificate cert : _certCache.get()) {
try {
messageList.add(cert.getEncoded());
} catch (CertificateEncodingException e) {
LOGGER.error("Could not encode certificate of type " + cert.getType(), e);
}
}
InternalMessageHeader header = new InternalMessageHeader(Collections.<String, Object>emptyMap(), null, 0l, null, null, UUID.randomUUID().toString(), null, null, (byte) 4, System.currentTimeMillis(), 0L, null, null, System.currentTimeMillis());
return InternalMessage.createListMessage(_virtualHost.getMessageStore(), header, messageList);
}
use of org.apache.qpid.server.message.internal.InternalMessageHeader in project qpid-broker-j by apache.
the class MessageConverter_Internal_to_0_10Test method getAmqMessage.
protected InternalMessage getAmqMessage(final Serializable content, final String mimeType) throws Exception {
final byte[] serializedContent = getObjectStreamMessageBytes(content);
configureMessageContent(serializedContent);
configureMessageHeader(mimeType);
final InternalMessageHeader internalMessageHeader = new InternalMessageHeader(_amqpHeader);
final int contentSize = serializedContent == null ? 0 : serializedContent.length;
final InternalMessageMetaData metaData = new InternalMessageMetaData(false, internalMessageHeader, contentSize);
when(_handle.getMetaData()).thenReturn(metaData);
return ((InternalMessage) InternalMessageMetaDataType.INSTANCE.createMessage(_handle));
}
use of org.apache.qpid.server.message.internal.InternalMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_10Test method createTestMessage.
private InternalMessage createTestMessage(String to) throws IOException {
final InternalMessageHeader internalMessageHeader = new InternalMessageHeader(mock(AMQMessageHeader.class));
final StoredMessage<InternalMessageMetaData> handle = createInternalStoredMessage(null, false, internalMessageHeader);
return new InternalMessage(handle, internalMessageHeader, null, to);
}
use of org.apache.qpid.server.message.internal.InternalMessageHeader 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.internal.InternalMessageHeader 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