Search in sources :

Example 76 with StandardWorkflow

use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.

the class SlowMessageNotificationTest method testNotification_SlowMessage_Success.

@Test
public void testNotification_SlowMessage_Success() throws Exception {
    SlowMessageNotification notif = new SlowMessageNotification(getName(), new TimeInterval(100L, TimeUnit.MILLISECONDS), new TimeInterval(1L, TimeUnit.MINUTES));
    StandardWorkflow workflow = createWorkflow(getName() + "_Workflow", notif);
    workflow.getServiceCollection().add(new WaitService(new TimeInterval(1L, TimeUnit.SECONDS)));
    Adapter adapter = createAdapter(getName(), workflow);
    List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
    BaseComponentMBean notifier = getFirstImpl(mBeans, InterceptorNotificationMBean.class);
    assertNotNull(notifier);
    ObjectName notifObjName = notifier.createObjectName();
    SimpleNotificationListener listener = new SimpleNotificationListener();
    try {
        start(adapter);
        register(mBeans);
        mBeanServer.addNotificationListener(notifObjName, listener, null, null);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        workflow.onAdaptrisMessage(msg);
        listener.waitForMessages(1);
        assertEquals(1, listener.getNotifications().size());
        Notification notification = listener.getNotifications().get(0);
        Properties userData = (Properties) notification.getUserData();
        assertEquals(msg.getUniqueId(), userData.getProperty(SlowMessageNotification.KEY_MESSAGE_ID));
    // assertEquals("true", userData.getProperty(SlowMessageNotification.KEY_MESSAGE_SUCCESS));
    } finally {
        stop(adapter);
    }
}
Also used : BaseComponentMBean(com.adaptris.core.runtime.BaseComponentMBean) WaitService(com.adaptris.core.services.WaitService) StandardWorkflow(com.adaptris.core.StandardWorkflow) TimeInterval(com.adaptris.util.TimeInterval) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleNotificationListener(com.adaptris.core.runtime.SimpleNotificationListener) Adapter(com.adaptris.core.Adapter) Properties(java.util.Properties) Notification(javax.management.Notification) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 77 with StandardWorkflow

use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.

the class MessageNotificationCase method createWorkflow.

protected StandardWorkflow createWorkflow(String uid, WorkflowInterceptor... interceptors) throws CoreException {
    StandardWorkflow wf = new StandardWorkflow();
    wf.setUniqueId(uid);
    for (WorkflowInterceptor wi : interceptors) {
        wf.addInterceptor(wi);
    }
    return wf;
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) WorkflowInterceptor(com.adaptris.core.WorkflowInterceptor)

Example 78 with StandardWorkflow

use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.

the class FailedMessageRetrierCase method testRegisteredWorkflowIds.

@Test
public void testRegisteredWorkflowIds() throws Exception {
    FailedMessageRetrier retrier = create();
    StandardWorkflow wf1 = createWorkflow();
    StandardWorkflow wf2 = createWorkflow();
    retrier.addWorkflow(wf1);
    retrier.addWorkflow(wf2);
    assertEquals(2, retrier.registeredWorkflowIds().size());
    assertTrue(retrier.registeredWorkflowIds().contains(wf1.obtainWorkflowId()));
    assertTrue(retrier.registeredWorkflowIds().contains(wf2.obtainWorkflowId()));
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) FailedMessageRetrier(com.adaptris.core.FailedMessageRetrier) Test(org.junit.Test)

Example 79 with StandardWorkflow

use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.

the class ExampleErrorHandlerCase method createWorkflow.

protected StandardWorkflow createWorkflow(MockMessageConsumer consumer, ProcessingExceptionHandler errorHandler, Service... services) {
    StandardWorkflow workflow = new StandardWorkflow();
    workflow.setMessageErrorHandler(errorHandler);
    workflow.setConsumer(consumer);
    workflow.getServiceCollection().addAll(Arrays.asList(services));
    return workflow;
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow)

Example 80 with StandardWorkflow

use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.

the class DefaultFailedMessageRetrierJmxTest method testMBean_Retry_File.

@Test
public void testMBean_Retry_File() throws Exception {
    Adapter adapter = createAdapter(getName());
    Channel c = createChannel(getName());
    StandardWorkflow wf = createWorkflow(getName());
    MockMessageProducer mock = new MockMessageProducer();
    wf.setProducer(mock);
    c.getWorkflowList().add(wf);
    adapter.getChannelList().add(c);
    DefaultFailedMessageRetrier retrier = new DefaultFailedMessageRetrier();
    adapter.setFailedMessageRetrier(retrier);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    msg.addMetadata(Workflow.WORKFLOW_ID_KEY, getName() + "@" + getName());
    File fileToRetry = writeFile(msg, new MimeEncoder());
    AdapterManager adapterManager = new AdapterManager(adapter);
    try {
        adapterManager.registerMBean();
        adapterManager.requestStart();
        ObjectName retrierObjName = createRetrierObjectName(adapterManager);
        DefaultFailedMessageRetrierJmxMBean jmxBean = JMX.newMBeanProxy(mBeanServer, retrierObjName, DefaultFailedMessageRetrierJmxMBean.class);
        assertTrue(jmxBean.retryMessage(fileToRetry));
        waitForMessages(mock, 1);
        assertEquals(1, 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) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MimeEncoder(com.adaptris.core.MimeEncoder) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) DefaultFailedMessageRetrier(com.adaptris.core.DefaultFailedMessageRetrier) File(java.io.File) ObjectName(javax.management.ObjectName) 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