Java Code Examples for javax.jms.Message#setJMSCorrelationIDAsBytes()
The following examples show how to use
javax.jms.Message#setJMSCorrelationIDAsBytes() .
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: MockJMSProducer.java From pooled-jms with Apache License 2.0 | 6 votes |
private void doSend(Destination destination, Message message) throws JMSException { if (message == null) { throw new MessageFormatException("Message must not be null"); } for (Map.Entry<String, Object> entry : messageProperties.entrySet()) { message.setObjectProperty(entry.getKey(), entry.getValue()); } if (correlationId != null) { message.setJMSCorrelationID(correlationId); } if (correlationIdBytes != null) { message.setJMSCorrelationIDAsBytes(correlationIdBytes); } if (type != null) { message.setJMSType(type); } if (replyTo != null) { message.setJMSReplyTo(replyTo); } session.send(producer, destination, message, deliveryMode, priority, timeToLive, disableMessageId, disableTimestamp, deliveryDelay, completionListener); }
Example 2
Source File: Client.java From qpid-broker-j with Apache License 2.0 | 6 votes |
private void sendReply(final Session session, final Destination jmsReplyTo, final Serializable correlationId) throws JMSException { final Message replyToMessage = session.createMessage(); if (correlationId != null) { if (correlationId instanceof byte[]) { replyToMessage.setJMSCorrelationIDAsBytes((byte[]) correlationId); } else { replyToMessage.setJMSCorrelationID((String) correlationId); } } System.out.println(String.format("Sending reply message: %s", replyToMessage)); MessageProducer producer = session.createProducer(jmsReplyTo); try { producer.send(replyToMessage); } finally { producer.close(); } }
Example 3
Source File: JmsProducer.java From qpid-jms with Apache License 2.0 | 6 votes |
private void doSend(Destination destination, Message message) throws JMSException { if (message == null) { throw new MessageFormatException("Message must not be null"); } for (Map.Entry<String, Object> entry : messageProperties.entrySet()) { message.setObjectProperty(entry.getKey(), entry.getValue()); } if (correlationId != null) { message.setJMSCorrelationID(correlationId); } if (correlationIdBytes != null) { message.setJMSCorrelationIDAsBytes(correlationIdBytes); } if (type != null) { message.setJMSType(type); } if (replyTo != null) { message.setJMSReplyTo(replyTo); } session.send(producer, destination, message, deliveryMode, priority, timeToLive, disableMessageId, disableTimestamp, deliveryDelay, completionListener); }
Example 4
Source File: JmsPoolJMSProducer.java From pooled-jms with Apache License 2.0 | 5 votes |
private void doSend(Destination destination, Message message) throws JMSException { if (message == null) { throw new MessageFormatException("Message must not be null"); } for (Map.Entry<String, Object> entry : messageProperties.entrySet()) { message.setObjectProperty(entry.getKey(), entry.getValue()); } if (correlationId != null) { message.setJMSCorrelationID(correlationId); } if (correlationIdBytes != null) { message.setJMSCorrelationIDAsBytes(correlationIdBytes); } if (type != null) { message.setJMSType(type); } if (replyTo != null) { message.setJMSReplyTo(replyTo); } if (completionListener != null) { producer.send(destination, message, deliveryMode, priority, timeToLive, completionListener); } else { producer.send(destination, message, deliveryMode, priority, timeToLive); } }
Example 5
Source File: AmqpManagementTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Test public void testGetTypesOnVirtualHostManagement() throws Exception { assumeThat(isSupportedClient(), is(true)); Connection connection = getConnection(); try { setUp(connection); Message message = _session.createBytesMessage(); message.setStringProperty("identity", "self"); message.setStringProperty("type", "org.amqp.management"); message.setStringProperty("operation", "GET-TYPES"); String correlationID = "some correlation id"; message.setJMSCorrelationIDAsBytes(correlationID.getBytes(UTF_8)); message.setJMSReplyTo(_replyAddress); _producer.send(message); Message responseMessage = _consumer.receive(getReceiveTimeout()); assertNotNull("A response message was not sent", responseMessage); assertEquals("The correlation id does not match the sent message's correlationId", correlationID, responseMessage.getJMSCorrelationID()); assertResponseCode(responseMessage, 200); assertNotNull("The response did not include the org.amqp.Management type", getValueFromMapResponse(responseMessage,"org.amqp.management")); assertNull("The response included the org.apache.qpid.Port type", getValueFromMapResponse(responseMessage,"org.apache.qpid.Port")); } finally { connection.close(); } }
Example 6
Source File: JMSCorrelationIDHeaderTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test public void testJMSDestination() throws Exception { Message m1 = queueProducerSession.createMessage(); // Test with correlation id containing a message id final String messageID = "ID:812739812378"; m1.setJMSCorrelationID(messageID); queueProducer.send(m1); Message m2 = queueConsumer.receive(); ProxyAssertSupport.assertEquals(messageID, m2.getJMSCorrelationID()); // Test with correlation id containing an application defined string Message m3 = queueProducerSession.createMessage(); final String appDefinedID = "oiwedjiwjdoiwejdoiwjd"; m3.setJMSCorrelationID(appDefinedID); queueProducer.send(m3); Message m4 = queueConsumer.receive(); ProxyAssertSupport.assertEquals(appDefinedID, m4.getJMSCorrelationID()); // Test with correlation id containing a byte[] Message m5 = queueProducerSession.createMessage(); final byte[] bytes = new byte[]{-111, 45, 106, 3, -44}; m5.setJMSCorrelationIDAsBytes(bytes); queueProducer.send(m5); Message m6 = queueConsumer.receive(); assertByteArraysEqual(bytes, m6.getJMSCorrelationIDAsBytes()); }
Example 7
Source File: ActiveMQJMSProducer.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public JMSProducer send(Destination destination, Message message) { if (message == null) { throw new MessageFormatRuntimeException("null message"); } try { if (jmsHeaderCorrelationID != null) { message.setJMSCorrelationID(jmsHeaderCorrelationID); } if (jmsHeaderCorrelationIDAsBytes != null && jmsHeaderCorrelationIDAsBytes.length > 0) { message.setJMSCorrelationIDAsBytes(jmsHeaderCorrelationIDAsBytes); } if (jmsHeaderReplyTo != null) { message.setJMSReplyTo(jmsHeaderReplyTo); } if (jmsHeaderType != null) { message.setJMSType(jmsHeaderType); } // XXX HORNETQ-1209 "JMS 2.0" can this be a foreign msg? // if so, then "SimpleString" properties will trigger an error. setProperties(message); if (completionListener != null) { CompletionListener wrapped = new CompletionListenerWrapper(completionListener); producer.send(destination, message, wrapped); } else { producer.send(destination, message); } } catch (JMSException e) { throw JmsExceptionUtils.convertToRuntimeException(e); } return this; }
Example 8
Source File: JMSProducerImpl.java From tomee with Apache License 2.0 | 5 votes |
@Override public JMSProducer send(final Destination destination, final Message message) { if (message == null) { throw new MessageFormatRuntimeException("null message"); } try { if (jmsHeaderCorrelationID != null) { message.setJMSCorrelationID(jmsHeaderCorrelationID); } if (jmsHeaderCorrelationIDAsBytes != null && jmsHeaderCorrelationIDAsBytes.length > 0) { message.setJMSCorrelationIDAsBytes(jmsHeaderCorrelationIDAsBytes); } if (jmsHeaderReplyTo != null) { message.setJMSReplyTo(jmsHeaderReplyTo); } if (jmsHeaderType != null) { message.setJMSType(jmsHeaderType); } setProperties(message); if (completionListener != null) { producer.send(destination, message, completionListener); } else { producer.send(destination, message); } } catch (final JMSException e) { throw toRuntimeException(e); } return this; }
Example 9
Source File: MessageCreator.java From qpid-broker-j with Apache License 2.0 | 4 votes |
private static void setJmsHeader(final MessageDescription messageDescription, final Message message) throws JMSException { final HashMap<MessageDescription.MessageHeader, Serializable> header = messageDescription.getHeaders(); if (header == null) { return; } for (Map.Entry<MessageDescription.MessageHeader, Serializable> entry : header.entrySet()) { try { switch (entry.getKey()) { case DESTINATION: message.setJMSDestination((Destination) entry.getValue()); break; case DELIVERY_MODE: message.setJMSDeliveryMode((Integer) entry.getValue()); break; case MESSAGE_ID: message.setJMSMessageID((String) entry.getValue()); break; case TIMESTAMP: message.setJMSTimestamp((Long) entry.getValue()); break; case CORRELATION_ID: if (entry.getValue() instanceof byte[]) { message.setJMSCorrelationIDAsBytes((byte[]) entry.getValue()); } else { message.setJMSCorrelationID((String) entry.getValue()); } break; case REPLY_TO: throw new RuntimeException("The Test should not set the replyTo header." + " It should rather use the dedicated method"); case REDELIVERED: message.setJMSRedelivered((Boolean) entry.getValue()); break; case TYPE: message.setJMSType((String) entry.getValue()); break; case EXPIRATION: message.setJMSExpiration((Long) entry.getValue()); break; case PRIORITY: message.setJMSPriority((Integer) entry.getValue()); break; default: throw new RuntimeException(String.format("unexpected message header '%s'", entry.getKey())); } } catch (ClassCastException e) { throw new RuntimeException(String.format("Could not set message header '%s' to this value: %s", entry.getKey(), entry.getValue()), e); } } }