use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class RelaxedFtpConsumerTest method setUp.
@Before
public void setUp() throws Exception {
consumer = new RelaxedFtpConsumer();
MockitoAnnotations.initMocks(this);
consumeDestination = "myDestination";
consumer.setFtpEndpoint(consumeDestination);
consumer.registerConnection(mockFtpConnection);
consumer.setPoller(new FixedIntervalPoller(new TimeInterval(1L, TimeUnit.SECONDS)));
consumer.setReacquireLockBetweenMessages(true);
messageListener = new MockMessageListener(10);
standaloneConsumer = new StandaloneConsumer(consumer);
standaloneConsumer.registerAdaptrisMessageListener(messageListener);
standaloneConsumer.setConnection(mockFtpConnection);
when(mockFtpConnection.retrieveConnection(FileTransferConnection.class)).thenReturn(mockFtpConnection);
when(mockFtpConnection.connect(consumeDestination)).thenReturn(mockFileTransferClient);
when(mockFtpConnection.getDirectoryRoot(consumeDestination)).thenReturn(DIR_ROOT);
calendarNow = new GregorianCalendar();
calendarOneYearAgo = new GregorianCalendar();
calendarOneYearAgo.add(Calendar.DAY_OF_YEAR, -1);
}
use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method createPollingWorkflow.
private JmsTransactedWorkflow createPollingWorkflow(EmbeddedActiveMq mq, String threadName, String target) throws CoreException {
JmsTransactedWorkflow workflow = new JmsTransactedWorkflow();
workflow.setProducer(new MockMessageProducer());
workflow.setWaitPeriodAfterRollback(new TimeInterval(10L, TimeUnit.MILLISECONDS.name()));
JmsPollingConsumerImpl jmsCons = new PtpPollingConsumer().withQueue(target);
jmsCons.setReacquireLockBetweenMessages(true);
jmsCons.setAdditionalDebug(true);
jmsCons.setPoller(new FixedIntervalPoller(new TimeInterval(2L, TimeUnit.SECONDS)));
BasicActiveMqImplementation vendorImpl = new BasicActiveMqImplementation();
JmsConnection jmsConn = mq.getJmsConnection(vendorImpl, true);
jmsCons.setVendorImplementation(jmsConn.getVendorImplementation());
jmsCons.setMessageTranslator(new TextMessageTranslator().withMoveJmsHeaders(true));
jmsCons.setClientId(jmsConn.getClientId());
workflow.setConsumer(jmsCons);
return workflow;
}
use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class PtpPollingConsumerTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
PtpPollingConsumer consumer = new PtpPollingConsumer();
consumer.setQueue("MyQueueName");
consumer.setPoller(new FixedIntervalPoller(new TimeInterval(1L, TimeUnit.MINUTES)));
consumer.setUserName("user-name");
consumer.setPassword("password");
consumer.setClientId("client-id");
consumer.setReacquireLockBetweenMessages(true);
StandaloneConsumer result = new StandaloneConsumer(consumer);
return result;
}
use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class ActiveMqPtpPollingConsumerTest method createConsumer.
private StandaloneConsumer createConsumer(EmbeddedActiveMq broker, String threadName, String destinationName) throws Exception {
PtpPollingConsumer consumer = new PtpPollingConsumer().withQueue(destinationName);
consumer.setPoller(new FixedIntervalPoller(new TimeInterval(500L, TimeUnit.MILLISECONDS)));
JmsConnection c = broker.getJmsConnection();
consumer.setClientId(c.configuredClientId());
consumer.setUserName(c.configuredUserName());
consumer.setPassword(c.configuredPassword());
consumer.setReacquireLockBetweenMessages(true);
consumer.setVendorImplementation(c.getVendorImplementation());
StandaloneConsumer sc = new StandaloneConsumer(consumer);
return sc;
}
use of com.adaptris.core.FixedIntervalPoller in project interlok by adaptris.
the class LargeFsConsumerTest method testConsumeWithAlternateFactory.
@Test
public void testConsumeWithAlternateFactory() throws Exception {
String subDir = GUID.safeUUID();
MockMessageListener stub = new MockMessageListener(10);
FsConsumer fs = createConsumer(subDir);
fs.setResetWipFiles(false);
fs.setMessageFactory(new DefaultMessageFactory());
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);
baseDir.mkdirs();
super.createFiles(baseDir, ".xml", count);
start(sc);
waitForMessages(stub, count);
assertEquals(count, stub.getMessages().size());
super.assertMessages(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml")));
assertDefaultMessageType(stub.getMessages());
} finally {
stop(sc);
FileUtils.deleteQuietly(new File(parentDir, subDir));
}
}
Aggregations