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