本文整理匯總了Java中org.apache.camel.Consumer.start方法的典型用法代碼示例。如果您正苦於以下問題:Java Consumer.start方法的具體用法?Java Consumer.start怎麽用?Java Consumer.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.camel.Consumer
的用法示例。
在下文中一共展示了Consumer.start方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: begin
import org.apache.camel.Consumer; //導入方法依賴的package包/類
public boolean begin(Consumer consumer, Endpoint endpoint) {
// start consumer as we simulate the fail in begin
// and thus before camel lazy start it itself
try {
consumer.start();
} catch (Exception e) {
ObjectHelper.wrapRuntimeCamelException(e);
}
if (counter++ == 0) {
// simulate an error on first poll
throw new IllegalArgumentException("Damn I cannot do this");
}
return true;
}
示例2: 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());
}
示例3: 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());
}
示例4: 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());
}
示例5: 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());
}
示例6: 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();
}
}
示例7: 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"));
}
示例8: bindToRegistry
import org.apache.camel.Consumer; //導入方法依賴的package包/類
private void bindToRegistry(JndiRegistry jndi) throws Exception {
Component comp = new DirectComponent();
comp.setCamelContext(context);
Endpoint slow = comp.createEndpoint("direct:somename");
Consumer consumer = slow.createConsumer(new Processor() {
public void process(Exchange exchange) throws Exception {
template.send("mock:result", exchange);
}
});
consumer.start();
// bind our endpoint to the registry for ref to lookup
jndi.bind("foo", slow);
}
示例9: 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();
}
示例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();
}