Search in sources :

Example 11 with FixedIntervalPoller

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);
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) GregorianCalendar(java.util.GregorianCalendar) FixedIntervalPoller(com.adaptris.core.FixedIntervalPoller) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) Before(org.junit.Before)

Example 12 with FixedIntervalPoller

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;
}
Also used : JmsPollingConsumerImpl(com.adaptris.core.jms.JmsPollingConsumerImpl) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) TimeInterval(com.adaptris.util.TimeInterval) TextMessageTranslator(com.adaptris.core.jms.TextMessageTranslator) PtpPollingConsumer(com.adaptris.core.jms.PtpPollingConsumer) JmsTransactedWorkflow(com.adaptris.core.jms.JmsTransactedWorkflow) JmsConnection(com.adaptris.core.jms.JmsConnection) FixedIntervalPoller(com.adaptris.core.FixedIntervalPoller)

Example 13 with FixedIntervalPoller

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;
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) FixedIntervalPoller(com.adaptris.core.FixedIntervalPoller) StandaloneConsumer(com.adaptris.core.StandaloneConsumer)

Example 14 with FixedIntervalPoller

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;
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) PtpPollingConsumer(com.adaptris.core.jms.PtpPollingConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection) FixedIntervalPoller(com.adaptris.core.FixedIntervalPoller) StandaloneConsumer(com.adaptris.core.StandaloneConsumer)

Example 15 with FixedIntervalPoller

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));
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) FilenameFilter(java.io.FilenameFilter) Perl5FilenameFilter(org.apache.oro.io.Perl5FilenameFilter) Perl5FilenameFilter(org.apache.oro.io.Perl5FilenameFilter) TimeInterval(com.adaptris.util.TimeInterval) FsConsumer(com.adaptris.core.fs.FsConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) FixedIntervalPoller(com.adaptris.core.FixedIntervalPoller) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) File(java.io.File) FsMessageConsumerTest(com.adaptris.core.fs.FsMessageConsumerTest) Test(org.junit.Test)

Aggregations

FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)38 TimeInterval (com.adaptris.util.TimeInterval)38 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)36 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)32 Test (org.junit.Test)31 File (java.io.File)26 GuidGenerator (com.adaptris.util.GuidGenerator)24 FilenameFilter (java.io.FilenameFilter)23 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)23 RandomAccessFile (java.io.RandomAccessFile)20 LargeFsConsumer (com.adaptris.core.lms.LargeFsConsumer)14 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)8 IOException (java.io.IOException)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)8 CoreConstants (com.adaptris.core.CoreConstants)4 CoreException (com.adaptris.core.CoreException)4 PollerImp (com.adaptris.core.PollerImp)4 LifecycleHelper (com.adaptris.core.util.LifecycleHelper)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4