Search in sources :

Example 81 with StandardWorkflow

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();
    }
}
Also used : DefaultFailedMessageRetrierJmxMBean(com.adaptris.core.DefaultFailedMessageRetrierJmxMBean) StandardWorkflow(com.adaptris.core.StandardWorkflow) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) TimeInterval(com.adaptris.util.TimeInterval) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SerializableMessage(com.adaptris.interlok.types.SerializableMessage) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) DefaultFailedMessageRetrier(com.adaptris.core.DefaultFailedMessageRetrier) DefaultSerializableMessageTranslator(com.adaptris.core.DefaultSerializableMessageTranslator) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 82 with StandardWorkflow

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();
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) Channel(com.adaptris.core.Channel) NotificationFilterSupport(javax.management.NotificationFilterSupport) Adapter(com.adaptris.core.Adapter) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) Notification(javax.management.Notification) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 83 with StandardWorkflow

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 {
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 84 with StandardWorkflow

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());
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) JettyMessageConsumer(com.adaptris.core.http.jetty.JettyMessageConsumer) Test(org.junit.Test)

Example 85 with StandardWorkflow

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());
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) ThrottlingInterceptor(com.adaptris.core.interceptor.ThrottlingInterceptor) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) Test(org.junit.Test)

Aggregations

StandardWorkflow (com.adaptris.core.StandardWorkflow)102 Test (org.junit.Test)78 Channel (com.adaptris.core.Channel)67 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)55 Adapter (com.adaptris.core.Adapter)53 ObjectName (javax.management.ObjectName)41 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)38 TimeInterval (com.adaptris.util.TimeInterval)25 StandaloneProducer (com.adaptris.core.StandaloneProducer)20 BaseComponentMBean (com.adaptris.core.runtime.BaseComponentMBean)16 SimpleNotificationListener (com.adaptris.core.runtime.SimpleNotificationListener)16 ArrayList (java.util.ArrayList)14 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)12 MockChannel (com.adaptris.core.stubs.MockChannel)11 Notification (javax.management.Notification)11 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)10 ServiceList (com.adaptris.core.ServiceList)10 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)10 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)9 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)9