Search in sources :

Example 6 with InternalMessageHeader

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);
}
Also used : InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader) ArrayList(java.util.ArrayList) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) CertificateEncodingException(java.security.cert.CertificateEncodingException) Certificate(java.security.cert.Certificate)

Example 7 with InternalMessageHeader

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));
}
Also used : InternalMessageMetaData(org.apache.qpid.server.message.internal.InternalMessageMetaData) InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader)

Example 8 with InternalMessageHeader

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);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) InternalMessageMetaData(org.apache.qpid.server.message.internal.InternalMessageMetaData) InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 9 with InternalMessageHeader

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);
}
Also used : HashMap(java.util.HashMap) InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 10 with InternalMessageHeader

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());
}
Also used : Header(org.apache.qpid.server.protocol.v0_10.transport.Header) InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Aggregations

InternalMessageHeader (org.apache.qpid.server.message.internal.InternalMessageHeader)22 InternalMessageMetaData (org.apache.qpid.server.message.internal.InternalMessageMetaData)9 HashMap (java.util.HashMap)7 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)7 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)6 ManagedObject (org.apache.qpid.server.model.ManagedObject)6 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)5 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)5 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)3 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)2 AccessControlException (java.security.AccessControlException)1 Certificate (java.security.cert.Certificate)1 CertificateEncodingException (java.security.cert.CertificateEncodingException)1 ArrayList (java.util.ArrayList)1 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1 AmqpConnectionMetaData (org.apache.qpid.server.connection.AmqpConnectionMetaData)1 ConfiguredObjectOperation (org.apache.qpid.server.model.ConfiguredObjectOperation)1 IntegrityViolationException (org.apache.qpid.server.model.IntegrityViolationException)1 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)1