use of com.adaptris.core.NullMessageConsumer in project interlok by adaptris.
the class OnMessageHandlerTest method testOnMessageHandlerProducerFailsRollback.
@Test
public void testOnMessageHandlerProducerFailsRollback() throws Exception {
when(mockSession.getTransacted()).thenReturn(true);
JmsTransactedWorkflow jmsTransactedWorkflow = new JmsTransactedWorkflow();
jmsTransactedWorkflow.setConsumer(new NullMessageConsumer());
jmsTransactedWorkflow.setProducer(new MockProducer());
jmsTransactedWorkflow.setStrict(true);
jmsTransactedWorkflow.registerChannel(mockChannel);
config.setCorrelationIdSource(mockCorrelationSourceId);
config.setMessageTranslator(mockTranslator);
config.registerAdaptrisMessageListener(jmsTransactedWorkflow);
handler = new OnMessageHandler(config);
handler.onMessage(jmsMessage);
verify(mockSession).rollback();
}
use of com.adaptris.core.NullMessageConsumer in project interlok by adaptris.
the class OnMessageHandlerTest method testOnMessageHandlerSuccessTransactedRollback.
@Test
public void testOnMessageHandlerSuccessTransactedRollback() throws Exception {
when(mockSession.getTransacted()).thenReturn(true);
doThrow(new ProduceException("Expected")).when(mockProducer).produce(any());
when(mockProducer.createName()).thenReturn("name");
when(mockProducer.createQualifier()).thenReturn("Qualifier");
when(mockProducer.isTrackingEndpoint()).thenReturn(false);
JmsTransactedWorkflow jmsTransactedWorkflow = new JmsTransactedWorkflow();
jmsTransactedWorkflow.setConsumer(new NullMessageConsumer());
jmsTransactedWorkflow.setProducer(mockProducer);
jmsTransactedWorkflow.registerChannel(mockChannel);
config.setCorrelationIdSource(mockCorrelationSourceId);
config.setMessageTranslator(mockTranslator);
config.registerAdaptrisMessageListener(jmsTransactedWorkflow);
handler = new OnMessageHandler(config);
handler.onMessage(jmsMessage);
verify(mockSession).rollback();
}
use of com.adaptris.core.NullMessageConsumer in project interlok by adaptris.
the class OnMessageHandlerTest method testOnMessageHandlerCommitFailsThenRollback.
@Test
public void testOnMessageHandlerCommitFailsThenRollback() throws Exception {
when(mockSession.getTransacted()).thenReturn(true);
doThrow(new JMSException("Expected")).when(mockSession).commit();
JmsTransactedWorkflow jmsTransactedWorkflow = new JmsTransactedWorkflow();
jmsTransactedWorkflow.setConsumer(new NullMessageConsumer());
jmsTransactedWorkflow.setProducer(new NullMessageProducer());
jmsTransactedWorkflow.registerChannel(mockChannel);
config.setCorrelationIdSource(mockCorrelationSourceId);
config.setMessageTranslator(mockTranslator);
config.registerAdaptrisMessageListener(jmsTransactedWorkflow);
handler = new OnMessageHandler(config);
handler.onMessage(jmsMessage);
verify(mockSession).commit();
verify(mockSession).rollback();
}
use of com.adaptris.core.NullMessageConsumer in project interlok by adaptris.
the class JmsTransactedWorkflow method initialiseWorkflow.
@Override
protected void initialiseWorkflow() throws CoreException {
AdaptrisMessageConsumer amc = getConsumer();
if (amc instanceof JmsPollingConsumerImpl) {
((JmsPollingConsumerImpl) amc).setRollbackTimeout(waitPeriodAfterRollbackMs());
((JmsPollingConsumerImpl) amc).setTransacted(Boolean.TRUE);
} else if (amc instanceof JmsConsumerImpl) {
((JmsConsumerImpl) amc).setRollbackTimeout(waitPeriodAfterRollbackMs());
((JmsConsumerImpl) amc).setTransacted(Boolean.TRUE);
} else if (!(amc instanceof NullMessageConsumer)) {
throw new CoreException(this.getClass().getSimpleName() + " must be used with a JMSConsumer");
}
ProduceExceptionHandler produceExceptionHandler = getProduceExceptionHandler();
if (produceExceptionHandler != null && !(produceExceptionHandler instanceof NullProduceExceptionHandler)) {
throw new CoreException(this.getClass().getSimpleName() + " may not have a ProduceExceptionHandler set");
}
super.initialiseWorkflow();
}
Aggregations