當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。