Java Code Examples for javax.jms.ObjectMessage#setObjectProperty()
The following examples show how to use
javax.jms.ObjectMessage#setObjectProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JMSCacheableMailQueue.java From james-project with Apache License 2.0 | 6 votes |
/** * Produce the mail to the JMS Queue */ protected void produceMail(Map<String, Object> props, int msgPrio, Mail mail) throws JMSException, MessagingException, IOException { ObjectMessage message = session.createObjectMessage(); for (Map.Entry<String, Object> entry : props.entrySet()) { message.setObjectProperty(entry.getKey(), entry.getValue()); } long size = mail.getMessageSize(); ByteArrayOutputStream out; if (size > -1) { out = new ByteArrayOutputStream((int) size); } else { out = new ByteArrayOutputStream(); } mail.getMessage().writeTo(out); // store the byte array in a ObjectMessage so we can use a // SharedByteArrayInputStream later // without the need of copy the day message.setObject(out.toByteArray()); producer.send(message, Message.DEFAULT_DELIVERY_MODE, msgPrio, Message.DEFAULT_TIME_TO_LIVE); }
Example 2
Source File: ObjectMessageTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void testSetObjectPropertyForString() throws Exception { Queue queue = createQueue(getTestName()); Connection connection = getConnection(); String testStringProperty = "TestStringProperty"; try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ObjectMessage msg = session.createObjectMessage("test"); msg.setObjectProperty("TestStringProperty", testStringProperty); assertEquals(testStringProperty, msg.getObjectProperty("TestStringProperty")); MessageProducer producer = session.createProducer(queue); producer.send(msg); MessageConsumer consumer = session.createConsumer(queue); connection.start(); Message receivedMessage = consumer.receive(getReceiveTimeout()); assertTrue("ObjectMessage should be received", receivedMessage instanceof ObjectMessage); assertEquals("Unexpected received property", testStringProperty, receivedMessage.getObjectProperty("TestStringProperty")); } finally { connection.close(); } }
Example 3
Source File: ObjectMessageTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void testSetObjectPropertyForBoolean() throws Exception { Queue queue = createQueue(getTestName()); Connection connection = getConnection(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ObjectMessage msg = session.createObjectMessage("test"); msg.setObjectProperty("TestBooleanProperty", Boolean.TRUE); assertEquals(Boolean.TRUE, msg.getObjectProperty("TestBooleanProperty")); MessageProducer producer = session.createProducer(queue); producer.send(msg); MessageConsumer consumer = session.createConsumer(queue); connection.start(); Message receivedMessage = consumer.receive(getReceiveTimeout()); assertTrue("ObjectMessage should be received", receivedMessage instanceof ObjectMessage); assertEquals("Unexpected received property", Boolean.TRUE, receivedMessage.getObjectProperty("TestBooleanProperty")); } finally { connection.close(); } }
Example 4
Source File: ObjectMessageTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void testSetObjectPropertyForByte() throws Exception { Queue queue = createQueue(getTestName()); Connection connection = getConnection(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ObjectMessage msg = session.createObjectMessage("test"); msg.setObjectProperty("TestByteProperty", Byte.MAX_VALUE); assertEquals(Byte.MAX_VALUE, msg.getObjectProperty("TestByteProperty")); MessageProducer producer = session.createProducer(queue); producer.send(msg); MessageConsumer consumer = session.createConsumer(queue); connection.start(); Message receivedMessage = consumer.receive(getReceiveTimeout()); assertTrue("ObjectMessage should be received", receivedMessage instanceof ObjectMessage); assertEquals("Unexpected received property", Byte.MAX_VALUE, receivedMessage.getObjectProperty("TestByteProperty")); } finally { connection.close(); } }
Example 5
Source File: ObjectMessageTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void testSetObjectPropertyForShort() throws Exception { Queue queue = createQueue(getTestName()); Connection connection = getConnection(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ObjectMessage msg = session.createObjectMessage("test"); msg.setObjectProperty("TestShortProperty", Short.MAX_VALUE); assertEquals(Short.MAX_VALUE, msg.getObjectProperty("TestShortProperty")); MessageProducer producer = session.createProducer(queue); producer.send(msg); MessageConsumer consumer = session.createConsumer(queue); connection.start(); Message receivedMessage = consumer.receive(getReceiveTimeout()); assertTrue("ObjectMessage should be received", receivedMessage instanceof ObjectMessage); assertEquals("Unexpected received property", Short.MAX_VALUE, receivedMessage.getObjectProperty("TestShortProperty")); } finally { connection.close(); } }
Example 6
Source File: ObjectMessageTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void testSetObjectPropertyForInteger() throws Exception { Queue queue = createQueue(getTestName()); Connection connection = getConnection(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ObjectMessage msg = session.createObjectMessage("test"); msg.setObjectProperty("TestIntegerProperty", Integer.MAX_VALUE); assertEquals(Integer.MAX_VALUE, msg.getObjectProperty("TestIntegerProperty")); MessageProducer producer = session.createProducer(queue); producer.send(msg); MessageConsumer consumer = session.createConsumer(queue); connection.start(); Message receivedMessage = consumer.receive(getReceiveTimeout()); assertTrue("ObjectMessage should be received", receivedMessage instanceof ObjectMessage); assertEquals("Unexpected received property", Integer.MAX_VALUE, receivedMessage.getObjectProperty("TestIntegerProperty")); } finally { connection.close(); } }
Example 7
Source File: ObjectMessageTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void testSetObjectPropertyForDouble() throws Exception { Queue queue = createQueue(getTestName()); Connection connection = getConnection(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ObjectMessage msg = session.createObjectMessage("test"); msg.setObjectProperty("TestDoubleProperty", Double.MAX_VALUE); assertEquals(Double.MAX_VALUE, msg.getObjectProperty("TestDoubleProperty")); MessageProducer producer = session.createProducer(queue); producer.send(msg); MessageConsumer consumer = session.createConsumer(queue); connection.start(); Message receivedMessage = consumer.receive(getReceiveTimeout()); assertTrue("ObjectMessage should be received", receivedMessage instanceof ObjectMessage); assertEquals("Unexpected received property", Double.MAX_VALUE, receivedMessage.getObjectProperty("TestDoubleProperty")); } finally { connection.close(); } }
Example 8
Source File: ObjectMessageTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void testSetObjectPropertyForFloat() throws Exception { Queue queue = createQueue(getTestName()); Connection connection = getConnection(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ObjectMessage msg = session.createObjectMessage("test"); msg.setObjectProperty("TestFloatProperty", Float.MAX_VALUE); assertEquals(Float.MAX_VALUE, msg.getObjectProperty("TestFloatProperty")); MessageProducer producer = session.createProducer(queue); producer.send(msg); MessageConsumer consumer = session.createConsumer(queue); connection.start(); Message receivedMessage = consumer.receive(getReceiveTimeout()); assertTrue("ObjectMessage should be received", receivedMessage instanceof ObjectMessage); assertEquals("Unexpected received property", Float.MAX_VALUE, receivedMessage.getObjectProperty("TestFloatProperty")); } finally { connection.close(); } }
Example 9
Source File: SessionCache.java From secure-data-service with Apache License 2.0 | 4 votes |
private ObjectMessage createMessage(String token, OAuth2Authentication auth, String action) throws JMSException { ObjectMessage msg = jmsSession.createObjectMessage(auth); msg.setObjectProperty(ACTION_KEY, action); msg.setStringProperty(TOKEN_KEY, token); return msg; }