Search in sources :

Example 6 with ActiveMQMessageProducer

use of org.apache.activemq.ActiveMQMessageProducer in project activemq-artemis by apache.

the class GeneralInteropTest method sendStreamMessageUsingOpenWire.

private void sendStreamMessageUsingOpenWire(String queueName) throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    System.out.println("destination: " + destination);
    final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
    StreamMessage streamMessage = session.createStreamMessage();
    streamMessage.writeBoolean(true);
    streamMessage.writeByte((byte) 2);
    streamMessage.writeBytes(new byte[] { 6, 7 });
    streamMessage.writeChar('b');
    streamMessage.writeDouble(6.5);
    streamMessage.writeFloat((float) 93.9);
    streamMessage.writeInt(7657);
    streamMessage.writeLong(239999L);
    streamMessage.writeShort((short) 34222);
    streamMessage.writeString("hello streammessage");
    producer.send(streamMessage);
}
Also used : ActiveMQMessageProducer(org.apache.activemq.ActiveMQMessageProducer) StreamMessage(javax.jms.StreamMessage) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 7 with ActiveMQMessageProducer

use of org.apache.activemq.ActiveMQMessageProducer in project activemq-artemis by apache.

the class GeneralInteropTest method sendTextMessageUsingOpenWire.

private void sendTextMessageUsingOpenWire(String text) throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
    TextMessage textMessage = session.createTextMessage(text);
    producer.send(textMessage);
}
Also used : ActiveMQMessageProducer(org.apache.activemq.ActiveMQMessageProducer) TextMessage(javax.jms.TextMessage) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 8 with ActiveMQMessageProducer

use of org.apache.activemq.ActiveMQMessageProducer in project activemq-artemis by apache.

the class CompressedInteropTest method sendCompressedStreamMessageUsingOpenWire.

private void sendCompressedStreamMessageUsingOpenWire() throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
    StreamMessage streamMessage = session.createStreamMessage();
    streamMessage.writeBoolean(true);
    streamMessage.writeByte((byte) 10);
    streamMessage.writeBytes(TEXT.getBytes());
    streamMessage.writeChar('A');
    streamMessage.writeDouble(55.3D);
    streamMessage.writeFloat(79.1F);
    streamMessage.writeInt(37);
    streamMessage.writeLong(56652L);
    streamMessage.writeObject(new String("VVVV"));
    streamMessage.writeShort((short) 333);
    streamMessage.writeString(TEXT);
    producer.send(streamMessage);
}
Also used : ActiveMQMessageProducer(org.apache.activemq.ActiveMQMessageProducer) StreamMessage(javax.jms.StreamMessage) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 9 with ActiveMQMessageProducer

use of org.apache.activemq.ActiveMQMessageProducer in project activemq-artemis by apache.

the class CompressedInteropTest method sendCompressedBytesMessageUsingOpenWire.

private void sendCompressedBytesMessageUsingOpenWire() throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
    BytesMessage bytesMessage = session.createBytesMessage();
    bytesMessage.writeBytes(TEXT.getBytes());
    producer.send(bytesMessage);
}
Also used : ActiveMQMessageProducer(org.apache.activemq.ActiveMQMessageProducer) BytesMessage(javax.jms.BytesMessage) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 10 with ActiveMQMessageProducer

use of org.apache.activemq.ActiveMQMessageProducer in project activemq-artemis by apache.

the class CompressedInteropTest method sendCompressedMapMessageUsingOpenWire.

private void sendCompressedMapMessageUsingOpenWire() throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
    MapMessage mapMessage = session.createMapMessage();
    mapMessage.setBoolean("boolean-type", true);
    mapMessage.setByte("byte-type", (byte) 10);
    mapMessage.setBytes("bytes-type", TEXT.getBytes());
    mapMessage.setChar("char-type", 'A');
    mapMessage.setDouble("double-type", 55.3D);
    mapMessage.setFloat("float-type", 79.1F);
    mapMessage.setInt("int-type", 37);
    mapMessage.setLong("long-type", 56652L);
    mapMessage.setObject("object-type", new String("VVVV"));
    mapMessage.setShort("short-type", (short) 333);
    mapMessage.setString("string-type", TEXT);
    producer.send(mapMessage);
}
Also used : ActiveMQMessageProducer(org.apache.activemq.ActiveMQMessageProducer) MapMessage(javax.jms.MapMessage) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Aggregations

Session (javax.jms.Session)12 ActiveMQMessageProducer (org.apache.activemq.ActiveMQMessageProducer)12 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)12 TextMessage (javax.jms.TextMessage)3 BytesMessage (javax.jms.BytesMessage)2 MapMessage (javax.jms.MapMessage)2 ObjectMessage (javax.jms.ObjectMessage)2 StreamMessage (javax.jms.StreamMessage)2