Search in sources :

Example 16 with WaitService

use of com.adaptris.core.services.WaitService in project interlok by adaptris.

the class JmsTransactedWorkflowTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    Channel c = new Channel();
    try {
        c.setUniqueId(UUID.randomUUID().toString());
        c.setConsumeConnection(configure(new JmsConnection()));
        JmsTransactedWorkflow workflow = createWorkflow("Sample_Queue_1");
        workflow.setUniqueId(UUID.randomUUID().toString());
        workflow.setWaitPeriodAfterRollback(new TimeInterval(30L, TimeUnit.SECONDS.name()));
        workflow.getServiceCollection().addService(new WaitService());
        workflow.getServiceCollection().addService(new ThrowExceptionService(new ConfiguredException("Fail")));
        workflow.setProducer(new FsProducer().withBaseDirectoryUrl("file:////path/to/directory"));
        c.getWorkflowList().add(workflow);
    } catch (CoreException e) {
        throw new RuntimeException(e);
    }
    return c;
}
Also used : WaitService(com.adaptris.core.services.WaitService) TimeInterval(com.adaptris.util.TimeInterval) CoreException(com.adaptris.core.CoreException) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) FsProducer(com.adaptris.core.fs.FsProducer) ConfiguredException(com.adaptris.core.services.exception.ConfiguredException)

Example 17 with WaitService

use of com.adaptris.core.services.WaitService 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 18 with WaitService

use of com.adaptris.core.services.WaitService in project interlok by adaptris.

the class MessagesInFlightTest method buildAdapter.

private Adapter buildAdapter(PoolingWorkflow workflow) throws Exception {
    Adapter adapter = createAdapter(getName());
    Channel channel = new Channel(getName());
    workflow.setPoolSize(1);
    workflow.setShutdownWaitTime(new TimeInterval(1L, TimeUnit.SECONDS));
    workflow.addInterceptor(new InFlightWorkflowInterceptor(getName()));
    workflow.getServiceCollection().add(new WaitService(new TimeInterval(5L, TimeUnit.SECONDS)));
    channel.getWorkflowList().add(workflow);
    adapter.getChannelList().add(channel);
    return adapter;
}
Also used : WaitService(com.adaptris.core.services.WaitService) TimeInterval(com.adaptris.util.TimeInterval) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) InFlightWorkflowInterceptor(com.adaptris.core.interceptor.InFlightWorkflowInterceptor)

Example 19 with WaitService

use of com.adaptris.core.services.WaitService in project interlok by adaptris.

the class ServiceCollectionCase method testIndexOf.

@Test
public void testIndexOf() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    sc.addService(new NullService(UUID.randomUUID().toString()));
    WaitService s = new WaitService(UUID.randomUUID().toString());
    sc.addService(s);
    sc.addService(new NullService(UUID.randomUUID().toString()));
    assertEquals(1, sc.indexOf(s));
}
Also used : WaitService(com.adaptris.core.services.WaitService) ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Example 20 with WaitService

use of com.adaptris.core.services.WaitService in project interlok by adaptris.

the class ServiceCollectionCase method testGet.

@Test
public void testGet() throws Exception {
    ServiceCollectionImp sc = createServiceCollection();
    sc.addService(new NullService(UUID.randomUUID().toString()));
    sc.addService(new WaitService(UUID.randomUUID().toString()));
    sc.addService(new NullService(UUID.randomUUID().toString()));
    assertEquals(WaitService.class, sc.get(1).getClass());
}
Also used : WaitService(com.adaptris.core.services.WaitService) ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) Test(org.junit.Test)

Aggregations

WaitService (com.adaptris.core.services.WaitService)28 Test (org.junit.Test)26 TimeInterval (com.adaptris.util.TimeInterval)21 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)16 Channel (com.adaptris.core.Channel)11 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)11 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)8 StandaloneProducer (com.adaptris.core.StandaloneProducer)8 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)8 NullService (com.adaptris.core.NullService)7 ServiceCollectionImp (com.adaptris.core.ServiceCollectionImp)7 StandardWorkflow (com.adaptris.core.StandardWorkflow)5 Adapter (com.adaptris.core.Adapter)4 AppendingMessageAggregator (com.adaptris.core.services.aggregator.AppendingMessageAggregator)4 ServiceException (com.adaptris.core.ServiceException)3 BaseComponentMBean (com.adaptris.core.runtime.BaseComponentMBean)3 SimpleNotificationListener (com.adaptris.core.runtime.SimpleNotificationListener)3 DefaultEventHandler (com.adaptris.core.DefaultEventHandler)2 ProduceException (com.adaptris.core.ProduceException)2 Service (com.adaptris.core.Service)2