本文整理汇总了Java中org.apache.camel.Consumer类的典型用法代码示例。如果您正苦于以下问题:Java Consumer类的具体用法?Java Consumer怎么用?Java Consumer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Consumer类属于org.apache.camel包,在下文中一共展示了Consumer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
public Consumer createConsumer(Processor processor) throws Exception {
ObjectHelper.notNull(feedUri, "feedUri");
FeedPollingConsumer answer;
if (isSplitEntries()) {
answer = createEntryPollingConsumer(this, processor, filter, lastUpdate, throttleEntries);
} else {
answer = createPollingConsumer(this, processor);
}
// ScheduledPollConsumer default delay is 500 millis and that is too often for polling a feed,
// so we override with a new default value. End user can override this value by providing a consumer.delay parameter
answer.setDelay(FeedPollingConsumer.DEFAULT_CONSUMER_DELAY);
configureConsumer(answer);
return answer;
}
示例2: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
/**
* Create one of the camel consumer available based on the configuration
* @param processor the given processor
* @return the camel consumer
* @throws Exception
*/
public Consumer createConsumer(Processor processor) throws Exception {
LOG.trace("Resolve consumer dropbox endpoint {" + configuration.getOperation().toString() + "}");
LOG.trace("Resolve consumer dropbox attached client:" + configuration.getClient());
DropboxScheduledPollConsumer consumer = null;
if (this.configuration.getOperation() == DropboxOperation.search) {
consumer = new DropboxScheduledPollSearchConsumer(this, processor, configuration);
consumer.setDelay(POLL_CONSUMER_DELAY);
return consumer;
} else if (this.configuration.getOperation() == DropboxOperation.get) {
consumer = new DropboxScheduledPollGetConsumer(this, processor, configuration);
consumer.setDelay(POLL_CONSUMER_DELAY);
return consumer;
} else {
throw new DropboxException("Operation specified is not valid for consumer!");
}
}
示例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: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
public Consumer createConsumer(Processor processor) throws Exception {
if (getComponent() != null) {
// all consumers must match having the same multipleConsumers options
String key = getComponent().getQueueKey(getEndpointUri());
QueueReference ref = getComponent().getQueueReference(key);
if (ref != null && ref.getMultipleConsumers() != isMultipleConsumers()) {
// there is already a multiple consumers, so make sure they matches
throw new IllegalArgumentException("Cannot use existing queue " + key + " as the existing queue multiple consumers "
+ ref.getMultipleConsumers() + " does not match given multiple consumers " + multipleConsumers);
}
}
Consumer answer = createNewConsumer(processor);
configureConsumer(answer);
return answer;
}
示例5: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
@Override
public Consumer createConsumer(Processor processor) throws Exception {
TwitterConsumer twitter4jConsumer = TwitterHelper.createConsumer(this, getEndpointUri());
TwitterConsumerDirect answer = new TwitterConsumerDirect(this, processor, twitter4jConsumer);
configureConsumer(answer);
return answer;
}
示例6: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
public Consumer createConsumer(Processor processor) throws Exception {
switch (config.getFunctionType()) {
case MESSAGES:
case ALGO:
case FOLLOWING:
case MY_FEED:
case PRIVATE:
case SENT:
case RECEIVED:
return new YammerMessagePollingConsumer(this, processor);
case USERS:
case CURRENT:
return new YammerUserPollingConsumer(this, processor);
case RELATIONSHIPS:
return new YammerRelationshipPollingConsumer(this, processor);
default:
throw new Exception(String.format("%s is not a valid Yammer function type.", config.getFunction()));
}
}
示例7: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
@Override
public Consumer createConsumer(CamelContext camelContext, Processor processor, String verb, String basePath, String uriTemplate,
String consumes, String produces, RestConfiguration configuration, Map<String, Object> parameters) throws Exception {
// just use a seda endpoint for testing purpose
String id;
if (uriTemplate != null) {
id = ActiveMQUuidGenerator.generateSanitizedId(basePath + uriTemplate);
} else {
id = ActiveMQUuidGenerator.generateSanitizedId(basePath);
}
// remove leading dash as we add that ourselves
if (id.startsWith("-")) {
id = id.substring(1);
}
SedaEndpoint seda = camelContext.getEndpoint("seda:" + verb + "-" + id, SedaEndpoint.class);
return seda.createConsumer(processor);
}
示例8: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
public Consumer createConsumer(Processor processor) throws Exception {
// make sure inBody is not set for consumers
if (inBody != null) {
throw new IllegalArgumentException("Option inBody is not supported for consumer endpoint");
}
// validate consumer APIs
if (getApiName() != BoxApiName.POLL_EVENTS) {
throw new IllegalArgumentException("Consumer endpoint only supports endpoint prefix "
+ BoxApiName.POLL_EVENTS.getName());
}
final BoxConsumer consumer = new BoxConsumer(this, processor);
// also set consumer.* properties
configureConsumer(consumer);
return consumer;
}
示例9: 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());
}
示例10: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
/**
* Creates a consumer endpoint that splits up the List of Maps into exchanges of single
* Maps, and within each exchange it converts each Map to JSON.
*/
@Override
public Consumer createConsumer(final Processor processor) throws Exception {
final ToJSONProcessor toJsonProcessor = new ToJSONProcessor();
Processor pipeline = Pipeline.newInstance(getCamelContext(), toJsonProcessor, processor);
final Expression expression = ExpressionBuilder.bodyExpression(List.class);
final Splitter splitter = new Splitter(getCamelContext(), expression, pipeline, null);
return endpoint.createConsumer(splitter);
}
示例11: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
@Override
public Consumer createConsumer(final Processor processor) throws Exception {
final Processor beforeConsumer = getBeforeConsumer();
final Processor afterConsumer = getAfterConsumer();
// use a pipeline to process before, processor, after in that order
// create consumer with the pipeline
final Processor pipeline = Pipeline.newInstance(getCamelContext(), beforeConsumer, processor, afterConsumer);
final Consumer consumer = endpoint.createConsumer(pipeline);
configureConsumer(consumer);
return consumer;
}
示例12: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
@Override
public Consumer createConsumer(Processor processor) throws Exception {
SpongeConsumer answer = new SpongeConsumer(this, processor, engine);
configureConsumer(answer);
return answer;
}
示例13: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
@Override
public Consumer createConsumer(Processor processor) throws Exception {
return new JsonConsumer(this, processor);
}
示例14: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
@Override
public Consumer createConsumer(Processor processor) throws Exception {
return new OrientDBConsumer(this, processor);
}
示例15: createConsumer
import org.apache.camel.Consumer; //导入依赖的package包/类
public Consumer createConsumer(Processor processor) throws Exception {
throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
}