Search in sources :

Example 6 with ReplaceWithFirstMessage

use of com.adaptris.core.services.aggregator.ReplaceWithFirstMessage in project interlok by adaptris.

the class AggregatingFsConsumeServiceTest method testServiceNonDeleting.

@Test
public void testServiceNonDeleting() throws Exception {
    Object o = new Object();
    File tempFile = TempFileUtils.createTrackedFile(o);
    String url = "file://localhost/" + tempFile.getCanonicalPath().replaceAll("\\\\", "/");
    AggregatingFsConsumer afc = createConsumer(url, null, new ReplaceWithFirstMessage());
    afc.setDeleteAggregatedFiles(false);
    AggregatingFsConsumeService service = createAggregatingService(afc);
    File wipFile = new File(tempFile.getParent(), tempFile.getName() + afc.wipSuffix());
    try {
        writeDataMessage(tempFile);
        start(service);
        AdaptrisMessage msg = new DefaultMessageFactory().newMessage(INITIAL_PAYLOAD);
        service.doService(msg);
        assertNotSame(INITIAL_PAYLOAD, msg.getContent());
        assertEquals(DATA_PAYLOAD, msg.getContent());
        assertTrue(tempFile.exists());
        assertFalse(wipFile.exists());
    } finally {
        stop(service);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) File(java.io.File) ReplaceWithFirstMessage(com.adaptris.core.services.aggregator.ReplaceWithFirstMessage) Test(org.junit.Test)

Example 7 with ReplaceWithFirstMessage

use of com.adaptris.core.services.aggregator.ReplaceWithFirstMessage in project interlok by adaptris.

the class AggregatingJmsConsumeServiceTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    AggregatingJmsConsumeService service = null;
    service = new AggregatingJmsConsumeService();
    JmsConnection jmsConnection = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616"));
    jmsConnection.setConnectionAttempts(2);
    jmsConnection.setConnectionRetryInterval(new TimeInterval(3L, "SECONDS"));
    service.setConnection(jmsConnection);
    AggregatingQueueConsumer consumer = new AggregatingQueueConsumer();
    consumer.setEndpoint("Sample.Q1");
    consumer.setFilterExpression("%message{filterSelectorKey}");
    consumer.setMessageAggregator(new ReplaceWithFirstMessage());
    consumer.setMessageTranslator(new TextMessageTranslator());
    service.setJmsConsumer(consumer);
    return service;
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) TimeInterval(com.adaptris.util.TimeInterval) ReplaceWithFirstMessage(com.adaptris.core.services.aggregator.ReplaceWithFirstMessage)

Example 8 with ReplaceWithFirstMessage

use of com.adaptris.core.services.aggregator.ReplaceWithFirstMessage in project interlok by adaptris.

the class AggregatingJmsConsumeServiceTest method createService.

private AggregatingJmsConsumeService createService(EmbeddedActiveMq broker) {
    AggregatingQueueConsumer consumer = new AggregatingQueueConsumer();
    consumer.setMessageAggregator(new ReplaceWithFirstMessage());
    return createService(broker, consumer);
}
Also used : ReplaceWithFirstMessage(com.adaptris.core.services.aggregator.ReplaceWithFirstMessage)

Aggregations

ReplaceWithFirstMessage (com.adaptris.core.services.aggregator.ReplaceWithFirstMessage)8 Test (org.junit.Test)6 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)5 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)3 FakeFtpServer (org.mockftpserver.fake.FakeFtpServer)3 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)2 File (java.io.File)2 CoreException (com.adaptris.core.CoreException)1 ServiceException (com.adaptris.core.ServiceException)1 BasicActiveMqImplementation (com.adaptris.core.jms.activemq.BasicActiveMqImplementation)1 DefectiveMessageFactory (com.adaptris.core.stubs.DefectiveMessageFactory)1 TimeInterval (com.adaptris.util.TimeInterval)1 FileSystem (org.mockftpserver.fake.filesystem.FileSystem)1