use of com.adaptris.core.PoolingWorkflow in project interlok by adaptris.
the class JettyNoBacklogInterceptorTest method retrieveObjectForSampleConfig.
@Override
protected Channel retrieveObjectForSampleConfig() {
Channel c = new Channel();
PoolingWorkflow wf = new PoolingWorkflow();
wf.addInterceptor(new JettyPoolingWorkflowInterceptor());
wf.addInterceptor(new JettyNoBacklogInterceptor());
c.setUniqueId(UUID.randomUUID().toString());
wf.setUniqueId(UUID.randomUUID().toString());
c.getWorkflowList().add(wf);
return c;
}
use of com.adaptris.core.PoolingWorkflow in project interlok by adaptris.
the class InFlightWorkflowInterceptorTest method testInterceptor.
@Test
public void testInterceptor() throws Exception {
InFlightWorkflowInterceptor interceptor = new InFlightWorkflowInterceptor("testInterceptor");
final PoolingWorkflow wf = createPoolingWorkflow("workflow", interceptor);
wf.setPoolSize(1);
wf.setShutdownWaitTime(new TimeInterval(10L, TimeUnit.SECONDS));
MockMessageProducer prod = new MockMessageProducer();
wf.setProducer(prod);
wf.getServiceCollection().add(new WaitService(new TimeInterval(2L, TimeUnit.SECONDS)));
MockChannel c = new MockChannel();
c.getWorkflowList().add(wf);
try {
LifecycleHelper.initAndStart(c);
wf.onAdaptrisMessage(AdaptrisMessageFactory.getDefaultInstance().newMessage());
assertEquals(1, interceptor.messagesInFlightCount());
assertEquals(0, interceptor.messagesPendingCount());
new Thread(new Runnable() {
@Override
public void run() {
wf.onAdaptrisMessage(AdaptrisMessageFactory.getDefaultInstance().newMessage());
}
}).start();
LifecycleHelper.waitQuietly(100);
assertEquals(1, interceptor.messagesInFlightCount());
assertEquals(1, interceptor.messagesPendingCount());
ExampleServiceCase.waitForMessages(prod, 2, 10000);
} finally {
LifecycleHelper.stopAndClose(c);
}
}
use of com.adaptris.core.PoolingWorkflow in project interlok by adaptris.
the class ChannelManagerTest method testMBean_NotificationOnAddWorkflow.
@Test
public void testMBean_NotificationOnAddWorkflow() 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"));
ChannelManager child1 = new ChannelManager(createChannel(getName() + "_1"), 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.addWorkflow(workflowXml);
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 AdapterManagerTest method testMBean_NotificationOnAddWorkflow.
@Test
public void testMBean_NotificationOnAddWorkflow() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
Channel newChannel = createChannel(getName() + "_1");
String workflowXml = DefaultMarshaller.getDefaultMarshaller().marshal(new PoolingWorkflow(getName() + "_wf1"));
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
ChannelManager channelManager = new ChannelManager(newChannel, adapterManager);
ObjectName channelManagerObj = channelManager.createObjectName();
SimpleNotificationListener listener = new SimpleNotificationListener();
NotificationFilterSupport filter = new NotificationFilterSupport();
filter.enableType(NOTIF_TYPE_ADAPTER_CONFIG);
try {
adapterManager.registerMBean();
mBeanServer.addNotificationListener(adapterObj, listener, filter, null);
AdapterManagerMBean adapterManagerProxy = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
channelManager.addWorkflow(workflowXml);
listener.waitForMessages(1);
assertEquals(1, listener.getNotifications().size());
Notification n = listener.getNotifications().get(0);
assertEquals(NOTIF_TYPE_ADAPTER_CONFIG, n.getType());
assertEquals(NOTIF_MSG_CONFIG_UPDATED, n.getMessage());
assertEquals(adapterManagerProxy.getConfiguration(), n.getUserData());
} finally {
}
}
use of com.adaptris.core.PoolingWorkflow in project interlok by adaptris.
the class WorkflowManagerTest method testJettyInterceptor_AlreadyHasInterceptor.
@Test
public void testJettyInterceptor_AlreadyHasInterceptor() 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.addInterceptor(new JettyPoolingWorkflowInterceptor());
workflow.setConsumer(new JettyMessageConsumer());
new WorkflowManager(workflow, channelManager);
assertEquals(3, workflow.getInterceptors().size());
// Look the order should now be swapped.
assertEquals(JettyPoolingWorkflowInterceptor.class, workflow.getInterceptors().get(0).getClass());
assertEquals(MessageMetricsInterceptor.class, workflow.getInterceptors().get(1).getClass());
assertEquals(InFlightWorkflowInterceptor.class, workflow.getInterceptors().get(2).getClass());
}
Aggregations