use of com.adaptris.core.PoolingWorkflow in project interlok by adaptris.
the class WorkflowManagerTest method testJettyInterceptor_AutoAdded.
@Test
public void testJettyInterceptor_AutoAdded() 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);
PoolingWorkflow workflow = new PoolingWorkflow("w1");
workflow.setConsumer(new JettyMessageConsumer());
new WorkflowManager(workflow, channelManager);
assertEquals(3, workflow.getInterceptors().size());
assertEquals(MessageMetricsInterceptor.class, workflow.getInterceptors().get(0).getClass());
assertEquals(InFlightWorkflowInterceptor.class, workflow.getInterceptors().get(1).getClass());
assertEquals(JettyPoolingWorkflowInterceptor.class, workflow.getInterceptors().get(2).getClass());
}
use of com.adaptris.core.PoolingWorkflow in project interlok by adaptris.
the class JettyNoBacklogInterceptor method init.
@Override
public void init() throws CoreException {
Workflow w = parentWorkflow();
if (PoolingWorkflow.class.isAssignableFrom(w.getClass())) {
maxWorkers = ((PoolingWorkflow) w).poolSize();
}
log.trace("503 Server Error will be sent when there are {} messages in flight", maxWorkers);
}
use of com.adaptris.core.PoolingWorkflow in project interlok by adaptris.
the class ChannelManagerTest method testMBean_NotificationOnRemoveWorkflow.
@Test
public void testMBean_NotificationOnRemoveWorkflow() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
String workflowXml = DefaultMarshaller.getDefaultMarshaller().marshal(new PoolingWorkflow(getName() + "_wf1"));
Channel channel = createChannel(getName() + "_1");
StandardWorkflow workflow = createWorkflow(getName() + "_1");
channel.getWorkflowList().add(workflow);
ChannelManager child1 = new ChannelManager(channel, adapterManager);
SimpleNotificationListener listener = new SimpleNotificationListener();
NotificationFilterSupport filter = new NotificationFilterSupport();
filter.enableType(NOTIF_TYPE_CHANNEL_CONFIG);
ObjectName adapterObj = adapterManager.createObjectName();
ObjectName channelObj = child1.createObjectName();
try {
adapterManager.registerMBean();
mBeanServer.addNotificationListener(channelObj, listener, null, null);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
channelManagerProxy.removeWorkflow(workflow.getUniqueId());
listener.waitForMessages(1);
assertEquals(1, listener.getNotifications().size());
Notification n = listener.getNotifications().get(0);
assertEquals(NOTIF_TYPE_CHANNEL_CONFIG, n.getType());
assertEquals(NOTIF_MSG_CONFIG_UPDATED, n.getMessage());
assertEquals(channelManagerProxy.getConfiguration(), n.getUserData());
} finally {
mBeanServer.removeNotificationListener(channelObj, listener);
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.PoolingWorkflow 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.PoolingWorkflow 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