當前位置: 首頁>>代碼示例>>Java>>正文


Java Consumer.stop方法代碼示例

本文整理匯總了Java中org.apache.camel.Consumer.stop方法的典型用法代碼示例。如果您正苦於以下問題:Java Consumer.stop方法的具體用法?Java Consumer.stop怎麽用?Java Consumer.stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.camel.Consumer的用法示例。


在下文中一共展示了Consumer.stop方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCreateDirectory

import org.apache.camel.Consumer; //導入方法依賴的package包/類
public void testCreateDirectory() throws Exception {
    deleteDirectory("target/file/foo");

    Endpoint endpoint = context.getEndpoint("file://target/file/foo");
    Consumer consumer = endpoint.createConsumer(new Processor() {
        public void process(Exchange exchange) throws Exception {
            // noop
        }
    });

    consumer.start();
    consumer.stop();

    // the directory should now exists
    File dir = new File("target/file/foo");
    assertTrue("Directory should be created", dir.exists());
    assertTrue("Directory should be a directory", dir.isDirectory());
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:19,代碼來源:FileConsumerAutoCreateDirectoryTest.java

示例2: testCreateAbsoluteDirectory

import org.apache.camel.Consumer; //導入方法依賴的package包/類
public void testCreateAbsoluteDirectory() throws Exception {
    deleteDirectory("target/file/foo");
    // use current dir as base as absolute path
    String base = new File("").getAbsolutePath() + "/target/file/foo";

    Endpoint endpoint = context.getEndpoint("file://" + base);
    Consumer consumer = endpoint.createConsumer(new Processor() {
        public void process(Exchange exchange) throws Exception {
            // noop
        }
    });

    consumer.start();
    consumer.stop();

    // the directory should now exists
    File dir = new File(base);
    assertTrue("Directory should be created", dir.exists());
    assertTrue("Directory should be a directory", dir.isDirectory());
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:21,代碼來源:FileConsumerAutoCreateDirectoryTest.java

示例3: testDoNotCreateDirectory

import org.apache.camel.Consumer; //導入方法依賴的package包/類
public void testDoNotCreateDirectory() throws Exception {
    deleteDirectory("target/file/foo");

    Endpoint endpoint = context.getEndpoint("file://target/file/foo?autoCreate=false");
    Consumer consumer = endpoint.createConsumer(new Processor() {
        public void process(Exchange exchange) throws Exception {
            // noop
        }
    });

    consumer.start();
    consumer.stop();

    // the directory should NOT exists
    File dir = new File("target/file/foo");
    assertFalse("Directory should NOT be created", dir.exists());
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:18,代碼來源:FileConsumerAutoCreateDirectoryTest.java

示例4: testAutoCreateDirectoryWithDot

import org.apache.camel.Consumer; //導入方法依賴的package包/類
public void testAutoCreateDirectoryWithDot() throws Exception {
    deleteDirectory("target/file/foo.bar");

    Endpoint endpoint = context.getEndpoint("file://target/file/foo.bar?autoCreate=true");
    Consumer consumer = endpoint.createConsumer(new Processor() {
        public void process(Exchange exchange) throws Exception {
            // noop
        }
    });

    consumer.start();
    consumer.stop();

    // the directory should exist
    File dir = new File("target/file/foo.bar");
    assertTrue("Directory should be created", dir.exists());
    assertTrue("Directory should be a directory", dir.isDirectory());
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:19,代碼來源:FileConsumerAutoCreateDirectoryTest.java

示例5: testFile

import org.apache.camel.Consumer; //導入方法依賴的package包/類
@Test
public void testFile() throws Exception {
    context.start();

    try {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedBodiesReceived("Hello");

        // can not use route builder as we need to have the file created in the setup before route builder starts
        Endpoint endpoint = context.getEndpoint("stream:file?fileName=target/stream/streamfile.txt&delay=100");
        Consumer consumer = endpoint.createConsumer(new Processor() {
            public void process(Exchange exchange) throws Exception {
                template.send("mock:result", exchange);
            }
        });
        consumer.start();

        assertMockEndpointsSatisfied();

        consumer.stop();
    } finally {
        fos.close();
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:25,代碼來源:StreamFileTest.java

示例6: getAllContentFromServerOrderedFromRootToLeaves

import org.apache.camel.Consumer; //導入方法依賴的package包/類
@Test
public void getAllContentFromServerOrderedFromRootToLeaves() throws Exception {
    resultEndpoint.expectedMessageCount(5);

    Consumer treeBasedConsumer = createConsumerFor(getUrl());
    treeBasedConsumer.start();

    resultEndpoint.assertIsSatisfied();
    treeBasedConsumer.stop();

    List<Exchange> exchanges = resultEndpoint.getExchanges();
    assertTrue(getNodeNameForIndex(exchanges, 0).equals("RootFolder"));
    assertTrue(getNodeNameForIndex(exchanges, 1).equals("Folder1"));
    assertTrue(getNodeNameForIndex(exchanges, 2).equals("Folder2"));
    assertTrue(getNodeNameForIndex(exchanges, 3).contains(".txt"));
    assertTrue(getNodeNameForIndex(exchanges, 4).contains(".txt"));
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:18,代碼來源:CMISConsumerTest.java

示例7: rollback

import org.apache.camel.Consumer; //導入方法依賴的package包/類
public boolean rollback(Consumer consumer, Endpoint endpoint, int retryCounter, Exception cause) throws Exception {
    if (cause.getMessage().equals("Damn I cannot do this")) {
        event += "rollback";
        // stop consumer as it does not work
        consumer.stop();
    }
    return false;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:9,代碼來源:FileConsumerPollStrategyStopOnRollbackTest.java

示例8: testNewFileConsumer

import org.apache.camel.Consumer; //導入方法依賴的package包/類
public void testNewFileConsumer() throws Exception {
    FileComponent comp = new FileComponent();
    comp.setCamelContext(context);

    // create a file to consume
    createDirectory("target/consumefile");
    FileOutputStream fos = new FileOutputStream(new File("target/consumefile/hello.txt"));
    try {
        fos.write("Hello World".getBytes());
    } finally {
        fos.close();
    }

    Endpoint endpoint = comp.createEndpoint("file://target/consumefile", "target/consumefile", new HashMap<String, Object>());
    Consumer consumer = endpoint.createConsumer(new Processor() {
        public void process(Exchange exchange) throws Exception {
            assertNotNull(exchange);
            String body = exchange.getIn().getBody(String.class);
            assertEquals("Hello World", body);
            latch.countDown();
        }
    });
    consumer.start();
    latch.await();

    consumer.stop();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:28,代碼來源:NewFileConsumeTest.java

示例9: rollback

import org.apache.camel.Consumer; //導入方法依賴的package包/類
public boolean rollback(Consumer consumer, Endpoint endpoint, int retryCounter, Exception cause) throws Exception {
    GenericFileOperationFailedException e = assertIsInstanceOf(GenericFileOperationFailedException.class, cause);
    assertEquals(530, e.getCode());

    // stop the consumer
    consumer.stop();

    latch.countDown();

    return false;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:12,代碼來源:FtpConsumerThrowExceptionOnLoginFailedTest.java

示例10: testConsumerManyMessages

import org.apache.camel.Consumer; //導入方法依賴的package包/類
@Test
public void testConsumerManyMessages() throws Exception {
    List<Object> messages = Lists.newArrayList();
    Consumer consumer = context.getEndpoint("ignite:messaging:TOPIC1").createConsumer(storeBodyInListProcessor(messages));
    consumer.start();

    Set<Integer> messagesToSend = ContiguousSet.create(Range.closedOpen(0, 100), DiscreteDomain.integers());
    ignite().message().send(TOPIC1, messagesToSend);

    await().atMost(5, TimeUnit.SECONDS).untilCall(to(messages).size(), equalTo(100));

    consumer.stop();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:14,代碼來源:IgniteMessagingTest.java

示例11: consumeDocumentsWithQuery

import org.apache.camel.Consumer; //導入方法依賴的package包/類
@Test
public void consumeDocumentsWithQuery() throws Exception {
    resultEndpoint.expectedMessageCount(2);

    Consumer queryBasedConsumer = createConsumerFor(
            getUrl() + "?query=SELECT * FROM cmis:document");
    queryBasedConsumer.start();
    resultEndpoint.assertIsSatisfied();
    queryBasedConsumer.stop();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:11,代碼來源:CMISConsumerTest.java


注:本文中的org.apache.camel.Consumer.stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。