Search in sources :

Example 6 with DeliveryProperties

use of org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties 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 7 with DeliveryProperties

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

the class PropertyConverter_0_10_to_1_0Test method testExpirationConversion.

public void testExpirationConversion() {
    long timestamp = System.currentTimeMillis();
    int ttl = 100000;
    final long expiration = timestamp + ttl;
    final DeliveryProperties deliveryProperties = new DeliveryProperties();
    deliveryProperties.setExpiration(expiration);
    MessageTransferMessage message = createTestMessage(deliveryProperties, new MessageProperties(), null, timestamp);
    final Message_1_0 convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    Properties properties = convertedMessage.getPropertiesSection().getValue();
    assertNull("Unexpected expiration", properties.getAbsoluteExpiryTime());
    Header header = convertedMessage.getHeaderSection().getValue();
    assertEquals("Unexpected TTL", ttl, header.getTtl().intValue());
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) 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 DeliveryProperties

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

the class PropertyConverter_1_0_to_0_10Test method testToConversionWhenQueueIsSpecified.

public void testToConversionWhenQueueIsSpecified() {
    final String testQueue = "testQueue";
    Properties properties = new Properties();
    properties.setTo(testQueue);
    Message_1_0 message = createTestMessage(properties);
    final Queue<?> queue = mock(Queue.class);
    when(queue.getName()).thenReturn(testQueue);
    when(_namedAddressSpace.getAttainedMessageDestination(testQueue)).thenReturn(queue);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
    assertEquals("Unexpected exchange", "", deliveryProperties.getExchange());
    assertEquals("Unexpected routing key", testQueue, deliveryProperties.getRoutingKey());
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 9 with DeliveryProperties

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

the class PropertyConverter_1_0_to_0_10Test method testToConversionWhenExchangeAndRoutingKeyIsSpecified.

public void testToConversionWhenExchangeAndRoutingKeyIsSpecified() {
    final String testExchange = "testExchange";
    final String testRoutingKey = "testRoutingKey";
    String to = testExchange + "/" + testRoutingKey;
    Properties properties = new Properties();
    properties.setTo(to);
    Message_1_0 message = createTestMessage(properties);
    final Exchange<?> exchange = mock(Exchange.class);
    when(exchange.getName()).thenReturn(testExchange);
    when(_namedAddressSpace.getAttainedMessageDestination(testExchange)).thenReturn(exchange);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
    assertEquals("Unexpected exchange", testExchange, deliveryProperties.getExchange());
    assertEquals("Unexpected routing key", testRoutingKey, deliveryProperties.getRoutingKey());
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)

Example 10 with DeliveryProperties

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

the class PropertyConverter_1_0_to_0_10Test method testAbsoluteExpiryTimeConversion.

public void testAbsoluteExpiryTimeConversion() {
    long ttl = 10000;
    long arrivalTime = System.currentTimeMillis();
    long expiryTime = arrivalTime + ttl;
    Properties properties = new Properties();
    properties.setAbsoluteExpiryTime(new Date(expiryTime));
    Message_1_0 message = createTestMessage(properties, arrivalTime);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
    assertEquals("Unexpected ttl", ttl, deliveryProperties.getTtl());
    assertEquals("Unexpected expiration", expiryTime, deliveryProperties.getExpiration());
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Date(java.util.Date)

Aggregations

DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)81 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)54 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)39 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)27 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)25 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)21 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)20 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)17 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)16 Matchers.anyString (org.mockito.Matchers.anyString)16 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)14 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)14 Header (org.apache.qpid.server.protocol.v0_10.transport.Header)10 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)7 Date (java.util.Date)5 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)5 MessageMetaData_0_10 (org.apache.qpid.server.protocol.v0_10.MessageMetaData_0_10)4 MessageDeliveryMode (org.apache.qpid.server.protocol.v0_10.transport.MessageDeliveryMode)4 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)4 Method (org.apache.qpid.server.protocol.v0_10.transport.Method)3