Search in sources :

Example 6 with MessageProperties

use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testHeaderJMSXGroupSeqConversion.

public void testHeaderJMSXGroupSeqConversion() {
    int testGroupSequenceNumber = 1;
    Map<String, Object> headers = Collections.singletonMap("JMSXGroupSeq", testGroupSequenceNumber);
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setApplicationHeaders(headers);
    MessageTransferMessage message = createTestMessage(messageProperties);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertEquals("Unexpected group-sequence", testGroupSequenceNumber, properties.getGroupSequence().intValue());
    Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
    assertFalse("Unexpected JMSXGroupSeq in application properties", applicationProperties.containsKey("JMSXGroupSeq"));
}
Also used : MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 7 with MessageProperties

use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testReplyToConversionWhenExchangeAndRoutingKeyAreNull.

public void testReplyToConversionWhenExchangeAndRoutingKeyAreNull() {
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setReplyTo(new ReplyTo(null, null));
    MessageTransferMessage message = createTestMessage(messageProperties);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertNull("Unexpected reply-to", properties.getReplyTo());
}
Also used : ReplyTo(org.apache.qpid.server.protocol.v0_10.transport.ReplyTo) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Example 8 with MessageProperties

use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.

the class Assembler method assemble.

private void assemble(Frame frame, ByteBuffer segment) {
    BBDecoder dec = _decoder.get();
    dec.init(segment);
    int channel = frame.getChannel();
    Method command;
    switch(frame.getType()) {
        case CONTROL:
            int controlType = dec.readUint16();
            Method control = Method.create(controlType);
            control.read(dec);
            emit(channel, control);
            break;
        case COMMAND:
            int commandType = dec.readUint16();
            // read in the session header, right now we don't use it
            int hdr = dec.readUint16();
            command = Method.create(commandType);
            command.setSync((0x0001 & hdr) != 0);
            command.read(dec);
            if (command.hasPayload() && !frame.isLastSegment()) {
                setIncompleteCommand(channel, command);
            } else {
                emit(channel, command);
            }
            break;
        case HEADER:
            command = getIncompleteCommand(channel);
            List<Struct> structs = null;
            DeliveryProperties deliveryProps = null;
            MessageProperties messageProps = null;
            while (dec.hasRemaining()) {
                Struct struct = dec.readStruct32();
                if (struct instanceof DeliveryProperties && deliveryProps == null) {
                    deliveryProps = (DeliveryProperties) struct;
                } else if (struct instanceof MessageProperties && messageProps == null) {
                    messageProps = (MessageProperties) struct;
                } else {
                    if (structs == null) {
                        structs = new ArrayList<>(2);
                    }
                    structs.add(struct);
                }
            }
            command.setHeader(new Header(deliveryProps, messageProps, structs));
            if (frame.isLastSegment()) {
                setIncompleteCommand(channel, null);
                emit(channel, command);
            }
            break;
        case BODY:
            command = getIncompleteCommand(channel);
            command.setBody(QpidByteBuffer.wrap(segment));
            setIncompleteCommand(channel, null);
            emit(channel, command);
            break;
        default:
            throw new IllegalStateException("unknown frame type: " + frame.getType());
    }
    dec.releaseBuffer();
}
Also used : ProtocolHeader(org.apache.qpid.server.protocol.v0_10.transport.ProtocolHeader) Header(org.apache.qpid.server.protocol.v0_10.transport.Header) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) ArrayList(java.util.ArrayList) Method(org.apache.qpid.server.protocol.v0_10.transport.Method) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) BBDecoder(org.apache.qpid.server.protocol.v0_10.transport.BBDecoder) Struct(org.apache.qpid.server.protocol.v0_10.transport.Struct)

Example 9 with MessageProperties

use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.

the class LargeMessageBodyTest method messageBodyOverManyFrames.

@Test
public void messageBodyOverManyFrames() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        final String subscriberName = "testSubscriber";
        byte[] sessionName = "test".getBytes(UTF_8);
        ConnectionTune tune = interaction.negotiateProtocol().consumeResponse().consumeResponse(ConnectionStart.class).connection().startOkMechanism(ConnectionInteraction.SASL_MECHANISM_ANONYMOUS).startOk().consumeResponse().getLatestResponse(ConnectionTune.class);
        final byte[] messageContent = new byte[tune.getMaxFrameSize() * 2];
        IntStream.range(0, messageContent.length).forEach(i -> {
            messageContent[i] = (byte) (i & 0xFF);
        });
        interaction.connection().tuneOk().connection().open().consumeResponse(ConnectionOpenOk.class);
        MessageProperties messageProperties = new MessageProperties();
        messageProperties.setContentLength(messageContent.length);
        interaction.channelId(1).attachSession(sessionName).message().subscribeDestination(subscriberName).subscribeQueue(BrokerAdmin.TEST_QUEUE_NAME).subscribeId(0).subscribe().message().flowId(1).flowDestination(subscriberName).flowUnit(MessageCreditUnit.MESSAGE).flowValue(1).flow().message().flowId(2).flowDestination(subscriberName).flowUnit(MessageCreditUnit.BYTE).flowValue(-1).flow().message().transferDestination(BrokerAdmin.TEST_QUEUE_NAME).transferBody(messageContent).transferHeader(null, messageProperties).transferId(3).transfer().session().flushCompleted().flush().consumeResponse().getLatestResponse(SessionCompleted.class);
        MessageTransfer transfer = consumeResponse(interaction, MessageTransfer.class, SessionCompleted.class, SessionCommandPoint.class, SessionConfirmed.class);
        assertThat(transfer.getBodySize(), is(equalTo(messageContent.length)));
        QpidByteBuffer receivedBody = transfer.getBody();
        byte[] receivedBytes = new byte[receivedBody.remaining()];
        receivedBody.get(receivedBytes);
        assertThat(receivedBytes, is(equalTo(messageContent)));
    }
}
Also used : MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) ConnectionTune(org.apache.qpid.server.protocol.v0_10.transport.ConnectionTune) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) ConnectionStart(org.apache.qpid.server.protocol.v0_10.transport.ConnectionStart) MessageTransfer(org.apache.qpid.server.protocol.v0_10.transport.MessageTransfer) Test(org.junit.Test)

Example 10 with MessageProperties

use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.

the class PropertyConverter_0_10_to_1_0Test method testQpidSubjectTakesPrecedenceOverJmsType.

public void testQpidSubjectTakesPrecedenceOverJmsType() {
    final String jmsType = "test-jms-type";
    final String qpidSubjectType = "test-qpid-type";
    final Map<String, Object> headers = new HashMap<>();
    headers.put("x-jms-type", jmsType);
    headers.put("qpid.subject", qpidSubjectType);
    final MessageProperties messageProperties = new MessageProperties();
    messageProperties.setApplicationHeaders(headers);
    MessageTransferMessage message = createTestMessage(messageProperties);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertEquals("Unexpected subject", qpidSubjectType, properties.getSubject());
    Map<String, Object> applicationProperties = convertedMessage.getApplicationPropertiesSection().getValue();
    assertTrue("Unexpected entries in application properties", applicationProperties.isEmpty());
}
Also used : HashMap(java.util.HashMap) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)

Aggregations

MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)121 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)90 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)63 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)45 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)44 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)39 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)37 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)31 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)24 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)20 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)18 Matchers.anyString (org.mockito.Matchers.anyString)15 HashMap (java.util.HashMap)10 UUID (java.util.UUID)10 Header (org.apache.qpid.server.protocol.v0_10.transport.Header)10 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)9 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)8 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)7 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)6 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)5