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);
}
}
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);
}
}
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();
}
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);
}
Aggregations