use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JndiPtpProducerCase method testProduceAndConsumeUsingJndiOnly.
@Test
public void testProduceAndConsumeUsingJndiOnly() throws Exception {
StandardJndiImplementation recvVendorImp = createVendorImplementation();
StandardJndiImplementation sendVendorImp = createVendorImplementation();
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, true, queueName, topicName), new PtpConsumer().withQueue(queueName));
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, true, queueName, topicName), new PtpProducer().withQueue((queueName)));
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms);
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JndiPtpProducerCase method testProduceAndConsume_ExtraConfig.
@Test
public void testProduceAndConsume_ExtraConfig() throws Exception {
SimpleFactoryConfiguration sfc = new SimpleFactoryConfiguration();
KeyValuePairSet kvps = new KeyValuePairSet();
kvps.add(new KeyValuePair("ClientID", "testProduceAndConsume_ExtraConfig"));
kvps.add(new KeyValuePair("UseCompression", "true"));
sfc.setProperties(kvps);
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
StandardJndiImplementation recvVendorImp = createVendorImplementation();
StandardJndiImplementation sendVendorImp = createVendorImplementation();
sendVendorImp.setExtraFactoryConfiguration(sfc);
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, false, queueName, topicName), new PtpConsumer().withQueue(queueName));
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, false, queueName, topicName), new PtpProducer().withQueue((queueName)));
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms);
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JmxNotificationConsumerTest method testConsumer.
@Test
public void testConsumer() throws Exception {
MBeanServer mbeanServer = JmxHelper.findMBeanServer();
String myObjectName = "com.adaptris:type=Junit,id=" + getName();
StubNotificationBroadcaster broadcast = new StubNotificationBroadcaster();
MockMessageListener listener = new MockMessageListener();
JmxNotificationConsumer consumer = new JmxNotificationConsumer();
consumer.setObjectName(myObjectName);
StandaloneConsumer sc = wrap(new JmxConnection(), consumer, listener);
try {
mbeanServer.registerMBean(broadcast, ObjectName.getInstance(myObjectName));
// INTERLOK-3329 For coverage so the prepare() warning is executed 2x
LifecycleHelper.prepare(sc);
start(sc);
broadcast.sendNotification(getName(), new Object());
waitForMessages(listener, 1);
assertEquals(1, listener.messageCount());
assertNotNull(listener.getMessages().get(0).getObjectHeaders().get(NotificationSerializer.OBJ_METADATA_USERDATA));
} finally {
stop(sc);
}
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JmxNotificationConsumerTest method wrap.
private StandaloneConsumer wrap(AdaptrisConnection conn, AdaptrisMessageConsumer consumer, AdaptrisMessageListener listener) throws Exception {
StandaloneConsumer sc = new StandaloneConsumer(conn, consumer);
sc.registerAdaptrisMessageListener(listener);
sc.prepare();
return sc;
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class FsMessageConsumerTest method testConsumeImmediateEventPoller.
@Test
public void testConsumeImmediateEventPoller() throws Exception {
String subDir = new GuidGenerator().safeUUID();
MockMessageListener stub = new MockMessageListener(10);
FsConsumer fs = createConsumer(subDir);
fs.setReacquireLockBetweenMessages(true);
fs.setPoller(new FsImmediateEventPoller());
fs.setQuietInterval(new TimeInterval(500L, "MILLISECONDS"));
StandaloneConsumer sc = new StandaloneConsumer(fs);
sc.registerAdaptrisMessageListener(stub);
int count = 10;
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true));
try {
File baseDir = new File(parentDir, subDir);
LifecycleHelper.init(sc);
createFiles(baseDir, ".xml", count);
Thread.sleep(1000);
LifecycleHelper.start(sc);
waitForMessages(stub, count);
assertMessages(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
} finally {
stop(sc);
FileUtils.deleteQuietly(new File(parentDir, subDir));
}
}
Aggregations