use of com.adaptris.core.DefaultFailedMessageRetrier in project interlok by adaptris.
the class DefaultFailedMessageRetrierJmxTest method testMBean_Retry_File.
@Test
public void testMBean_Retry_File() throws Exception {
Adapter adapter = createAdapter(getName());
Channel c = createChannel(getName());
StandardWorkflow wf = createWorkflow(getName());
MockMessageProducer mock = new MockMessageProducer();
wf.setProducer(mock);
c.getWorkflowList().add(wf);
adapter.getChannelList().add(c);
DefaultFailedMessageRetrier retrier = new DefaultFailedMessageRetrier();
adapter.setFailedMessageRetrier(retrier);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(Workflow.WORKFLOW_ID_KEY, getName() + "@" + getName());
File fileToRetry = writeFile(msg, new MimeEncoder());
AdapterManager adapterManager = new AdapterManager(adapter);
try {
adapterManager.registerMBean();
adapterManager.requestStart();
ObjectName retrierObjName = createRetrierObjectName(adapterManager);
DefaultFailedMessageRetrierJmxMBean jmxBean = JMX.newMBeanProxy(mBeanServer, retrierObjName, DefaultFailedMessageRetrierJmxMBean.class);
assertTrue(jmxBean.retryMessage(fileToRetry));
waitForMessages(mock, 1);
assertEquals(1, mock.messageCount());
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.DefaultFailedMessageRetrier in project interlok by adaptris.
the class DefaultFailedMessageRetrierJmxTest method testMBean_GetParentObjectName.
@Test
public void testMBean_GetParentObjectName() throws Exception {
Adapter adapter = createAdapter(getName());
DefaultFailedMessageRetrier retrier = new DefaultFailedMessageRetrier();
adapter.setFailedMessageRetrier(retrier);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName retrierObjName = createRetrierObjectName(adapterManager);
try {
adapterManager.registerMBean();
DefaultFailedMessageRetrierJmxMBean proxy = JMX.newMBeanProxy(mBeanServer, retrierObjName, DefaultFailedMessageRetrierJmxMBean.class);
assertNotNull(proxy);
assertEquals(adapterManager.createObjectName(), proxy.getParentObjectName());
} finally {
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.DefaultFailedMessageRetrier in project interlok by adaptris.
the class DefaultFailedMessageRetrierJmxTest method testMBean_Retry_WorkflowNotStarted.
@Test
public void testMBean_Retry_WorkflowNotStarted() throws Exception {
Adapter adapter = createAdapter(getName());
Channel channel = createChannel(getName());
StandardWorkflow wf = createWorkflow(getName());
MockMessageProducer mock = new MockMessageProducer();
wf.setProducer(mock);
channel.getWorkflowList().add(wf);
adapter.getChannelList().add(channel);
DefaultFailedMessageRetrier retrier = new DefaultFailedMessageRetrier();
retrier.setShutdownWaitTime(new TimeInterval(10L, TimeUnit.SECONDS));
adapter.setFailedMessageRetrier(retrier);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(Workflow.WORKFLOW_ID_KEY, getName() + "@" + getName());
SerializableMessage serialized = new DefaultSerializableMessageTranslator().translate(msg);
AdapterManager adapterManager = new AdapterManager(adapter);
try {
adapterManager.registerMBean();
adapterManager.requestStart();
// Close the workflow directly
wf.requestClose();
ObjectName retrierObjName = createRetrierObjectName(adapterManager);
DefaultFailedMessageRetrierJmxMBean jmxBean = JMX.newMBeanProxy(mBeanServer, retrierObjName, DefaultFailedMessageRetrierJmxMBean.class);
assertFalse(jmxBean.retryMessage(serialized));
assertEquals(0, mock.messageCount());
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
Aggregations