@Override Destination destination(Message message) { try { return message.getJMSDestination(); } catch (JMSException ignored) { // don't crash on wonky exceptions! } return null; }
@Override Destination destination(Message message) { try { Destination result = message.getJMSDestination(); if (result != null) return result; return delegate.getDestination(); } catch (JMSException ignored) { // don't crash on wonky exceptions! } return null; }
void tagQueueOrTopic(Message message, SpanCustomizer span) { try { Destination destination = message.getJMSDestination(); if (destination != null) tagQueueOrTopic(destination, span); } catch (JMSException e) { // don't crash on wonky exceptions! } }
public void updateState(List<TridentTuple> tuples, TridentCollector collector) throws JMSException { try { for (TridentTuple tuple : tuples) { Message msg = this.options.msgProducer.toMessage(this.session, tuple); if (msg != null) { if (msg.getJMSDestination() != null) { this.messageProducer.send(msg.getJMSDestination(), msg); } else { this.messageProducer.send(msg); } } } } catch (JMSException e) { LOG.warn("Failed to send jmd message for a trident batch ", e); if (this.options.jmsTransactional) { session.rollback(); } throw new FailedException("Failed to write tuples", e); } }
throw new MessageConversionException( "Could not find type id property [" + this.typeIdPropertyName + "] on message [" + message.getJMSMessageID() + "] from destination [" + message.getJMSDestination() + "]");
Message msg = this.producer.toMessage(this.session, input); if (msg != null) { if (msg.getJMSDestination() != null) { this.messageProducer.send(msg.getJMSDestination(), msg); } else { this.messageProducer.send(msg);
sbuf.append(m.getJMSDestination());
Destination destination = jmsMessage.getJMSDestination(); if (destination != null) { headers.put(JmsHeaders.DESTINATION, destination);
private Map<String, String> extractMessageHeaders(final Message message) throws JMSException { final Map<String, String> messageHeaders = new HashMap<>(); messageHeaders.put(JmsHeaders.DELIVERY_MODE, String.valueOf(message.getJMSDeliveryMode())); messageHeaders.put(JmsHeaders.EXPIRATION, String.valueOf(message.getJMSExpiration())); messageHeaders.put(JmsHeaders.PRIORITY, String.valueOf(message.getJMSPriority())); messageHeaders.put(JmsHeaders.REDELIVERED, String.valueOf(message.getJMSRedelivered())); messageHeaders.put(JmsHeaders.TIMESTAMP, String.valueOf(message.getJMSTimestamp())); messageHeaders.put(JmsHeaders.CORRELATION_ID, message.getJMSCorrelationID()); messageHeaders.put(JmsHeaders.MESSAGE_ID, message.getJMSMessageID()); messageHeaders.put(JmsHeaders.TYPE, message.getJMSType()); String replyToDestinationName = this.retrieveDestinationName(message.getJMSReplyTo(), JmsHeaders.REPLY_TO); if (replyToDestinationName != null) { messageHeaders.put(JmsHeaders.REPLY_TO, replyToDestinationName); } String destinationName = this.retrieveDestinationName(message.getJMSDestination(), JmsHeaders.DESTINATION); if (destinationName != null) { messageHeaders.put(JmsHeaders.DESTINATION, destinationName); } return messageHeaders; }
attributes.put(ATTRIBUTE_PREFIX + JMS_CORRELATION_ID, message.getJMSCorrelationID()); if (message.getJMSDestination() != null) { String destinationName; if (message.getJMSDestination() instanceof Queue) { destinationName = ((Queue) message.getJMSDestination()).getQueueName(); } else { destinationName = ((Topic) message.getJMSDestination()).getTopicName();
setJMSDestination(foreign.getJMSDestination()); setJMSDeliveryMode(foreign.getJMSDeliveryMode()); setJMSExpiration(foreign.getJMSExpiration());
/** * Copies the standard JMS and user defined properties from the givem * message to the specified message * * @param fromMessage the message to take the properties from * @param toMessage the message to add the properties to * @throws JMSException */ public static void copyProperties(Message fromMessage, Message toMessage) throws JMSException { toMessage.setJMSMessageID(fromMessage.getJMSMessageID()); toMessage.setJMSCorrelationID(fromMessage.getJMSCorrelationID()); toMessage.setJMSReplyTo(transformDestination(fromMessage.getJMSReplyTo())); toMessage.setJMSDestination(transformDestination(fromMessage.getJMSDestination())); toMessage.setJMSDeliveryMode(fromMessage.getJMSDeliveryMode()); toMessage.setJMSRedelivered(fromMessage.getJMSRedelivered()); toMessage.setJMSType(fromMessage.getJMSType()); toMessage.setJMSExpiration(fromMessage.getJMSExpiration()); toMessage.setJMSPriority(fromMessage.getJMSPriority()); toMessage.setJMSTimestamp(fromMessage.getJMSTimestamp()); Enumeration propertyNames = fromMessage.getPropertyNames(); while (propertyNames.hasMoreElements()) { String name = propertyNames.nextElement().toString(); Object obj = fromMessage.getObjectProperty(name); toMessage.setObjectProperty(name, obj); } } }
@Test public void jmsReadOnlyPropertiesNotMapped() throws JMSException { Message<String> message = initBuilder() .setHeader(JmsHeaders.DESTINATION, new Destination() {}) .setHeader(JmsHeaders.DELIVERY_MODE, DeliveryMode.NON_PERSISTENT) .setHeader(JmsHeaders.EXPIRATION, 1000L) .setHeader(JmsHeaders.MESSAGE_ID, "abc-123") .setHeader(JmsHeaders.PRIORITY, 9) .setHeader(JmsHeaders.REDELIVERED, true) .setHeader(JmsHeaders.TIMESTAMP, System.currentTimeMillis()) .build(); javax.jms.Message jmsMessage = new StubTextMessage(); mapper.fromHeaders(message.getHeaders(), jmsMessage); assertNull(jmsMessage.getJMSDestination()); assertEquals(DeliveryMode.PERSISTENT, jmsMessage.getJMSDeliveryMode()); assertEquals(0, jmsMessage.getJMSExpiration()); assertNull(jmsMessage.getJMSMessageID()); assertEquals(javax.jms.Message.DEFAULT_PRIORITY, jmsMessage.getJMSPriority()); assertFalse(jmsMessage.getJMSRedelivered()); assertEquals(0, jmsMessage.getJMSTimestamp()); }
sbuf.append(m.getJMSDestination());
Destination destination = jmsMessage.getJMSDestination(); if (destination != null) { headers.put(JmsHeaders.DESTINATION, destination);
/** * INTERNAL: */ protected String logDebugJMSTopic(Message message) throws JMSException { String topic = ((Topic)message.getJMSDestination()).getTopicName(); Object[] args = { topic }; // call logDebugWithoutLevelCheck to avoid the second rcm.shouldLogDebugMessage() check rcm.logDebugWithoutLevelCheck("retreived_remote_message_from_JMS_topic", args); return topic; }
/** * INTERNAL: */ protected String logDebugJMSTopic(Message message) throws JMSException { String topic = ((Topic)message.getJMSDestination()).getTopicName(); Object[] args = { topic }; // call logDebugWithoutLevelCheck to avoid the second rcm.shouldLogDebugMessage() check rcm.logDebugWithoutLevelCheck("retreived_remote_message_from_JMS_topic", args); return topic; }
@Test public void testJMSDestination() throws Exception { queueProducer.send(queueProducerSession.createMessage()); Message m = queueConsumer.receive(); ProxyAssertSupport.assertEquals(queue1, m.getJMSDestination()); }
@Test public void testClearMessage() throws Exception { queueProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); Message message = queueProducerSession.createTextMessage("some message"); queueProducer.send(message); message = queueConsumer.receive(1000); ProxyAssertSupport.assertNotNull(message); message.clearProperties(); ProxyAssertSupport.assertNotNull(message.getJMSDestination()); }
@Test public void testForeignJMSDestination() throws JMSException { Message message = queueProducerSession.createMessage(); Destination foreignDestination = new ForeignDestination(); message.setJMSDestination(foreignDestination); ProxyAssertSupport.assertSame(foreignDestination, message.getJMSDestination()); queueProducer.send(message); ProxyAssertSupport.assertSame(queue1, message.getJMSDestination()); Message receivedMessage = queueConsumer.receive(2000); MessageHeaderTestBase.ensureEquivalent(receivedMessage, (ActiveMQMessage) message); }