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


Java Endpoint.createProducer方法代码示例

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


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

示例1: retrieveAlsoDocumentContent

import org.apache.camel.Endpoint; //导入方法依赖的package包/类
@Test
public void retrieveAlsoDocumentContent() throws Exception {
    Endpoint endpoint = context.getEndpoint("cmis://" + getUrl() + "?queryMode=true");
    Producer producer = endpoint.createProducer();

    Exchange exchange = createExchangeWithInBody(
            "SELECT * FROM cmis:document WHERE cmis:name='test1.txt'");
    exchange.getIn().getHeaders().put("CamelCMISRetrieveContent", true);

    producer.process(exchange);

    @SuppressWarnings("unchecked")
    List<Map<String, Object>> documents = exchange.getOut().getBody(List.class);
    InputStream content = (InputStream)documents.get(0).get("CamelCMISContent");
    assertEquals("This is the first Camel test content.", readFromStream(content));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:CMISQueryProducerTest.java

示例2: prepareFtpServer

import org.apache.camel.Endpoint; //导入方法依赖的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 deleted");
    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 + "/deletefile/hello.txt");
    assertTrue("The file should exists", file.exists());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:FromFtpSedaDeleteFileTest.java

示例3: sendExchange

import org.apache.camel.Endpoint; //导入方法依赖的package包/类
private Exchange sendExchange(boolean setException) throws Exception {
    Endpoint endpoint = context.getEndpoint("mina:tcp://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,代码来源:MinaTransferExchangeOptionTest.java

示例4: testCamelEndpointInvocation

import org.apache.camel.Endpoint; //导入方法依赖的package包/类
@Test
public void testCamelEndpointInvocation() throws Exception {
    // get the endpoint from the camel context
    Endpoint endpoint = context.getEndpoint("jms:queue:numbers");

    // create the exchange used for the communication
    // we use the in out pattern for a synchronized exchange where we expect a response
    Exchange exchange = endpoint.createExchange(ExchangePattern.InOut);
    // set the input on the in body
    // must you correct type to match the expected type of an Integer object
    exchange.getIn().setBody(11);

    // to send the exchange we need an producer to do it for us
    Producer producer = endpoint.createProducer();
    // start the producer so it can operate
    producer.start();

    // let the producer process the exchange where it does all the work in this one line of code
    producer.process(exchange);

    // get the response from the out body and cast it to an integer
    int response = exchange.getOut().getBody(Integer.class);
    
    assertEquals("Get a wrong response.", 33, response);

    // stop the producer after usage
    producer.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:29,代码来源:SpringJmsClientServerTest.java

示例5: prepareFtpServer

import org.apache.camel.Endpoint; //导入方法依赖的package包/类
private void prepareFtpServer() throws Exception {
    // create a binary file .. uploaded to the default root location
    Endpoint endpoint = context.getEndpoint(getFtpUrl());
    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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:FromFileToFtpDefaultRootRenameStrategyTest.java

示例6: testNoPathCreateTempFileName

import org.apache.camel.Endpoint; //导入方法依赖的package包/类
public void testNoPathCreateTempFileName() throws Exception {
    Endpoint endpoint = context.getEndpoint(fileUrl);
    GenericFileProducer<?> producer = (GenericFileProducer<?>) endpoint.createProducer();
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setHeader(Exchange.FILE_NAME, "claus.txt");

    String tempFileName = producer.createTempFileName(exchange, ".");
    assertDirectoryEquals("inprogress.claus.txt", tempFileName);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:FileProduceTempPrefixTest.java

示例7: failConnectingToNonExistingRepository

import org.apache.camel.Endpoint; //导入方法依赖的package包/类
@Test(expected = CmisInvalidArgumentException.class)
public void failConnectingToNonExistingRepository() throws Exception {
    Endpoint endpoint = context.getEndpoint("cmis://" + getUrl()
            + "?username=admin&password=admin&repositoryId=NON_EXISTING_ID");
    Producer producer = endpoint.createProducer();

    Exchange exchange = createExchangeWithInBody("Some content to be store");
    exchange.getIn().getHeaders().put(PropertyIds.NAME, "test.txt");
    producer.process(exchange);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:CMISProducerTest.java

示例8: prepareFtpServer

import org.apache.camel.Endpoint; //导入方法依赖的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
    Endpoint endpoint = context.getEndpoint(getFtpUrl());
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody("Hello World");
    exchange.getIn().setHeader(Exchange.FILE_NAME, "hello.txt");
    Producer producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:FtpConsumerLocalWorkDirectoryTest.java

示例9: uploadFile

import org.apache.camel.Endpoint; //导入方法依赖的package包/类
private void uploadFile(String username, String password) throws Exception {
    Endpoint endpoint = context.getEndpoint("ftp://" + username + "@localhost:" + getPort() + "/login?password=" + password);

    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody("Hello World from FTPServer");
    exchange.getIn().setHeader(Exchange.FILE_NAME, "report.txt");
    Producer producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:FtpLoginTest.java

示例10: prepareFtpServer

import org.apache.camel.Endpoint; //导入方法依赖的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("ftp://[email protected]:" + getPort() + "/nolist/?password=admin&binary=false");
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody("Hello World from FTPServer");
    exchange.getIn().setHeader(Exchange.FILE_NAME, "report.txt");
    Producer producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:FtpConsumerTemplateUseListFalseTest.java

示例11: testSendExchangeWithException

import org.apache.camel.Endpoint; //导入方法依赖的package包/类
public void testSendExchangeWithException() throws Exception {
    Endpoint endpoint = resolveMandatoryEndpoint("log:org.apache.camel.TEST?showException=true");
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody("Hello World");
    exchange.setException(new IllegalArgumentException("Damn"));

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

示例12: testSendCaughtExchangeWithException

import org.apache.camel.Endpoint; //导入方法依赖的package包/类
public void testSendCaughtExchangeWithException() throws Exception {
    Endpoint endpoint = resolveMandatoryEndpoint("log:org.apache.camel.TEST?showCaughtException=true");
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody("Hello World");
    exchange.setProperty(Exchange.EXCEPTION_CAUGHT, new IllegalArgumentException("I am caught"));

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

示例13: prepareFtpServer

import org.apache.camel.Endpoint; //导入方法依赖的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("ftp://[email protected]:" + getPort() + "/fileonly/?password=admin&binary=false");
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody("Hello World from FTPServer");
    exchange.getIn().setHeader(Exchange.FILE_NAME, "report.txt");
    Producer producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:FromFtpPollFileOnlyTest.java

示例14: prepareFtpServer

import org.apache.camel.Endpoint; //导入方法依赖的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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:FromFtpPreMoveNoopTest.java

示例15: testSedaQueue

import org.apache.camel.Endpoint; //导入方法依赖的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.Endpoint.createProducer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。