Search in sources :

Example 1 with MessageMetricsInterceptor

use of com.adaptris.core.interceptor.MessageMetricsInterceptor in project interlok by adaptris.

the class WorkflowManagerTest method testMessageCounter_Enabled_AlreadyHasMessageCounter.

@Test
public void testMessageCounter_Enabled_AlreadyHasMessageCounter() 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);
    Workflow workflow = createWorkflow("w1");
    workflow.getInterceptors().add(new MessageMetricsInterceptor(getName(), null));
    new WorkflowManager(workflow, channelManager);
    assertEquals(2, workflow.getInterceptors().size());
    assertEquals(MessageMetricsInterceptor.class, workflow.getInterceptors().get(0).getClass());
    assertEquals(getName(), workflow.getInterceptors().get(0).getUniqueId());
    assertEquals(InFlightWorkflowInterceptor.class, workflow.getInterceptors().get(1).getClass());
}
Also used : Channel(com.adaptris.core.Channel) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) Adapter(com.adaptris.core.Adapter) MessageMetricsInterceptor(com.adaptris.core.interceptor.MessageMetricsInterceptor) Test(org.junit.Test)

Example 2 with MessageMetricsInterceptor

use of com.adaptris.core.interceptor.MessageMetricsInterceptor in project interlok by adaptris.

the class WorkflowManager method configureMessageCounter.

private void configureMessageCounter() throws CoreException, MalformedObjectNameException {
    if (managedWorkflow.disableMessageCount())
        return;
    if (!hasInterceptorOfType(managedWorkflow.getInterceptors(), MessageMetricsInterceptor.class)) {
        log.trace("Message count interceptor added for [{}], tracks metrics for ~1hr", createObjectName());
        String uid = managedWorkflow.getUniqueId() + MessageMetricsInterceptor.UID_SUFFIX;
        managedWorkflow.getInterceptors().add(new MessageMetricsInterceptor(uid, new TimeInterval(5L, TimeUnit.MINUTES), 12));
    }
    if (!hasInterceptorOfType(managedWorkflow.getInterceptors(), InFlightWorkflowInterceptor.class)) {
        log.trace("InFlight interceptor added for [{}]", createObjectName());
        String uid = managedWorkflow.getUniqueId() + InFlightWorkflowInterceptor.UID_SUFFIX;
        managedWorkflow.getInterceptors().add(new InFlightWorkflowInterceptor(uid));
    }
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) InFlightWorkflowInterceptor(com.adaptris.core.interceptor.InFlightWorkflowInterceptor) MessageMetricsInterceptor(com.adaptris.core.interceptor.MessageMetricsInterceptor)

Example 3 with MessageMetricsInterceptor

use of com.adaptris.core.interceptor.MessageMetricsInterceptor in project interlok by adaptris.

the class AdapterManagerTest method testRegisterMBean.

@Test
public void testRegisterMBean() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    Channel channel = createChannel("c1");
    Workflow workflow = createWorkflow("w1");
    workflow.getInterceptors().add(new MessageMetricsInterceptor());
    channel.getWorkflowList().add(workflow);
    adapter.getChannelList().add(channel);
    AdapterManager adapterManager = new AdapterManager(adapter);
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
    mBeans.add(adapterManager);
    mBeans.addAll(adapterManager.getAllDescendants());
    try {
        adapterManager.registerMBean();
        assertTrue(JmxHelper.findMBeanServer().isRegistered(adapterManager.createObjectName()));
        for (BaseComponentMBean baseMBean : adapterManager.getAllDescendants()) {
            assertTrue(JmxHelper.findMBeanServer().isRegistered(baseMBean.createObjectName()));
        }
        adapterManager.unregisterMBean();
        assertFalse(JmxHelper.findMBeanServer().isRegistered(adapterManager.createObjectName()));
        for (BaseComponentMBean baseMBean : adapterManager.getAllDescendants()) {
            assertFalse(JmxHelper.findMBeanServer().isRegistered(baseMBean.createObjectName()));
        }
        register(mBeans);
        assertTrue(JmxHelper.findMBeanServer().isRegistered(adapterManager.createObjectName()));
        for (BaseComponentMBean baseMBean : adapterManager.getAllDescendants()) {
            assertTrue(JmxHelper.findMBeanServer().isRegistered(baseMBean.createObjectName()));
        }
    } finally {
    }
}
Also used : Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) Adapter(com.adaptris.core.Adapter) MessageMetricsInterceptor(com.adaptris.core.interceptor.MessageMetricsInterceptor) Test(org.junit.Test)

Example 4 with MessageMetricsInterceptor

use of com.adaptris.core.interceptor.MessageMetricsInterceptor in project interlok by adaptris.

the class WorkflowManagerTest method testConstructor_WithInterceptor_RuntimeInfoFactoryRegistered.

@Test
public void testConstructor_WithInterceptor_RuntimeInfoFactoryRegistered() 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.setDisableDefaultMessageCount(true);
    workflow.getInterceptors().add(new MessageMetricsInterceptor());
    WorkflowManager workflowManager = new WorkflowManager(workflow, channelManager);
    assertEquals(1, workflowManager.getChildRuntimeInfoComponents().size());
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) MessageMetricsInterceptor(com.adaptris.core.interceptor.MessageMetricsInterceptor) Test(org.junit.Test)

Aggregations

MessageMetricsInterceptor (com.adaptris.core.interceptor.MessageMetricsInterceptor)4 Adapter (com.adaptris.core.Adapter)3 Channel (com.adaptris.core.Channel)3 StandardWorkflow (com.adaptris.core.StandardWorkflow)3 Test (org.junit.Test)3 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)2 Workflow (com.adaptris.core.Workflow)2 InFlightWorkflowInterceptor (com.adaptris.core.interceptor.InFlightWorkflowInterceptor)1 TimeInterval (com.adaptris.util.TimeInterval)1 ArrayList (java.util.ArrayList)1