Search in sources :

Example 6 with ServerJMSObjectMessage

use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage in project activemq-artemis by apache.

the class JMSMappingOutboundTransformerTest method testConvertObjectMessageToAmqpMessageUnknownEncodingGetsDataSection.

@Test
public void testConvertObjectMessageToAmqpMessageUnknownEncodingGetsDataSection() throws Exception {
    ServerJMSObjectMessage outbound = createObjectMessage(TEST_OBJECT_VALUE);
    outbound.encode();
    Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
    assertNotNull(amqp.getBody());
    assertTrue(amqp.getBody() instanceof Data);
    assertFalse(0 == ((Data) amqp.getBody()).getValue().getLength());
    Object value = deserialize(((Data) amqp.getBody()).getValue().getArray());
    assertNotNull(value);
    assertTrue(value instanceof UUID);
}
Also used : CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Data(org.apache.qpid.proton.amqp.messaging.Data) UUID(java.util.UUID) Test(org.junit.Test)

Example 7 with ServerJMSObjectMessage

use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage in project activemq-artemis by apache.

the class AMQPMessageSupport method createObjectMessage.

public static ServerJMSMessage createObjectMessage(long id, byte[] array, int offset, int length, CoreMessageObjectPools coreMessageObjectPools) throws JMSException {
    ServerJMSObjectMessage message = createObjectMessage(id, coreMessageObjectPools);
    message.setSerializedForm(new Binary(array, offset, length));
    return message;
}
Also used : ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Binary(org.apache.qpid.proton.amqp.Binary)

Example 8 with ServerJMSObjectMessage

use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage in project activemq-artemis by apache.

the class JMSMappingOutboundTransformerTest method testConvertEmptyObjectMessageToAmqpMessageWithDataBody.

// ----- ObjectMessage type tests -----------------------------------------//
@Test
public void testConvertEmptyObjectMessageToAmqpMessageWithDataBody() throws Exception {
    ServerJMSObjectMessage outbound = createObjectMessage();
    outbound.encode();
    Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
    assertNotNull(amqp.getBody());
    assertTrue(amqp.getBody() instanceof Data);
    assertEquals(5, ((Data) amqp.getBody()).getValue().getLength());
}
Also used : CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Data(org.apache.qpid.proton.amqp.messaging.Data) Test(org.junit.Test)

Example 9 with ServerJMSObjectMessage

use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage in project activemq-artemis by apache.

the class JMSMappingOutboundTransformerTest method createObjectMessage.

private ServerJMSObjectMessage createObjectMessage(Serializable payload, boolean compression) {
    ServerJMSObjectMessage result = AMQPMessageSupport.createObjectMessage(0, null);
    if (compression) {
    // TODO
    }
    try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        oos.writeObject(payload);
        byte[] data = baos.toByteArray();
        result.setSerializedForm(new Binary(data));
    } catch (Exception ex) {
        throw new AssertionError("Should not fail to setObject in this test");
    }
    return result;
}
Also used : ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Binary(org.apache.qpid.proton.amqp.Binary) ObjectOutputStream(java.io.ObjectOutputStream) JMSException(javax.jms.JMSException)

Example 10 with ServerJMSObjectMessage

use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage in project activemq-artemis by apache.

the class AMQPMessageSupport method createObjectMessage.

public static ServerJMSMessage createObjectMessage(long id, Binary serializedForm, CoreMessageObjectPools coreMessageObjectPools) throws JMSException {
    ServerJMSObjectMessage message = createObjectMessage(id, coreMessageObjectPools);
    message.setSerializedForm(serializedForm);
    return message;
}
Also used : ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage)

Aggregations

ServerJMSObjectMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage)11 ServerJMSBytesMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage)8 ServerJMSMapMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage)8 ServerJMSMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage)8 ServerJMSStreamMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage)8 ServerJMSTextMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage)8 Data (org.apache.qpid.proton.amqp.messaging.Data)8 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)7 Message (org.apache.qpid.proton.message.Message)7 Test (org.junit.Test)7 UUID (java.util.UUID)5 Binary (org.apache.qpid.proton.amqp.Binary)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 ArrayList (java.util.ArrayList)1 JMSException (javax.jms.JMSException)1 MessageEOFException (javax.jms.MessageEOFException)1 ICoreMessage (org.apache.activemq.artemis.api.core.ICoreMessage)1 AmqpSequence (org.apache.qpid.proton.amqp.messaging.AmqpSequence)1 AmqpValue (org.apache.qpid.proton.amqp.messaging.AmqpValue)1