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();
}
}
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();
}
}
Aggregations