Here are the examples of the java api class org.apache.activemq.ActiveMQMessageProducer taken from open source projects.
1. GeneralInteropTest#sendMapMessageUsingOpenWire()
Project: activemq-artemis
File: GeneralInteropTest.java
File: GeneralInteropTest.java
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); }
2. GeneralInteropTest#sendStreamMessageUsingOpenWire()
Project: activemq-artemis
File: GeneralInteropTest.java
File: GeneralInteropTest.java
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); }
3. GeneralInteropTest#sendBytesMessageUsingOpenWire()
Project: activemq-artemis
File: GeneralInteropTest.java
File: GeneralInteropTest.java
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); }
4. GeneralInteropTest#sendMessageUsingOpenWire()
Project: activemq-artemis
File: GeneralInteropTest.java
File: GeneralInteropTest.java
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); }
5. CompressedInteropTest#sendCompressedMapMessageUsingOpenWire()
Project: activemq-artemis
File: CompressedInteropTest.java
File: CompressedInteropTest.java
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); }
6. CompressedInteropTest#sendCompressedStreamMessageUsingOpenWire()
Project: activemq-artemis
File: CompressedInteropTest.java
File: CompressedInteropTest.java
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); }
7. GeneralInteropTest#sendTextMessageUsingOpenWire()
Project: activemq-artemis
File: GeneralInteropTest.java
File: GeneralInteropTest.java
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); }
8. GeneralInteropTest#sendObjectMessageUsingOpenWire()
Project: activemq-artemis
File: GeneralInteropTest.java
File: GeneralInteropTest.java
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); }
9. CompressedInteropTest#sendCompressedTextMessageUsingOpenWire()
Project: activemq-artemis
File: CompressedInteropTest.java
File: CompressedInteropTest.java
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. CompressedInteropTest#sendCompressedBytesMessageUsingOpenWire()
Project: activemq-artemis
File: CompressedInteropTest.java
File: CompressedInteropTest.java
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); }
11. CompressedInteropTest#sendCompressedObjectMessageUsingOpenWire()
Project: activemq-artemis
File: CompressedInteropTest.java
File: CompressedInteropTest.java
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); }
12. GeneralInteropTest#sendMultipleTextMessagesUsingOpenWire()
Project: activemq-artemis
File: GeneralInteropTest.java
File: GeneralInteropTest.java
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); } }