Search in sources :

Example 1 with ActiveMQMessageProducer

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

the class GeneralInteropTest method sendBytesMessageUsingOpenWire.

private void sendBytesMessageUsingOpenWire(byte[] bytesData) 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);
    BytesMessage bytesMessage = session.createBytesMessage();
    bytesMessage.writeBytes(bytesData);
    bytesMessage.writeBoolean(true);
    bytesMessage.writeLong(99999L);
    bytesMessage.writeChar('h');
    bytesMessage.writeInt(987);
    bytesMessage.writeShort((short) 1099);
    bytesMessage.writeUTF("hellobytes");
    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 2 with ActiveMQMessageProducer

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

the class GeneralInteropTest method sendObjectMessageUsingOpenWire.

private void sendObjectMessageUsingOpenWire(SimpleSerializable obj) 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);
    ObjectMessage objectMessage = session.createObjectMessage(obj);
    producer.send(objectMessage);
}
Also used : ObjectMessage(javax.jms.ObjectMessage) ActiveMQMessageProducer(org.apache.activemq.ActiveMQMessageProducer) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 3 with ActiveMQMessageProducer

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

the class GeneralInteropTest method sendMultipleTextMessagesUsingOpenWire.

private void sendMultipleTextMessagesUsingOpenWire(String text, int num) throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
    for (int i = 0; i < num; i++) {
        TextMessage textMessage = session.createTextMessage(text + i);
        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 4 with ActiveMQMessageProducer

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

the class GeneralInteropTest method sendMapMessageUsingOpenWire.

private void sendMapMessageUsingOpenWire() 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);
    MapMessage mapMessage = session.createMapMessage();
    mapMessage.setBoolean("aboolean", true);
    mapMessage.setByte("abyte", (byte) 4);
    mapMessage.setBytes("abytes", new byte[] { 4, 5 });
    mapMessage.setChar("achar", 'a');
    mapMessage.setDouble("adouble", 4.4);
    mapMessage.setFloat("afloat", 4.5f);
    mapMessage.setInt("aint", 40);
    mapMessage.setLong("along", 80L);
    mapMessage.setShort("ashort", (short) 65);
    mapMessage.setString("astring", "hello");
    producer.send(mapMessage);
}
Also used : ActiveMQMessageProducer(org.apache.activemq.ActiveMQMessageProducer) MapMessage(javax.jms.MapMessage) Session(javax.jms.Session) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 5 with ActiveMQMessageProducer

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

the class GeneralInteropTest method sendMessageUsingOpenWire.

private void sendMessageUsingOpenWire(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);
    javax.jms.Message message = session.createMessage();
    message.setBooleanProperty("booleanProperty", false);
    message.setLongProperty("longProperty", 99999L);
    message.setByteProperty("byteProperty", (byte) 5);
    message.setIntProperty("intProperty", 979);
    message.setShortProperty("shortProperty", (short) 1099);
    message.setStringProperty("stringProperty", "HelloMessage");
    producer.send(message);
}
Also used : ActiveMQMessageProducer(org.apache.activemq.ActiveMQMessageProducer) 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