Search in sources :

Example 1 with MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType

use of org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testContentEncodingConversion.

public void testContentEncodingConversion() {
    String contentEncoding = "my-test-encoding";
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getEncoding()).thenReturn(contentEncoding);
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Symbol convertedContentEncoding = MessageConverter_from_1_0.getContentEncoding(convertedMessage);
    assertEquals("Unexpected content encoding", contentEncoding, convertedContentEncoding.toString());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Example 2 with MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType

use of org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10 method convertToStoredMessage.

private StoredMessage<MessageMetaData_0_10> convertToStoredMessage(final Message_1_0 serverMsg, final NamedAddressSpace addressSpace) {
    final ConvertedContentAndMimeType convertedContentAndMimeType = getAmqp0xConvertedContentAndMimeType(serverMsg);
    final byte[] convertedContent = convertedContentAndMimeType.getContent();
    final MessageMetaData_0_10 messageMetaData_0_10 = convertMetaData(serverMsg, addressSpace, convertedContentAndMimeType.getMimeType(), convertedContent.length);
    final int metadataSize = messageMetaData_0_10.getStorableSize();
    return new StoredMessage<MessageMetaData_0_10>() {

        @Override
        public MessageMetaData_0_10 getMetaData() {
            return messageMetaData_0_10;
        }

        @Override
        public long getMessageNumber() {
            return serverMsg.getMessageNumber();
        }

        @Override
        public QpidByteBuffer getContent(final int offset, final int length) {
            return QpidByteBuffer.wrap(convertedContent, offset, length);
        }

        @Override
        public int getContentSize() {
            return convertedContent.length;
        }

        @Override
        public int getMetadataSize() {
            return metadataSize;
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }

        @Override
        public boolean isInMemory() {
            return true;
        }

        @Override
        public boolean flowToDisk() {
            return false;
        }

        @Override
        public void reallocate() {
        }
    };
}
Also used : StoredMessage(org.apache.qpid.server.store.StoredMessage) ConvertedContentAndMimeType(org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.ConvertedContentAndMimeType) MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType(org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType) MessageMetaData_0_10(org.apache.qpid.server.protocol.v0_10.MessageMetaData_0_10)

Example 3 with MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType

use of org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_8 method convertToStoredMessage.

private StoredMessage<MessageMetaData> convertToStoredMessage(final Message_1_0 serverMsg, final NamedAddressSpace addressSpace) {
    final ConvertedContentAndMimeType convertedContentAndMimeType = getAmqp0xConvertedContentAndMimeType(serverMsg);
    final byte[] convertedContent = convertedContentAndMimeType.getContent();
    final MessageMetaData messageMetaData_0_8 = convertMetaData(serverMsg, convertedContentAndMimeType.getMimeType(), convertedContent.length, addressSpace);
    final int metadataSize = messageMetaData_0_8.getStorableSize();
    return new StoredMessage<MessageMetaData>() {

        @Override
        public MessageMetaData getMetaData() {
            return messageMetaData_0_8;
        }

        @Override
        public long getMessageNumber() {
            return serverMsg.getMessageNumber();
        }

        @Override
        public QpidByteBuffer getContent(final int offset, final int length) {
            return QpidByteBuffer.wrap(convertedContent, offset, length);
        }

        @Override
        public int getContentSize() {
            return convertedContent.length;
        }

        @Override
        public int getMetadataSize() {
            return metadataSize;
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }

        @Override
        public boolean isInMemory() {
            return true;
        }

        @Override
        public boolean flowToDisk() {
            return false;
        }

        @Override
        public void reallocate() {
        }
    };
}
Also used : MessageMetaData(org.apache.qpid.server.protocol.v0_8.MessageMetaData) StoredMessage(org.apache.qpid.server.store.StoredMessage) ConvertedContentAndMimeType(org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.ConvertedContentAndMimeType) MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType(org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType)

Example 4 with MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType

use of org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType in project qpid-broker-j by apache.

the class MessageConverter_v1_0_to_Internal method getInternalTypeHint.

private static MessageConverter_from_1_0.ContentHint getInternalTypeHint(final Message_1_0 serverMsg) {
    Symbol contentType = MessageConverter_from_1_0.getContentType(serverMsg);
    JmsMessageTypeAnnotation jmsMessageTypeAnnotation = MessageConverter_from_1_0.getJmsMessageTypeAnnotation(serverMsg);
    Class<?> classHint = MessageConverter_from_1_0.getContentTypeClassHint(jmsMessageTypeAnnotation);
    String mimeTypeHint = null;
    if (contentType != null) {
        Class<?> contentTypeClassHint = null;
        String type = contentType.toString();
        if (ConversionUtils.TEXT_CONTENT_TYPES.matcher(type).matches()) {
            contentTypeClassHint = String.class;
        } else if (ConversionUtils.MAP_MESSAGE_CONTENT_TYPES.matcher(type).matches()) {
            contentTypeClassHint = Map.class;
        } else if (ConversionUtils.LIST_MESSAGE_CONTENT_TYPES.matcher(type).matches()) {
            contentTypeClassHint = List.class;
        } else if (ConversionUtils.OBJECT_MESSAGE_CONTENT_TYPES.matcher(type).matches()) {
            contentTypeClassHint = Serializable.class;
        } else if (ConversionUtils.BYTES_MESSAGE_CONTENT_TYPES.matcher(type).matches()) {
            contentTypeClassHint = byte[].class;
        }
        if (classHint == null || classHint == contentTypeClassHint) {
            classHint = contentTypeClassHint;
        }
        mimeTypeHint = contentType.toString();
    }
    return new MessageConverter_from_1_0.ContentHint(classHint, mimeTypeHint);
}
Also used : Serializable(java.io.Serializable) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) Map(java.util.Map)

Example 5 with MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType

use of org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType in project qpid-broker-j by apache.

the class PropertyConverter_Internal_to_v1_0Test method testCorrelationIdUnsignedLongConversion.

public void testCorrelationIdUnsignedLongConversion() {
    final UnsignedLong correlationId = UnsignedLong.valueOf(-1L);
    final AMQMessageHeader header = mock(AMQMessageHeader.class);
    when(header.getCorrelationId()).thenReturn(correlationId.toString());
    InternalMessage originalMessage = createTestMessage(header);
    Message_1_0 convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    Object convertedCorrelationId = MessageConverter_from_1_0.getCorrelationId(convertedMessage);
    assertEquals("Unexpected correlationId", correlationId, convertedCorrelationId);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) UnsignedLong(org.apache.qpid.server.protocol.v1_0.type.UnsignedLong) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader)

Aggregations

AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)5 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)5 UnsignedLong (org.apache.qpid.server.protocol.v1_0.type.UnsignedLong)3 ConvertedContentAndMimeType (org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.ConvertedContentAndMimeType)2 MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType (org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType)2 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)2 StoredMessage (org.apache.qpid.server.store.StoredMessage)2 Serializable (java.io.Serializable)1 Map (java.util.Map)1 MessageMetaData_0_10 (org.apache.qpid.server.protocol.v0_10.MessageMetaData_0_10)1 MessageMetaData (org.apache.qpid.server.protocol.v0_8.MessageMetaData)1 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)1