Search in sources :

Example 21 with Workflow

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

the class WorkflowManagerTest method testChannelClosed_StopWorkflow.

@Test
public void testChannelClosed_StopWorkflow() 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);
    Workflow workflow = createWorkflow("w1");
    WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
    adapterManager.createObjectName();
    ObjectName workflowObj = realWorkflowManager.createObjectName();
    ObjectName channelObj = channelManager.createObjectName();
    mBeans.add(adapterManager);
    mBeans.addAll(adapterManager.getAllDescendants());
    try {
        register(mBeans);
        WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        adapterManager.requestStart();
        channelManagerProxy.requestClose(TIMEOUT_MILLIS);
        try {
            workflowManagerProxy.requestStop(TIMEOUT_MILLIS);
            fail();
        } catch (CoreException e) {
            assertEquals(createErrorMessageString(ClosedState.getInstance(), StoppedState.getInstance()), e.getMessage());
        }
    } finally {
        adapter.requestClose();
    }
}
Also used : Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 22 with Workflow

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

the class WorkflowManagerTest method testStart.

@Test
public void testStart() 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);
    Workflow workflow = createWorkflow("w1");
    WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
    List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
    adapterManager.createObjectName();
    ObjectName workflowObj = realWorkflowManager.createObjectName();
    mBeans.add(adapterManager);
    mBeans.addAll(adapterManager.getAllDescendants());
    try {
        register(mBeans);
        WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
        adapterManager.requestStart();
        assertEquals(StartedState.getInstance(), workflowManagerProxy.getComponentState());
        workflowManagerProxy.requestStop(TIMEOUT_MILLIS);
        assertEquals(StoppedState.getInstance(), workflowManagerProxy.getComponentState());
        workflowManagerProxy.requestStart(TIMEOUT_MILLIS);
        assertEquals(StartedState.getInstance(), workflowManagerProxy.getComponentState());
    } finally {
        adapter.requestClose();
    }
}
Also used : Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 23 with Workflow

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

the class WorkflowManagerTest method testMessageCounter_Enabled_AlreadyHasMessageCounter.

@Test
public void testMessageCounter_Enabled_AlreadyHasMessageCounter() 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);
    Workflow workflow = createWorkflow("w1");
    workflow.getInterceptors().add(new MessageMetricsInterceptor(getName(), null));
    new WorkflowManager(workflow, channelManager);
    assertEquals(2, workflow.getInterceptors().size());
    assertEquals(MessageMetricsInterceptor.class, workflow.getInterceptors().get(0).getClass());
    assertEquals(getName(), workflow.getInterceptors().get(0).getUniqueId());
    assertEquals(InFlightWorkflowInterceptor.class, workflow.getInterceptors().get(1).getClass());
}
Also used : Channel(com.adaptris.core.Channel) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) Adapter(com.adaptris.core.Adapter) MessageMetricsInterceptor(com.adaptris.core.interceptor.MessageMetricsInterceptor) Test(org.junit.Test)

Example 24 with Workflow

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

the class ChannelManager method addWorkflow.

@Override
public ObjectName addWorkflow(String xml) throws CoreException, IllegalStateException, MalformedObjectNameException {
    ensureState(ClosedState.getInstance());
    Workflow newWorkflow = (Workflow) DefaultMarshaller.getDefaultMarshaller().unmarshal(xml);
    WorkflowManager workflowManager = new WorkflowManager(newWorkflow, this);
    LifecycleHelper.prepare(newWorkflow);
    // We don't need to "store" the XML at this point, as channelManager will eventually call
    // addChild() and that's when that happens.
    // marshalAndSendNotification();
    getParent().childUpdated();
    workflowManager.registerMBean();
    return workflowManager.createObjectName();
}
Also used : Workflow(com.adaptris.core.Workflow)

Example 25 with Workflow

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

the class ChannelManager method initMembers.

private void initMembers() throws MalformedObjectNameException, CoreException {
    if (isEmpty(channel.getUniqueId())) {
        throw new CoreException("No UniqueID, this channel cannot be managed");
    }
    // Builds up a name com.adaptris:type=Channel, adapter=<adapter-id,>, id=<channel-id>
    myObjectName = ObjectName.getInstance(JMX_CHANNEL_TYPE + ADAPTER_PREFIX + parent.getUniqueId() + ID_PREFIX + getWrappedComponent().getUniqueId());
    for (Workflow c : channel.getWorkflowList()) {
        if (!isEmpty(c.getUniqueId())) {
            addChild(new WorkflowManager(c, this, true), true);
        }
    }
    addChildJmxComponentQuietly((ChildRuntimeInfoComponent) RuntimeInfoComponentFactory.create(this, channel.getMessageErrorHandler()));
    marshalConfig();
}
Also used : CoreException(com.adaptris.core.CoreException) Workflow(com.adaptris.core.Workflow)

Aggregations

Workflow (com.adaptris.core.Workflow)53 StandardWorkflow (com.adaptris.core.StandardWorkflow)49 Channel (com.adaptris.core.Channel)44 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)44 Test (org.junit.Test)43 Adapter (com.adaptris.core.Adapter)40 ObjectName (javax.management.ObjectName)30 ArrayList (java.util.ArrayList)27 CoreException (com.adaptris.core.CoreException)8 MockChannel (com.adaptris.core.stubs.MockChannel)5 Notification (javax.management.Notification)3 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 MessageMetricsInterceptor (com.adaptris.core.interceptor.MessageMetricsInterceptor)2 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)2 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)2 TimeInterval (com.adaptris.util.TimeInterval)2 DefaultEventHandler (com.adaptris.core.DefaultEventHandler)1 NullProcessingExceptionHandler (com.adaptris.core.NullProcessingExceptionHandler)1 XStreamMarshaller (com.adaptris.core.XStreamMarshaller)1