use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class PasPollingConsumerTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
PasPollingConsumer consumer = createConsumer();
consumer.setPoller(new FixedIntervalPoller(new TimeInterval(1L, TimeUnit.MINUTES)));
consumer.setUserName("user-name");
consumer.setPassword("password");
consumer.setClientId("client-id");
consumer.setSubscriptionId("subscription-id");
consumer.setPoller(new FixedIntervalPoller(new TimeInterval(1L, TimeUnit.MINUTES)));
consumer.setReacquireLockBetweenMessages(true);
consumer.setTopic("MyTopic");
StandaloneConsumer result = new StandaloneConsumer();
result.setConsumer(consumer);
return result;
}
use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class FtpRecursiveConsumerTest method testConsumeWithQuietPeriodAndTimezone.
@Test
public void testConsumeWithQuietPeriodAndTimezone() throws Exception {
int count = 1;
EmbeddedFtpServer helper = new EmbeddedFtpServer();
MockMessageListener listener = new MockMessageListener(100);
FileSystem filesystem = helper.createFilesystem_DirsOnly();
for (int i = 0; i < count; i++) {
filesystem.add(new FileEntry(DEFAULT_WORK_DIR_CANONICAL + SLASH + DEFAULT_FILENAME + i + ".txt", PAYLOAD));
}
FakeFtpServer server = helper.createAndStart(filesystem);
StandaloneConsumer sc = null;
try {
AtomicBoolean pollFired = new AtomicBoolean(false);
PollerImp poller = new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)).withPollerCallback(e -> {
log.trace("Poll Fired {}", getName());
if (e == 0) {
pollFired.set(true);
}
});
FtpRecursiveConsumer ftpConsumer = createForTests(listener, "testConsumeWithQuietPeriodAndTimezone", poller);
ftpConsumer.setQuietInterval(new TimeInterval(3L, TimeUnit.SECONDS));
FtpConnection consumeConnection = create(server);
consumeConnection.setAdditionalDebug(true);
consumeConnection.setServerTimezone("America/Los_Angeles");
sc = new StandaloneConsumer(consumeConnection, ftpConsumer);
start(sc);
long waitTime = waitForPollCallback(pollFired);
log.trace("Waited for {}ms for == 0 poll", waitTime);
helper.assertMessages(listener.getMessages(), 0);
assertEquals(count, filesystem.listFiles(DEFAULT_WORK_DIR_CANONICAL).size());
} catch (Exception e) {
throw e;
} finally {
stop(sc);
server.stop();
}
}
use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class FtpRecursiveConsumerTest method testConsumeWithNonMatchingFilter.
@Test
public void testConsumeWithNonMatchingFilter() throws Exception {
int count = 1;
EmbeddedFtpServer helper = new EmbeddedFtpServer();
MockMessageListener listener = new MockMessageListener();
FileSystem filesystem = helper.createFilesystem_DirsOnly();
for (int i = 0; i < count; i++) {
filesystem.add(new FileEntry(DEFAULT_WORK_DIR_CANONICAL + SLASH + DEFAULT_FILENAME + i + ".txt", PAYLOAD));
}
FakeFtpServer server = helper.createAndStart(filesystem);
StandaloneConsumer sc = null;
try {
AtomicBoolean pollFired = new AtomicBoolean(false);
FixedIntervalPoller poller = new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS)).withPollerCallback(e -> {
log.trace("Poll Fired {}", getName());
if (e == 0) {
pollFired.set(true);
}
});
FtpRecursiveConsumer ftpConsumer = createForTests(listener, SERVER_ADDRESS, poller);
ftpConsumer.setFilterExpression("^*.xml$");
ftpConsumer.setFileFilterImp(RegexFileFilter.class.getCanonicalName());
FtpConnection consumeConnection = create(server);
sc = new StandaloneConsumer(consumeConnection, ftpConsumer);
start(sc);
long waitTime = waitForPollCallback(pollFired);
log.trace("Waited for {}ms for == 0 poll", waitTime);
helper.assertMessages(listener.getMessages(), 0);
assertEquals(count, filesystem.listFiles(DEFAULT_WORK_DIR_CANONICAL).size());
} catch (Exception e) {
throw e;
} finally {
stop(sc);
server.stop();
}
}
Aggregations