Search in sources :

Example 1 with MessageInFlightMBean

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

the class MessagesInFlightTest method testInFlightMessageCount.

@Test
public void testInFlightMessageCount() throws Exception {
    PoolingWorkflow workflow = new PoolingWorkflow(getName());
    Adapter adapter = buildAdapter(workflow);
    AdapterManager adapterManager = new AdapterManager(adapter);
    try {
        adapterManager.registerMBean();
        ObjectName objName = createInFlightObjectName(adapterManager);
        MessageInFlightMBean mbean = JMX.newMBeanProxy(mBeanServer, objName, MessageInFlightMBean.class);
        assertNotNull(mbean);
        assertEquals(0, mbean.messagesInFlightCount());
        adapterManager.requestStart();
        workflow.onAdaptrisMessage(AdaptrisMessageFactory.getDefaultInstance().newMessage());
        LifecycleHelper.waitQuietly(100L);
        assertEquals(1, mbean.messagesInFlightCount());
        assertTrue(mbean.messagesInFlight());
    } finally {
        adapterManager.requestClose();
        adapterManager.unregisterMBean();
    }
}
Also used : MessageInFlightMBean(com.adaptris.core.interceptor.MessageInFlightMBean) Adapter(com.adaptris.core.Adapter) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 2 with MessageInFlightMBean

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

the class MessagesInFlightTest method testPendingMessageCount.

@Test
public void testPendingMessageCount() throws Exception {
    final PoolingWorkflow workflow = new PoolingWorkflow(getName());
    Adapter adapter = buildAdapter(workflow);
    AdapterManager adapterManager = new AdapterManager(adapter);
    try {
        adapterManager.registerMBean();
        ObjectName objName = createInFlightObjectName(adapterManager);
        MessageInFlightMBean mbean = JMX.newMBeanProxy(mBeanServer, objName, MessageInFlightMBean.class);
        assertNotNull(mbean);
        assertEquals(0, mbean.messagesInFlightCount());
        adapterManager.requestStart();
        workflow.onAdaptrisMessage(AdaptrisMessageFactory.getDefaultInstance().newMessage());
        new Thread(new Runnable() {

            @Override
            public void run() {
                workflow.onAdaptrisMessage(AdaptrisMessageFactory.getDefaultInstance().newMessage());
            }
        }).start();
        LifecycleHelper.waitQuietly(200L);
        assertEquals(1, mbean.messagesInFlightCount());
        assertTrue(mbean.messagesInFlight());
        assertEquals(1, mbean.messagesPendingCount());
    } finally {
        adapterManager.requestClose();
        adapterManager.unregisterMBean();
    }
}
Also used : MessageInFlightMBean(com.adaptris.core.interceptor.MessageInFlightMBean) Adapter(com.adaptris.core.Adapter) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

Adapter (com.adaptris.core.Adapter)2 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)2 MessageInFlightMBean (com.adaptris.core.interceptor.MessageInFlightMBean)2 ObjectName (javax.management.ObjectName)2 Test (org.junit.Test)2