use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class NonDeletingFsConsumerTest method testBug2100_OriginalNameContainsWip.
@Test
public void testBug2100_OriginalNameContainsWip() throws Exception {
String subDir = new GuidGenerator().safeUUID();
MockMessageListener stub = new MockMessageListener(10);
NonDeletingFsConsumer fs = createConsumer(subDir, "testBug2100_OriginalNameContainsWip");
fs.setReacquireLockBetweenMessages(true);
fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.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);
LifecycleHelper.start(sc);
waitForMessages(stub, count);
assertMessages(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
for (AdaptrisMessage msg : stub.getMessages()) {
assertFalse("original name should not contain '.wip'", msg.getMetadataValue(CoreConstants.ORIGINAL_NAME_KEY).endsWith(".wip"));
}
} finally {
stop(sc);
FileUtils.deleteQuietly(new File(parentDir, subDir));
}
}
use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class TraversingFsConsumerTest method testConsume_WithFilter.
@Test
public void testConsume_WithFilter() throws Exception {
String subDir = new GuidGenerator().safeUUID();
MockMessageListener stub = new MockMessageListener(10);
FsConsumer fs = createConsumer(subDir);
fs.setFilterExpression(".*xml");
fs.setReacquireLockBetweenMessages(true);
fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.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);
start(sc);
createFiles(baseDir, ".xml", count);
waitForMessages(stub, count);
assertMessages(stub.getMessages(), count);
} finally {
stop(sc);
File baseDir = new File(parentDir, subDir);
}
}
use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class TraversingFsConsumerTest method testConsume.
@Test
public void testConsume() throws Exception {
String subDir = new GuidGenerator().safeUUID();
MockMessageListener stub = new MockMessageListener(10);
FsConsumer fs = createConsumer(subDir);
fs.setReacquireLockBetweenMessages(true);
fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.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);
start(sc);
createFiles(baseDir, ".xml", count);
waitForMessages(stub, count);
assertMessages(stub.getMessages(), count);
} finally {
stop(sc);
FileUtils.deleteQuietly(new File(parentDir, subDir));
}
}
use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class JmsSyncConsumerTest method createConsumer.
protected JmsSyncConsumer createConsumer(boolean destQueue, boolean deferConsumerCreationToVendor) {
JmsSyncConsumer consumer = new JmsSyncConsumer();
consumer.setPoller(new FixedIntervalPoller(new TimeInterval(1L, TimeUnit.MINUTES)));
consumer.setReacquireLockBetweenMessages(true);
String dest = "jms:topic:MyTopicName?subscriptionId=mySubscriptionId";
if (destQueue) {
dest = "jms:queue:MyQueueName";
}
consumer.setEndpoint(dest);
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
consumer.setDeferConsumerCreationToVendor(deferConsumerCreationToVendor);
return consumer;
}
use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class JmsPollingConsumerTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
JmsPollingConsumer consumer = createConsumer();
consumer.setPoller(new FixedIntervalPoller(new TimeInterval(1L, TimeUnit.MINUTES)));
consumer.setUserName("user-name");
consumer.setPassword("password");
consumer.setClientId("client-id");
consumer.setReacquireLockBetweenMessages(true);
consumer.setEndpoint("jms:topic:MyTopicName?subscriptionId=mySubscriptionId");
StandaloneConsumer result = new StandaloneConsumer();
result.setConsumer(consumer);
return result;
}
Aggregations