org.apache.activemq.ActiveMQMessageProducer

Here are the examples of the java api class org.apache.activemq.ActiveMQMessageProducer taken from open source projects.

1. CompressedInteropTest#sendCompressedStreamMessageUsingOpenWire()

View license
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);
}

2. CompressedInteropTest#sendCompressedMapMessageUsingOpenWire()

View license
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);
}

3. GeneralInteropTest#sendMessageUsingOpenWire()

View license
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);
}

4. GeneralInteropTest#sendBytesMessageUsingOpenWire()

View license
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);
}

5. GeneralInteropTest#sendStreamMessageUsingOpenWire()

View license
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);
}

6. GeneralInteropTest#sendMapMessageUsingOpenWire()

View license
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);
}

7. CompressedInteropTest#sendCompressedObjectMessageUsingOpenWire()

View license
private void sendCompressedObjectMessageUsingOpenWire() throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
    ObjectMessage objectMessage = session.createObjectMessage();
    objectMessage.setObject(TEXT);
    producer.send(objectMessage);
}

8. CompressedInteropTest#sendCompressedBytesMessageUsingOpenWire()

View license
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);
}

9. CompressedInteropTest#sendCompressedTextMessageUsingOpenWire()

View license
private void sendCompressedTextMessageUsingOpenWire() 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);
}

10. GeneralInteropTest#sendObjectMessageUsingOpenWire()

View license
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);
}

11. GeneralInteropTest#sendTextMessageUsingOpenWire()

View license
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);
}

12. GeneralInteropTest#sendMultipleTextMessagesUsingOpenWire()

View license
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);
    }
}