Search in sources :

Example 1 with DefaultSerializableMessageTranslator

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

the class AdapterComponentCheckerTest method testApplyService_WithConnections_Rewrite.

@Test
public void testApplyService_WithConnections_Rewrite() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName, 2, 2);
    adapter.getSharedComponents().addConnection(new NullConnection(getName()));
    List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
    ObjectName objectName = createComponentCheckerObjectName(adapterName);
    LifecycleHelper.initAndStart(adapter);
    register(mBeans);
    // Must init & start because of shared connections.
    LifecycleHelper.initAndStart(adapter);
    AdapterComponentCheckerMBean manager = JMX.newMBeanProxy(mBeanServer, objectName, AdapterComponentCheckerMBean.class);
    AdaptrisMessage msg = new DefaultSerializableMessageTranslator().translate(manager.applyService(createConnectedServices(getName()), createSerializableMessage(), true));
    assertTrue(msg.containsKey("key"));
    assertEquals("value", msg.getMetadataValue("key"));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Adapter(com.adaptris.core.Adapter) NullConnection(com.adaptris.core.NullConnection) DefaultSerializableMessageTranslator(com.adaptris.core.DefaultSerializableMessageTranslator) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 2 with DefaultSerializableMessageTranslator

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

the class DefaultFailedMessageRetrierJmxTest method testMBean_Retry_SerializableMessage_WorkflowNotFound.

@Test
public void testMBean_Retry_SerializableMessage_WorkflowNotFound() 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() + "@BLAHBLAH");
    SerializableMessage serialized = new DefaultSerializableMessageTranslator().translate(msg);
    AdapterManager adapterManager = new AdapterManager(adapter);
    try {
        adapterManager.registerMBean();
        adapterManager.requestStart();
        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) 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 3 with DefaultSerializableMessageTranslator

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

the class DefaultFailedMessageRetrierJmxTest method testMBean_RetryWhen_Retrier_Closed.

@Test
public void testMBean_RetryWhen_Retrier_Closed() 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
        LifecycleHelper.stop(retrier);
        LifecycleHelper.close(retrier);
        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 4 with DefaultSerializableMessageTranslator

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

the class DefaultFailedMessageRetrierJmxTest method testMBean_Retry_SerializableMessage.

@Test
public void testMBean_Retry_SerializableMessage() 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();
    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();
        ObjectName retrierObjName = createRetrierObjectName(adapterManager);
        DefaultFailedMessageRetrierJmxMBean jmxBean = JMX.newMBeanProxy(mBeanServer, retrierObjName, DefaultFailedMessageRetrierJmxMBean.class);
        assertTrue(jmxBean.retryMessage(serialized));
        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) 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 5 with DefaultSerializableMessageTranslator

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

the class WorkflowManager method processAsync.

@Override
public void processAsync(SerializableMessage msgToProcess) throws InterlokException {
    DefaultSerializableMessageTranslator translator = new DefaultSerializableMessageTranslator();
    managedWorkflow.onAdaptrisMessage(toAdaptrisMessage(msgToProcess, translator));
}
Also used : DefaultSerializableMessageTranslator(com.adaptris.core.DefaultSerializableMessageTranslator)

Aggregations

DefaultSerializableMessageTranslator (com.adaptris.core.DefaultSerializableMessageTranslator)9 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)8 Adapter (com.adaptris.core.Adapter)7 ObjectName (javax.management.ObjectName)7 Test (org.junit.Test)7 Channel (com.adaptris.core.Channel)4 DefaultFailedMessageRetrier (com.adaptris.core.DefaultFailedMessageRetrier)4 DefaultFailedMessageRetrierJmxMBean (com.adaptris.core.DefaultFailedMessageRetrierJmxMBean)4 StandardWorkflow (com.adaptris.core.StandardWorkflow)4 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)4 SerializableMessage (com.adaptris.interlok.types.SerializableMessage)4 NullConnection (com.adaptris.core.NullConnection)2 TimeInterval (com.adaptris.util.TimeInterval)2 SerializableAdaptrisMessage (com.adaptris.core.SerializableAdaptrisMessage)1