Search in sources :

Example 56 with BasicContentHeaderProperties

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

the class BDBMessageStoreTest method createContentHeaderProperties_0_8.

private BasicContentHeaderProperties createContentHeaderProperties_0_8() {
    BasicContentHeaderProperties props = new BasicContentHeaderProperties();
    props.setDeliveryMode(Integer.valueOf(BasicContentHeaderProperties.PERSISTENT).byteValue());
    props.setContentType("text/html");
    props.getHeaders().setString("Test", "MST");
    return props;
}
Also used : BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

Example 57 with BasicContentHeaderProperties

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

the class LargeHeadersTest method headersFillContentHeaderFrame.

@Test
public /**
 * Tests boundary case where headers exactly fill the content header frame
 */
void headersFillContentHeaderFrame() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        String consumerTag = "A";
        ConnectionTuneBody connTune = interaction.negotiateProtocol().consumeResponse(ConnectionStartBody.class).connection().startOkMechanism("ANONYMOUS").startOk().consumeResponse(ConnectionTuneBody.class).getLatestResponse(ConnectionTuneBody.class);
        final String headerName = "test";
        final int headerValueSize = (int) (connTune.getFrameMax() - calculateContentHeaderFramingOverhead(headerName));
        final String headerValue = generateLongString(headerValueSize);
        final Map<String, Object> messageHeaders = Collections.singletonMap(headerName, headerValue);
        interaction.connection().tuneOk().connection().open().consumeResponse(ConnectionOpenOkBody.class).channel().open().consumeResponse(ChannelOpenOkBody.class).basic().qosPrefetchCount(1).qos().consumeResponse(BasicQosOkBody.class).basic().consumeConsumerTag(consumerTag).consumeQueue(BrokerAdmin.TEST_QUEUE_NAME).consumeNoAck(true).consume().consumeResponse(BasicConsumeOkBody.class).channel().flow(true).consumeResponse(ChannelFlowOkBody.class).basic().contentHeaderPropertiesHeaders(messageHeaders).publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).publishMessage().consumeResponse(BasicDeliverBody.class);
        BasicDeliverBody delivery = interaction.getLatestResponse(BasicDeliverBody.class);
        assertThat(delivery.getConsumerTag(), is(equalTo(AMQShortString.valueOf(consumerTag))));
        ContentHeaderBody header = interaction.consumeResponse(ContentHeaderBody.class).getLatestResponse(ContentHeaderBody.class);
        assertThat(header.getBodySize(), is(equalTo(0L)));
        BasicContentHeaderProperties properties = header.getProperties();
        Map<String, Object> receivedHeaders = new HashMap<>(FieldTable.convertToMap(properties.getHeaders()));
        assertThat(receivedHeaders, is(equalTo(new HashMap<>(messageHeaders))));
    }
}
Also used : ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) HashMap(java.util.HashMap) ConnectionStartBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionStartBody) BasicConsumeOkBody(org.apache.qpid.server.protocol.v0_8.transport.BasicConsumeOkBody) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) BasicQosOkBody(org.apache.qpid.server.protocol.v0_8.transport.BasicQosOkBody) ConnectionTuneBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionTuneBody) BasicDeliverBody(org.apache.qpid.server.protocol.v0_8.transport.BasicDeliverBody) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) Test(org.junit.Test)

Example 58 with BasicContentHeaderProperties

use of org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties 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 59 with BasicContentHeaderProperties

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

the class PropertyConverter_v0_8_to_InternalTest method testReplyToNonBurl.

public void testReplyToNonBurl() {
    final String replyTo = "test/routing";
    BasicContentHeaderProperties header = new BasicContentHeaderProperties();
    header.setReplyTo(replyTo);
    final AMQMessage originalMessage = createTestMessage(header);
    InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected replyTo", replyTo, convertedMessage.getMessageHeader().getReplyTo());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

Example 60 with BasicContentHeaderProperties

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

the class AMQChannelTest method testOversizedMessageClosesChannel.

public void testOversizedMessageClosesChannel() throws Exception {
    when(_virtualHost.getDefaultDestination()).thenReturn(mock(MessageDestination.class));
    long maximumMessageSize = 1024l;
    when(_amqConnection.getMaxMessageSize()).thenReturn(maximumMessageSize);
    AMQChannel channel = new AMQChannel(_amqConnection, 1, _virtualHost.getMessageStore());
    BasicContentHeaderProperties properties = new BasicContentHeaderProperties();
    channel.receiveBasicPublish(AMQShortString.EMPTY_STRING, AMQShortString.EMPTY_STRING, false, false);
    channel.receiveMessageHeader(properties, maximumMessageSize + 1);
    verify(_amqConnection).closeChannelAndWriteFrame(eq(channel), eq(ErrorCodes.MESSAGE_TOO_LARGE), eq("Message size of 1025 greater than allowed maximum of 1024"));
}
Also used : MessageDestination(org.apache.qpid.server.message.MessageDestination) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

Aggregations

BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)151 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)115 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)74 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)59 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)52 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)48 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)39 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)31 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)21 Matchers.anyString (org.mockito.Matchers.anyString)20 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)18 HashMap (java.util.HashMap)16 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)16 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)12 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)9 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)8 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)7 Date (java.util.Date)6 UUID (java.util.UUID)6 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)6