当前位置: 首页>>代码示例>>Java>>正文


Java Consumer类代码示例

本文整理汇总了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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:FeedEndpoint.java

示例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!");
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:DropboxEndpoint.java

示例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());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:FileConsumerAutoCreateDirectoryTest.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:SedaEndpoint.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:TwitterEndpointDirect.java

示例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()));
    }  

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:YammerEndpoint.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:DummyRestConsumerFactory.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:BoxEndpoint.java

示例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());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:FileConsumerAutoCreateDirectoryTest.java

示例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);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:13,代码来源:RecordSplitterEndpoint.java

示例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;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:14,代码来源:ComponentProxyEndpoint.java

示例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;
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:7,代码来源:SpongeEndpoint.java

示例13: createConsumer

import org.apache.camel.Consumer; //导入依赖的package包/类
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new JsonConsumer(this, processor);
}
 
开发者ID:syndesisio,项目名称:syndesis-integration-runtime,代码行数:5,代码来源:JsonEndpoint.java

示例14: createConsumer

import org.apache.camel.Consumer; //导入依赖的package包/类
@Override
public Consumer createConsumer(Processor processor) throws Exception {

	return new OrientDBConsumer(this, processor);
}
 
开发者ID:OrienteerBAP,项目名称:camel-orientdb,代码行数:6,代码来源:OrientDBEndpoint.java

示例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");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:SesEndpoint.java


注:本文中的org.apache.camel.Consumer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。