use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class DefaultFailedMessageRetrierJmxTest method testMBean_Retry_WorkflowNotStarted.
@Test
public void testMBean_Retry_WorkflowNotStarted() throws Exception {
Adapter adapter = createAdapter(getName());
Channel channel = createChannel(getName());
StandardWorkflow wf = createWorkflow(getName());
MockMessageProducer mock = new MockMessageProducer();
wf.setProducer(mock);
channel.getWorkflowList().add(wf);
adapter.getChannelList().add(channel);
DefaultFailedMessageRetrier retrier = new DefaultFailedMessageRetrier();
retrier.setShutdownWaitTime(new TimeInterval(10L, TimeUnit.SECONDS));
adapter.setFailedMessageRetrier(retrier);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(Workflow.WORKFLOW_ID_KEY, getName() + "@" + getName());
SerializableMessage serialized = new DefaultSerializableMessageTranslator().translate(msg);
AdapterManager adapterManager = new AdapterManager(adapter);
try {
adapterManager.registerMBean();
adapterManager.requestStart();
// Close the workflow directly
wf.requestClose();
ObjectName retrierObjName = createRetrierObjectName(adapterManager);
DefaultFailedMessageRetrierJmxMBean jmxBean = JMX.newMBeanProxy(mBeanServer, retrierObjName, DefaultFailedMessageRetrierJmxMBean.class);
assertFalse(jmxBean.retryMessage(serialized));
assertEquals(0, mock.messageCount());
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.StandardWorkflow 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.StandardWorkflow in project interlok by adaptris.
the class ChannelManagerTest method testMBean_RemoveWorkflow_AddWorkflow.
@Test
public void testMBean_RemoveWorkflow_AddWorkflow() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel newChannel = createChannel(getName() + "_1");
ObjectName adapterObj = adapterManager.createObjectName();
ChannelManager channelManager = new ChannelManager(newChannel, adapterManager);
ObjectName channelObj = channelManager.createObjectName();
StandardWorkflow newWorkflow1 = createWorkflow(getName() + "_1");
StandardWorkflow newWorkflow2 = createWorkflow(getName() + "_2");
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
adapterManager.registerMBean();
AdapterManagerMBean adapterManagerProxy = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
ObjectName workflowObj1 = channelManagerProxy.addWorkflow(DefaultMarshaller.getDefaultMarshaller().marshal(newWorkflow1));
ObjectName workflowObj2 = channelManagerProxy.addWorkflow(DefaultMarshaller.getDefaultMarshaller().marshal(newWorkflow2));
assertEquals(2, channelManagerProxy.getChildren().size());
assertTrue(channelManagerProxy.removeWorkflow(newWorkflow1.getUniqueId()));
assertFalse(JmxHelper.findMBeanServer().isRegistered(workflowObj1));
assertNotNull(channelManagerProxy.addWorkflow(DefaultMarshaller.getDefaultMarshaller().marshal(newWorkflow1)));
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj1, WorkflowManagerMBean.class);
} finally {
}
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class WorkflowManagerTest method testJettyInterceptor_NotAddedTo_StandardWorkflow.
@Test
public void testJettyInterceptor_NotAddedTo_StandardWorkflow() 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.setConsumer(new JettyMessageConsumer());
new WorkflowManager(workflow, channelManager);
assertEquals(2, workflow.getInterceptors().size());
assertEquals(MessageMetricsInterceptor.class, workflow.getInterceptors().get(0).getClass());
assertEquals(InFlightWorkflowInterceptor.class, workflow.getInterceptors().get(1).getClass());
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class WorkflowManagerTest method testConstructor_WithInterceptor_NoRuntimeInfoFactoryRegistration.
@Test
public void testConstructor_WithInterceptor_NoRuntimeInfoFactoryRegistration() 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 ThrottlingInterceptor());
WorkflowManager workflowManager = new WorkflowManager(workflow, channelManager);
assertEquals(0, workflowManager.getChildRuntimeInfoComponents().size());
}
Aggregations