Search in sources :

Example 11 with MessagePublishInfo

use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.

the class MessageConverter_Internal_to_v0_8 method convertMetaData.

private MessageMetaData convertMetaData(final InternalMessage serverMsg, final NamedAddressSpace addressSpace, final String bodyMimeType, final int size) {
    MessagePublishInfo publishInfo = createMessagePublishInfo(serverMsg, addressSpace);
    final BasicContentHeaderProperties props = new BasicContentHeaderProperties();
    props.setAppId(serverMsg.getMessageHeader().getAppId());
    props.setContentType(bodyMimeType);
    props.setCorrelationId(convertToShortStringForProperty("correlation-id", serverMsg.getMessageHeader().getCorrelationId()));
    props.setDeliveryMode(serverMsg.isPersistent() ? BasicContentHeaderProperties.PERSISTENT : BasicContentHeaderProperties.NON_PERSISTENT);
    props.setExpiration(serverMsg.getExpiration());
    props.setMessageId(convertToOptionalAMQPShortString(serverMsg.getMessageHeader().getMessageId()));
    props.setPriority(serverMsg.getMessageHeader().getPriority());
    props.setReplyTo(convertToShortStringForProperty("reply-to", getReplyTo(serverMsg, addressSpace)));
    props.setTimestamp(serverMsg.getMessageHeader().getTimestamp());
    props.setUserId(convertToOptionalAMQPShortString(serverMsg.getMessageHeader().getUserId()));
    props.setEncoding(convertToShortStringForProperty("encoding", serverMsg.getMessageHeader().getEncoding()));
    Map<String, Object> headerProps = new LinkedHashMap<String, Object>();
    for (String headerName : serverMsg.getMessageHeader().getHeaderNames()) {
        headerProps.put(headerName, serverMsg.getMessageHeader().getHeader(headerName));
    }
    try {
        props.setHeaders(FieldTable.convertToFieldTable(headerProps));
    } catch (IllegalArgumentException | AMQPInvalidClassException e) {
        throw new MessageConversionException("Could not convert message from internal to 0-8 because headers conversion failed.", e);
    }
    final ContentHeaderBody chb = new ContentHeaderBody(props);
    chb.setBodySize(size);
    return new MessageMetaData(publishInfo, chb, serverMsg.getArrivalTime());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) LinkedHashMap(java.util.LinkedHashMap)

Example 12 with MessagePublishInfo

use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.

the class MessageFormat_0_9_1 method createMessage.

@Override
public AMQMessage createMessage(final QpidByteBuffer payload, final MessageStore store, final Object connectionReference) {
    try {
        AMQShortString exchange = readShortString(payload);
        AMQShortString routingKey = readShortString(payload);
        byte flags = payload.get();
        final MessagePublishInfo publishBody = new MessagePublishInfo(exchange, (flags & IMMEDIATE_MASK) != 0, (flags & MANDATORY_MASK) != 0, routingKey);
        final ContentHeaderBody contentHeaderBody = readContentBody(payload);
        MessageMetaData mmd = new MessageMetaData(publishBody, contentHeaderBody);
        final MessageHandle<MessageMetaData> handle = store.addMessage(mmd);
        handle.addContent(payload);
        final StoredMessage<MessageMetaData> storedMessage = handle.allContentAdded();
        return new AMQMessage(storedMessage, connectionReference);
    } catch (AMQFrameDecodingException | BufferUnderflowException e) {
        throw new ConnectionScopedRuntimeException("Error parsing AMQP 0-9-1 message format", e);
    }
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) BufferUnderflowException(java.nio.BufferUnderflowException)

Example 13 with MessagePublishInfo

use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.

the class ProtocolOutputConverterImpl method writeReturn.

@Override
public void writeReturn(MessagePublishInfo messagePublishInfo, ContentHeaderBody header, MessageContentSource message, int channelId, int replyCode, AMQShortString replyText) {
    AMQBody returnFrame = createEncodedReturnFrame(messagePublishInfo, replyCode, replyText);
    writeMessageDelivery(message, header, channelId, returnFrame);
}
Also used : AMQBody(org.apache.qpid.server.protocol.v0_8.transport.AMQBody)

Example 14 with MessagePublishInfo

use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.

the class ProtocolOutputConverterImpl method createEncodedGetOkBody.

private AMQBody createEncodedGetOkBody(AMQMessage message, InstanceProperties props, long deliveryTag, int queueSize) {
    final AMQShortString exchangeName;
    final AMQShortString routingKey;
    final MessagePublishInfo pb = message.getMessagePublishInfo();
    exchangeName = pb.getExchange();
    routingKey = pb.getRoutingKey();
    final boolean isRedelivered = Boolean.TRUE.equals(props.getProperty(InstanceProperties.Property.REDELIVERED));
    return _connection.getMethodRegistry().createBasicGetOkBody(deliveryTag, isRedelivered, exchangeName, routingKey, queueSize);
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)

Example 15 with MessagePublishInfo

use of org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo in project qpid-broker-j by apache.

the class MessageMetaDataFactoryTest method createTestMessageMetaData.

private MessageMetaData createTestMessageMetaData() {
    final MessagePublishInfo publishBody = new MessagePublishInfo(_exchange, false, false, _routingKey);
    final BasicContentHeaderProperties props = new BasicContentHeaderProperties();
    props.setContentType(CONTENT_TYPE);
    final ContentHeaderBody contentHeaderBody = new ContentHeaderBody(props);
    return new MessageMetaData(publishBody, contentHeaderBody, _arrivalTime);
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

Aggregations

MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)40 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)16 Matchers.anyString (org.mockito.Matchers.anyString)15 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)14 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)13 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)11 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)9 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)9 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)8 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)7 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)7 Exchange (org.apache.qpid.server.model.Exchange)6 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)6 Queue (org.apache.qpid.server.model.Queue)4 MessageMetaData (org.apache.qpid.server.protocol.v0_8.MessageMetaData)4 LinkedHashMap (java.util.LinkedHashMap)3 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)3 Date (java.util.Date)2 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)2 MessageDestination (org.apache.qpid.server.message.MessageDestination)2