use of com.adaptris.core.RetryMessageErrorHandler in project interlok by adaptris.
the class ChannelManagerTest method testChannelManager_HasRetryMonitor.
@Test
public void testChannelManager_HasRetryMonitor() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel c1 = createChannel(getName() + "_1");
c1.setMessageErrorHandler(new RetryMessageErrorHandler(getName()));
ChannelManager cm1 = new ChannelManager(c1, adapterManager);
ObjectName channelObj = cm1.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>(Arrays.asList(new BaseComponentMBean[] { adapterManager, cm1 }));
try {
register(mBeans);
ObjectName handlerObjectName = ObjectName.getInstance(JMX_RETRY_MONITOR_TYPE + cm1.createObjectHierarchyString() + ID_PREFIX + getName());
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
assertTrue(channelManagerProxy.getChildRuntimeInfoComponents().contains(handlerObjectName));
RetryMessageErrorHandlerMonitorMBean monitor = JMX.newMBeanProxy(mBeanServer, handlerObjectName, RetryMessageErrorHandlerMonitorMBean.class);
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.RetryMessageErrorHandler in project interlok by adaptris.
the class WorkflowManagerTest method testWorkflowManager_HasRetryMonitor.
@Test
public void testWorkflowManager_HasRetryMonitor() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel("c1");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
StandardWorkflow workflow = createWorkflow("w1");
workflow.setMessageErrorHandler(new RetryMessageErrorHandler(getName()));
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
try {
adapterManager.registerMBean();
adapterManager.requestStart();
ObjectName handlerObjectName = ObjectName.getInstance(JMX_RETRY_MONITOR_TYPE + realWorkflowManager.createObjectHierarchyString() + ID_PREFIX + getName());
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
assertTrue(workflowManagerProxy.getChildRuntimeInfoComponents().contains(handlerObjectName));
RetryMessageErrorHandlerMonitorMBean monitor = JMX.newMBeanProxy(mBeanServer, handlerObjectName, RetryMessageErrorHandlerMonitorMBean.class);
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.RetryMessageErrorHandler in project interlok by adaptris.
the class RetryMessageErrorHandlerMonitorTest method testMBean_FailAllMessages.
@Test
public void testMBean_FailAllMessages() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
MockMessageProducer failProducer = new MockMessageProducer();
RetryMessageErrorHandler handler = new RetryMessageErrorHandler(getName(), new StandaloneProducer(failProducer));
adapter.setMessageErrorHandler(handler);
AdapterManager adapterManager = new AdapterManager(adapter);
try {
registerMBeans(adapterManager);
adapterManager.requestStart();
ObjectName retryObjectName = ObjectName.getInstance(JMX_RETRY_MONITOR_TYPE + adapterManager.createObjectHierarchyString() + ID_PREFIX + getName());
RetryMessageErrorHandlerMonitorMBean mbean = JMX.newMBeanProxy(mBeanServer, retryObjectName, RetryMessageErrorHandlerMonitorMBean.class);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
// 10 retries 10 minutes apart, so it should be waiting.
handler.handleProcessingException(msg);
assertEquals(1, mbean.waitingForRetry().size());
assertTrue(mbean.waitingForRetry().contains(msg.getUniqueId()));
mbean.failAllMessages(true);
assertEquals(1, failProducer.messageCount());
handler.handleProcessingException(AdaptrisMessageFactory.getDefaultInstance().newMessage());
// All msgs Fail.
assertEquals(0, mbean.waitingForRetry().size());
assertEquals(2, failProducer.messageCount());
} finally {
adapterManager.requestClose();
}
}
use of com.adaptris.core.RetryMessageErrorHandler in project interlok by adaptris.
the class RetryMessageErrorHandlerMonitorTest method testMBean_FailMessageById.
@Test
public void testMBean_FailMessageById() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
MockMessageProducer failProducer = new MockMessageProducer();
RetryMessageErrorHandler handler = new RetryMessageErrorHandler(getName(), new StandaloneProducer(failProducer));
adapter.setMessageErrorHandler(handler);
AdapterManager adapterManager = new AdapterManager(adapter);
try {
registerMBeans(adapterManager);
adapterManager.requestStart();
ObjectName retryObjectName = ObjectName.getInstance(JMX_RETRY_MONITOR_TYPE + adapterManager.createObjectHierarchyString() + ID_PREFIX + getName());
RetryMessageErrorHandlerMonitorMBean mbean = JMX.newMBeanProxy(mBeanServer, retryObjectName, RetryMessageErrorHandlerMonitorMBean.class);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
// 10 retries 10 minutes apart, so it should be waiting.
handler.handleProcessingException(msg);
assertEquals(1, mbean.waitingForRetry().size());
assertTrue(mbean.waitingForRetry().contains(msg.getUniqueId()));
mbean.failMessage("hello");
mbean.failMessage(msg.getUniqueId());
assertEquals(1, failProducer.messageCount());
} finally {
adapterManager.requestClose();
}
}
use of com.adaptris.core.RetryMessageErrorHandler in project interlok by adaptris.
the class AdapterManagerTest method testMBean_HasRetryMessageErrorHandler.
@Test
public void testMBean_HasRetryMessageErrorHandler() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
adapter.setMessageErrorHandler(new RetryMessageErrorHandler(getName()));
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
adapterManager.requestStart();
AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
ObjectName handlerObjectName = ObjectName.getInstance(JMX_RETRY_MONITOR_TYPE + adapterManager.createObjectHierarchyString() + ID_PREFIX + getName());
assertTrue(amp.getChildRuntimeInfoComponents().contains(handlerObjectName));
RetryMessageErrorHandlerMonitorMBean monitor = JMX.newMBeanProxy(mBeanServer, handlerObjectName, RetryMessageErrorHandlerMonitorMBean.class);
} finally {
adapterManager.requestClose();
}
}
Aggregations