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


Java Producer类代码示例

本文整理汇总了Java中org.apache.camel.Producer的典型用法代码示例。如果您正苦于以下问题:Java Producer类的具体用法?Java Producer怎么用?Java Producer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Producer类属于org.apache.camel包,在下文中一共展示了Producer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createProducer

import org.apache.camel.Producer; //导入依赖的package包/类
@Override
public Producer createProducer() throws Exception {
    JettyHttpProducer answer = new JettyHttpProducer(this);
    if (client != null) {
        // use shared client, and ensure its started so we can use it
        client.start();
        answer.setSharedClient(client);
        answer.setBinding(getJettyBinding(client));
    } else {
        HttpClient httpClient = createJettyHttpClient();
        answer.setClient(httpClient);
        answer.setBinding(getJettyBinding(httpClient));
    }

    if (isSynchronous()) {
        return new SynchronousDelegateProducer(answer);
    } else {
        return answer;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:21,代码来源:JettyHttpEndpoint.java

示例2: prepareFtpServer

import org.apache.camel.Producer; //导入依赖的package包/类
private void prepareFtpServer() throws Exception {
    // prepares the FTP Server by creating a file on the server that we want to unit
    // test that we can pool and store as a local file
    Endpoint endpoint = context.getEndpoint(getFtpUrl());
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody("Hello World this file will be moved");
    exchange.getIn().setHeader(Exchange.FILE_NAME, "hello.txt");
    Producer producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();

    // assert file is created
    File file = new File(FTP_ROOT_DIR + "/movefile/hello.txt");
    assertTrue("The file should exists", file.exists());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:FromFtpMoveFileTest.java

示例3: testCacheProducerAcquireAndRelease

import org.apache.camel.Producer; //导入依赖的package包/类
public void testCacheProducerAcquireAndRelease() throws Exception {
    ProducerCache cache = new ProducerCache(this, context);
    cache.start();

    assertEquals("Size should be 0", 0, cache.size());

    // test that we cache at most 1000 producers to avoid it eating to much memory
    for (int i = 0; i < 1003; i++) {
        Endpoint e = context.getEndpoint("direct:queue:" + i);
        Producer p = cache.acquireProducer(e);
        cache.releaseProducer(e, p);
    }

    // the eviction is async so force cleanup
    cache.cleanUp();

    assertEquals("Size should be 1000", 1000, cache.size());
    cache.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:DefaultProducerCacheTest.java

示例4: sendExchange

import org.apache.camel.Producer; //导入依赖的package包/类
private Exchange sendExchange(boolean setException) throws Exception {
    Endpoint endpoint = context.getEndpoint("netty:tcp://localhost:{{port}}?transferExchange=true");
    Exchange exchange = endpoint.createExchange();

    Message message = exchange.getIn();
    message.setBody("Hello!");
    message.setHeader("cheese", "feta");
    exchange.setProperty("ham", "old");
    exchange.setProperty("setException", setException);

    Producer producer = endpoint.createProducer();
    producer.start();

    // ensure to stop producer after usage
    try {
        producer.process(exchange);
    } finally {
        producer.stop();
    }

    return exchange;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:NettyTransferExchangeOptionTest.java

示例5: ProducerCache

import org.apache.camel.Producer; //导入依赖的package包/类
public ProducerCache(Object source, CamelContext camelContext, ServicePool<Endpoint, Producer> producerServicePool, Map<String, Producer> cache) {
    this.source = source;
    this.camelContext = camelContext;
    if (producerServicePool == null) {
        // use shared producer pool which lifecycle is managed by CamelContext
        this.pool = camelContext.getProducerServicePool();
        this.stopServicePool = false;
    } else {
        this.pool = producerServicePool;
        this.stopServicePool = true;
    }
    this.producers = cache;
    if (producers instanceof LRUCache) {
        maxCacheSize = ((LRUCache) producers).getMaxCacheSize();
    }

    // only if JMX is enabled
    if (camelContext.getManagementStrategy().getManagementAgent() != null) {
        this.extendedStatistics = camelContext.getManagementStrategy().getManagementAgent().getStatisticsLevel().isExtended();
    } else {
        this.extendedStatistics = false;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:ProducerCache.java

示例6: sendExchange

import org.apache.camel.Producer; //导入依赖的package包/类
private Exchange sendExchange(boolean setException) throws Exception {
    Endpoint endpoint = context.getEndpoint("mina:vm://localhost:{{port}}?sync=true&encoding=UTF-8&transferExchange=true");
    Exchange exchange = endpoint.createExchange();

    Message message = exchange.getIn();
    message.setBody("Hello!");
    message.setHeader("cheese", "feta");
    exchange.setProperty("ham", "old");
    exchange.setProperty("setException", setException);

    Producer producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);

    return exchange;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:MinaVMTransferExchangeOptionTest.java

示例7: acquireProducer

import org.apache.camel.Producer; //导入依赖的package包/类
@Override
public Producer acquireProducer(Endpoint endpoint) {
    // always create a new producer
    Producer answer;
    try {
        answer = endpoint.createProducer();
        if (getCamelContext().isStartingRoutes() && answer.isSingleton()) {
            // if we are currently starting a route, then add as service and enlist in JMX
            // - but do not enlist non-singletons in JMX
            // - note addService will also start the service
            getCamelContext().addService(answer);
        } else {
            // must then start service so producer is ready to be used
            ServiceHelper.startService(answer);
        }
    } catch (Exception e) {
        throw new FailedToCreateProducerException(endpoint, e);
    }
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:EmptyProducerCache.java

示例8: prepareFtpServer

import org.apache.camel.Producer; //导入依赖的package包/类
private void prepareFtpServer() throws Exception {
    // prepares the FTP Server by creating a file on the server that we want to unit
    // test that we can pool and store as a local file
    String ftpUrl = "ftp://[email protected]:" + getPort() + "/incoming?password=admin&binary=true"
            + "&consumer.delay=2000&recursive=false";
    Endpoint endpoint = context.getEndpoint(ftpUrl);
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody(IOConverter.toFile("src/test/data/ftpbinarytest/logo.jpeg"));
    exchange.getIn().setHeader(Exchange.FILE_NAME, "logo.jpeg");
    Producer producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();

    ftpUrl = "ftp://[email protected]:" + getPort() + "/incoming/a?password=admin&binary=true"
            + "&consumer.delay=2000&recursive=false";
    endpoint = context.getEndpoint(ftpUrl);
    exchange = endpoint.createExchange();
    exchange.getIn().setBody(IOConverter.toFile("src/test/data/ftpbinarytest/logo1.jpeg"));
    exchange.getIn().setHeader(Exchange.FILE_NAME, "logo1.jpeg");
    producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:FromFtpToBinaryFilesTest.java

示例9: testSedaEndpoint

import org.apache.camel.Producer; //导入依赖的package包/类
public void testSedaEndpoint() throws Exception {
    SedaEndpoint seda = new SedaEndpoint("seda://foo", context.getComponent("seda"), queue);
    assertNotNull(seda);

    assertEquals(1000, seda.getSize());
    assertSame(queue, seda.getQueue());
    assertEquals(1, seda.getConcurrentConsumers());

    Producer prod = seda.createProducer();
    seda.onStarted((SedaProducer) prod);
    assertEquals(1, seda.getProducers().size());

    Consumer cons = seda.createConsumer(new Processor() {
        public void process(Exchange exchange) throws Exception {
            // do nothing
        }
    });
    seda.onStarted((SedaConsumer) cons);
    assertEquals(1, seda.getConsumers().size());

    assertEquals(0, seda.getExchanges().size());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:SedaEndpointTest.java

示例10: createProducer

import org.apache.camel.Producer; //导入依赖的package包/类
@Override
public Producer createProducer() throws Exception {
    final Producer producer = endpoint.createProducer();

    final Processor beforeProducer = getBeforeProducer();
    final Processor afterProducer = getAfterProducer();

    // use a pipeline to process before, producer, after in that order
    // create producer with the pipeline
    final Processor pipeline = Pipeline.newInstance(getCamelContext(), beforeProducer, producer, afterProducer);

    return new ComponentProxyProducer(endpoint, pipeline);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:14,代码来源:ComponentProxyEndpoint.java

示例11: createProducer

import org.apache.camel.Producer; //导入依赖的package包/类
public Producer createProducer() throws Exception {
    if (room != null) {
        return createGroupChatProducer();
    } else {
        if (isPubsub()) {
            return createPubSubProducer();
        }
        if (getParticipant() == null) {
            throw new IllegalArgumentException("No room or participant configured on this endpoint: " + this);
        }
        return createPrivateChatProducer(getParticipant());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:XmppEndpoint.java

示例12: sendMessage

import org.apache.camel.Producer; //导入依赖的package包/类
private void sendMessage() throws Exception {
    Endpoint endpoint = context.getEndpoint(URI);
    Producer producer = endpoint.createProducer();

    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody("Hello World");

    producer.start();
    producer.process(exchange);
    producer.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:Mina2ProducerShutdownTest.java

示例13: createProducer

import org.apache.camel.Producer; //导入依赖的package包/类
public Producer createProducer() throws Exception {
    String[] uriSplit = splitUri(getEndpointUri());
    if (uriSplit.length > 0) {
        ProducerType producerType = ProducerType.fromUri(uriSplit[0]);
        return new SplunkProducer(this, producerType);
    }
    throw new IllegalArgumentException("Cannot create any producer with uri " + getEndpointUri() + ". A producer type was not provided (or an incorrect pairing was used).");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:SplunkEndpoint.java

示例14: createProducer

import org.apache.camel.Producer; //导入依赖的package包/类
@Override
public Producer createProducer() throws Exception {
    LOG.trace("Creating {} Spark producer.", endpointType);
    if (endpointType == EndpointType.rdd) {
        LOG.trace("About to create RDD producer.");
        return new RddSparkProducer(this);
    } else if (endpointType == EndpointType.dataframe) {
        LOG.trace("About to create DataFrame producer.");
        return new DataFrameSparkProducer(this);
    } else {
        LOG.trace("About to create Hive producer.");
        return new HiveSparkProducer(this);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:SparkEndpoint.java

示例15: testSedaQueue

import org.apache.camel.Producer; //导入依赖的package包/类
public void testSedaQueue() throws Exception {
    CamelContext container = new DefaultCamelContext();

    final AtomicBoolean invoked = new AtomicBoolean();

    // lets add some routes
    container.addRoutes(new RouteBuilder() {
        public void configure() {
            from("direct:test.a").to("direct:test.b");
            from("direct:test.b").process(new Processor() {
                public void process(Exchange e) {
                    invoked.set(true);
                }
            });
        }
    });

    container.start();

    // now lets fire in a message
    Endpoint endpoint = container.getEndpoint("direct:test.a");
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setHeader("cheese", 123);

    Producer producer = endpoint.createProducer();
    producer.process(exchange);

    // now lets sleep for a while
    assertTrue("Did not receive the message!", invoked.get());

    container.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:DirectRouteTest.java


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