Search in sources :

Example 31 with FixedIntervalPoller

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

Example 32 with FixedIntervalPoller

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

Example 33 with FixedIntervalPoller

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

Example 34 with FixedIntervalPoller

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

Example 35 with FixedIntervalPoller

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

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