@Test public void testExceptionThrown() throws Exception { doThrow(new JMSException("expected")) .when(mockMessageProducer).send(any(), any(), any()); try { producer.setPerMessageProperties(false); producer.produce(adaptrisMessage, mockJmsDestination); fail("Should throw produce exception"); } catch (ProduceException ex) { } }
@Override protected void produce(AdaptrisMessage msg, JmsDestination jmsDest) throws JMSException, CoreException { try { setupSession(msg); Message jmsMsg = translate(msg, jmsDest.getReplyToDestination()); jmsMsg.setStringProperty(ID_HEADER, msg.getUniqueId()); if (!perMessageProperties()) { producerSession().getProducer().send(jmsDest.getDestination(), jmsMsg, getEventHandler()); } else { producerSession().getProducer().send(jmsDest.getDestination(), jmsMsg, calculateDeliveryMode(msg, jmsDest.deliveryMode()), calculatePriority(msg, jmsDest.priority()), calculateTimeToLive(msg, jmsDest.timeToLive()), getEventHandler()); } getEventHandler().addUnAckedMessage(jmsMsg.getStringProperty(ID_HEADER), msg); msg.getObjectHeaders().remove(CoreConstants.OBJ_METADATA_ON_SUCCESS_CALLBACK); msg.getObjectHeaders().remove(CoreConstants.OBJ_METADATA_ON_FAILURE_CALLBACK); captureOutgoingMessageDetails(jmsMsg, msg); log.info("msg produced to destination [{}]", jmsDest); } catch (Throwable ex) { ExceptionHelper.rethrowProduceException(ex); } }
JmsAsyncProducer extends JmsProducer { @Override protected void produce(AdaptrisMessage msg, JmsDestination jmsDest) throws JMSException, CoreException { try { setupSession(msg); Message jmsMsg = translate(msg, jmsDest.getReplyToDestination()); jmsMsg.setStringProperty(ID_HEADER, msg.getUniqueId()); if (!perMessageProperties()) { producerSession().getProducer().send(jmsDest.getDestination(), jmsMsg, getEventHandler()); } else { producerSession().getProducer().send(jmsDest.getDestination(), jmsMsg, calculateDeliveryMode(msg, jmsDest.deliveryMode()), calculatePriority(msg, jmsDest.priority()), calculateTimeToLive(msg, jmsDest.timeToLive()), getEventHandler()); } getEventHandler().addUnAckedMessage(jmsMsg.getStringProperty(ID_HEADER), msg); msg.getObjectHeaders().remove(CoreConstants.OBJ_METADATA_ON_SUCCESS_CALLBACK); msg.getObjectHeaders().remove(CoreConstants.OBJ_METADATA_ON_FAILURE_CALLBACK); captureOutgoingMessageDetails(jmsMsg, msg); log.info("msg produced to destination [{}]", jmsDest); } catch (Throwable ex) { ExceptionHelper.rethrowProduceException(ex); } } }
JmsAsyncProducer extends JmsProducer { @Override protected void produce(AdaptrisMessage msg, JmsDestination jmsDest) throws JMSException, CoreException { try { setupSession(msg); Message jmsMsg = translate(msg, jmsDest.getReplyToDestination()); jmsMsg.setStringProperty(ID_HEADER, msg.getUniqueId()); if (!perMessageProperties()) { producerSession().getProducer().send(jmsDest.getDestination(), jmsMsg, getEventHandler()); } else { producerSession().getProducer().send(jmsDest.getDestination(), jmsMsg, calculateDeliveryMode(msg, jmsDest.deliveryMode()), calculatePriority(msg, jmsDest.priority()), calculateTimeToLive(msg, jmsDest.timeToLive()), getEventHandler()); } getEventHandler().addUnAckedMessage(jmsMsg.getStringProperty(ID_HEADER), msg); msg.getObjectHeaders().remove(CoreConstants.OBJ_METADATA_ON_SUCCESS_CALLBACK); msg.getObjectHeaders().remove(CoreConstants.OBJ_METADATA_ON_FAILURE_CALLBACK); captureOutgoingMessageDetails(jmsMsg, msg); log.info("msg produced to destination [{}]", jmsDest); } catch (Throwable ex) { ExceptionHelper.rethrowProduceException(ex); } } JmsAsyncProducer(); }
JmsAsyncProducer extends JmsProducer { @Override protected void produce(AdaptrisMessage msg, JmsDestination jmsDest) throws JMSException, CoreException { try { setupSession(msg); Message jmsMsg = translate(msg, jmsDest.getReplyToDestination()); jmsMsg.setStringProperty(ID_HEADER, msg.getUniqueId()); if (!perMessageProperties()) { producerSession().getProducer().send(jmsDest.getDestination(), jmsMsg, getEventHandler()); } else { producerSession().getProducer().send(jmsDest.getDestination(), jmsMsg, calculateDeliveryMode(msg, jmsDest.deliveryMode()), calculatePriority(msg, jmsDest.priority()), calculateTimeToLive(msg, jmsDest.timeToLive()), getEventHandler()); } getEventHandler().addUnAckedMessage(jmsMsg.getStringProperty(ID_HEADER), msg); msg.getObjectHeaders().remove(CoreConstants.OBJ_METADATA_ON_SUCCESS_CALLBACK); msg.getObjectHeaders().remove(CoreConstants.OBJ_METADATA_ON_FAILURE_CALLBACK); captureOutgoingMessageDetails(jmsMsg, msg); log.info("msg produced to destination [{}]", jmsDest); } catch (Throwable ex) { ExceptionHelper.rethrowProduceException(ex); } } JmsAsyncProducer(); @Override void init(); }
JmsAsyncProducer extends JmsProducer { @Override protected void produce(AdaptrisMessage msg, JmsDestination jmsDest) throws JMSException, CoreException { try { setupSession(msg); Message jmsMsg = translate(msg, jmsDest.getReplyToDestination()); jmsMsg.setStringProperty(ID_HEADER, msg.getUniqueId()); if (!perMessageProperties()) { producerSession().getProducer().send(jmsDest.getDestination(), jmsMsg, getEventHandler()); } else { producerSession().getProducer().send(jmsDest.getDestination(), jmsMsg, calculateDeliveryMode(msg, jmsDest.deliveryMode()), calculatePriority(msg, jmsDest.priority()), calculateTimeToLive(msg, jmsDest.timeToLive()), getEventHandler()); } getEventHandler().addUnAckedMessage(jmsMsg.getStringProperty(ID_HEADER), msg); msg.getObjectHeaders().remove(CoreConstants.OBJ_METADATA_ON_SUCCESS_CALLBACK); msg.getObjectHeaders().remove(CoreConstants.OBJ_METADATA_ON_FAILURE_CALLBACK); captureOutgoingMessageDetails(jmsMsg, msg); log.info("msg produced to destination [{}]", jmsDest); } catch (Throwable ex) { ExceptionHelper.rethrowProduceException(ex); } } JmsAsyncProducer(); @Override void init();  }