本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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());
}
示例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();
}
}
示例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"));
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}