Search in sources :

Example 1 with RetryMessageErrorHandlerMonitorMBean

use of com.adaptris.core.RetryMessageErrorHandlerMonitorMBean 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();
    }
}
Also used : Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) RetryMessageErrorHandlerMonitorMBean(com.adaptris.core.RetryMessageErrorHandlerMonitorMBean) Adapter(com.adaptris.core.Adapter) RetryMessageErrorHandler(com.adaptris.core.RetryMessageErrorHandler) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 2 with RetryMessageErrorHandlerMonitorMBean

use of com.adaptris.core.RetryMessageErrorHandlerMonitorMBean 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();
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) Channel(com.adaptris.core.Channel) RetryMessageErrorHandlerMonitorMBean(com.adaptris.core.RetryMessageErrorHandlerMonitorMBean) Adapter(com.adaptris.core.Adapter) RetryMessageErrorHandler(com.adaptris.core.RetryMessageErrorHandler) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 3 with RetryMessageErrorHandlerMonitorMBean

use of com.adaptris.core.RetryMessageErrorHandlerMonitorMBean 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();
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) RetryMessageErrorHandlerMonitorMBean(com.adaptris.core.RetryMessageErrorHandlerMonitorMBean) Adapter(com.adaptris.core.Adapter) RetryMessageErrorHandler(com.adaptris.core.RetryMessageErrorHandler) StandaloneProducer(com.adaptris.core.StandaloneProducer) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 4 with RetryMessageErrorHandlerMonitorMBean

use of com.adaptris.core.RetryMessageErrorHandlerMonitorMBean 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();
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) RetryMessageErrorHandlerMonitorMBean(com.adaptris.core.RetryMessageErrorHandlerMonitorMBean) Adapter(com.adaptris.core.Adapter) RetryMessageErrorHandler(com.adaptris.core.RetryMessageErrorHandler) StandaloneProducer(com.adaptris.core.StandaloneProducer) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 5 with RetryMessageErrorHandlerMonitorMBean

use of com.adaptris.core.RetryMessageErrorHandlerMonitorMBean 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();
    }
}
Also used : AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) ArrayList(java.util.ArrayList) RetryMessageErrorHandlerMonitorMBean(com.adaptris.core.RetryMessageErrorHandlerMonitorMBean) Adapter(com.adaptris.core.Adapter) RetryMessageErrorHandler(com.adaptris.core.RetryMessageErrorHandler) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

Adapter (com.adaptris.core.Adapter)5 RetryMessageErrorHandler (com.adaptris.core.RetryMessageErrorHandler)5 RetryMessageErrorHandlerMonitorMBean (com.adaptris.core.RetryMessageErrorHandlerMonitorMBean)5 ObjectName (javax.management.ObjectName)5 Test (org.junit.Test)5 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 Channel (com.adaptris.core.Channel)2 StandaloneProducer (com.adaptris.core.StandaloneProducer)2 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)2 ArrayList (java.util.ArrayList)2 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)1 StandardWorkflow (com.adaptris.core.StandardWorkflow)1