Search in sources :

Example 1 with AdaptrisComponent

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

the class FailoverJmsConsumerCase method testBug1012.

@Test
public void testBug1012() throws Exception {
    FailoverJmsConnection connection = new FailoverJmsConnection();
    try {
        List<JmsConnection> ptp = new ArrayList<JmsConnection>();
        ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
        ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), false));
        connection.setConnections(ptp);
        LifecycleHelper.init(connection);
        assertEquals(1, connection.currentJmsConnection().retrieveExceptionListeners().size());
        AdaptrisComponent owner = (AdaptrisComponent) connection.currentJmsConnection().retrieveExceptionListeners().toArray()[0];
        assertTrue("Owner should be failover connection", connection == owner);
        LifecycleHelper.close(connection);
        Channel channel = new MockChannel();
        connection = new FailoverJmsConnection();
        connection.setRegisterOwner(true);
        channel.setConsumeConnection(connection);
        ptp = new ArrayList<JmsConnection>();
        ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
        ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), false));
        connection.setConnections(ptp);
        connection.setConnectionAttempts(1);
        LifecycleHelper.init(connection);
        assertEquals(0, connection.currentJmsConnection().retrieveExceptionListeners().size());
        LifecycleHelper.close(connection);
    } finally {
        LifecycleHelper.close(connection);
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) AdaptrisComponent(com.adaptris.core.AdaptrisComponent) Test(org.junit.Test)

Example 2 with AdaptrisComponent

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

the class AdapterComponentChecker method checkInitialise.

@Override
public void checkInitialise(String xml) throws CoreException {
    AdaptrisMarshaller marshaller = DefaultMarshaller.getDefaultMarshaller();
    AdaptrisComponent component = (AdaptrisComponent) marshaller.unmarshal(xml);
    prepare(component);
    if (component instanceof AllowsRetriesConnection) {
        AllowsRetriesConnection retry = (AllowsRetriesConnection) component;
        if (retry.connectionAttempts() == -1) {
            retry.setConnectionAttempts(0);
        }
    }
    try {
        init(component);
    } finally {
        close(component);
    }
}
Also used : AllowsRetriesConnection(com.adaptris.core.AllowsRetriesConnection) AdaptrisMarshaller(com.adaptris.core.AdaptrisMarshaller) AdaptrisComponent(com.adaptris.core.AdaptrisComponent)

Example 3 with AdaptrisComponent

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

the class WorkflowManager method initMembers.

private void initMembers() throws MalformedObjectNameException, CoreException {
    if (isEmpty(managedWorkflow.getUniqueId())) {
        throw new CoreException("No UniqueID, this workflow cannot be managed");
    }
    // Builds up a name com.adaptris:type=Workflow, adapter=<adapter-id,>, id=<channel-id>, workflow=<workflow-id>
    myObjectName = ObjectName.getInstance(JMX_WORKFLOW_TYPE + ADAPTER_PREFIX + getParent().getParent().getUniqueId() + CHANNEL_PREFIX + getParent().getUniqueId() + ID_PREFIX + getWrappedComponent().getUniqueId());
    configureDefaultInterceptors();
    Collection<AdaptrisComponent> runtimeCandidates = CollectionUtils.union(managedWorkflow.getInterceptors(), Arrays.asList(new AdaptrisComponent[] { managedWorkflow.getConsumer(), managedWorkflow.getProducer(), defaultIfNull(managedWorkflow.getMessageErrorHandler()) }));
    for (AdaptrisComponent c : runtimeCandidates) {
        addChildJmxComponentQuietly((ChildRuntimeInfoComponent) RuntimeInfoComponentFactory.create(this, c));
    }
    marshalConfig();
}
Also used : CoreException(com.adaptris.core.CoreException) AdaptrisComponent(com.adaptris.core.AdaptrisComponent)

Example 4 with AdaptrisComponent

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

the class FailoverJmsProducerCase method testBug1012.

@Test
public void testBug1012() throws Exception {
    FailoverJmsConnection connection = new FailoverJmsConnection();
    List<JmsConnection> ptp = new ArrayList<JmsConnection>();
    ptp.add(activeMqBroker.getJmsConnection());
    ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
    connection.setConnections(ptp);
    LifecycleHelper.init(connection);
    assertEquals(1, connection.currentJmsConnection().retrieveExceptionListeners().size());
    AdaptrisComponent owner = (AdaptrisComponent) connection.currentJmsConnection().retrieveExceptionListeners().toArray()[0];
    assertTrue("Owner should be failover connection", connection == owner);
    LifecycleHelper.close(connection);
    Channel channel = new MockChannel();
    connection = new FailoverJmsConnection();
    connection.setRegisterOwner(true);
    channel.setConsumeConnection(connection);
    ptp = new ArrayList<JmsConnection>();
    ptp.add(activeMqBroker.getJmsConnection());
    ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
    connection.setConnections(ptp);
    LifecycleHelper.init(connection);
    // setting the consume connection no longer sets up the exception handler, so expect 0 here.
    assertEquals(0, connection.currentJmsConnection().retrieveExceptionListeners().size());
    LifecycleHelper.close(connection);
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) AdaptrisComponent(com.adaptris.core.AdaptrisComponent) Test(org.junit.Test)

Aggregations

AdaptrisComponent (com.adaptris.core.AdaptrisComponent)4 Channel (com.adaptris.core.Channel)2 BasicActiveMqImplementation (com.adaptris.core.jms.activemq.BasicActiveMqImplementation)2 MockChannel (com.adaptris.core.stubs.MockChannel)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 AdaptrisMarshaller (com.adaptris.core.AdaptrisMarshaller)1 AllowsRetriesConnection (com.adaptris.core.AllowsRetriesConnection)1 CoreException (com.adaptris.core.CoreException)1