當前位置: 首頁>>代碼示例>>Java>>正文


Java ProducerTemplate.requestBodyAndHeader方法代碼示例

本文整理匯總了Java中org.apache.camel.ProducerTemplate.requestBodyAndHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java ProducerTemplate.requestBodyAndHeader方法的具體用法?Java ProducerTemplate.requestBodyAndHeader怎麽用?Java ProducerTemplate.requestBodyAndHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.camel.ProducerTemplate的用法示例。


在下文中一共展示了ProducerTemplate.requestBodyAndHeader方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testJaxrsProducer

import org.apache.camel.ProducerTemplate; //導入方法依賴的package包/類
@Test
public void testJaxrsProducer() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
            .setHeader(Exchange.HTTP_METHOD, constant("GET")).
            to("cxfrs://" + getEndpointAddress("/") + "?resourceClasses=" + GreetingService.class.getName());
        }
    });

    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        String result = producer.requestBodyAndHeader("direct:start", "mybody", "name", "Kermit", String.class);
        Assert.assertEquals("Hello Kermit", result);
    } finally {
        camelctx.stop();
    }
}
 
開發者ID:wildfly-swarm-archive,項目名稱:wildfly-swarm-camel,代碼行數:22,代碼來源:JAXRSProducerTest.java

示例2: main

import org.apache.camel.ProducerTemplate; //導入方法依賴的package包/類
public static void main(String args[]) throws Exception {
    CamelContext context = new DefaultCamelContext();
    // Set up the ActiveMQ JMS Components
    ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:51616");
    // Note we can explicit name of the component
    context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
    context.start();

    ProducerTemplate template = context.createProducerTemplate();

    String out = template.requestBodyAndHeader("jms:queue:loan", null, Constants.PROPERTY_SSN, "Client-A", String.class);
    System.out.println(out);

    template.stop();
    context.stop();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:Client.java

示例3: testRequestUsingDefaultEndpoint

import org.apache.camel.ProducerTemplate; //導入方法依賴的package包/類
public void testRequestUsingDefaultEndpoint() throws Exception {
    ProducerTemplate producer = new DefaultProducerTemplate(context, context.getEndpoint("direct:out"));
    producer.start();

    Object out = producer.requestBody("Hello");
    assertEquals("Bye Bye World", out);

    out = producer.requestBodyAndHeader("Hello", "foo", 123);
    assertEquals("Bye Bye World", out);

    Map<String, Object> headers = new HashMap<String, Object>();
    out = producer.requestBodyAndHeaders("Hello", headers);
    assertEquals("Bye Bye World", out);

    out = producer.requestBodyAndHeaders("Hello", null);
    assertEquals("Bye Bye World", out);

    producer.stop();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:20,代碼來源:DefaultProducerTemplateTest.java

示例4: sendAddToCatalogRequest

import org.apache.camel.ProducerTemplate; //導入方法依賴的package包/類
public String sendAddToCatalogRequest(ProducerTemplate template, String endpointUri, String operation, Book book) throws Exception {
    String response = (String) template.requestBodyAndHeader(endpointUri, book, "ROUTE_DISPATCH_KEY", operation);  
    return response;      
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:5,代碼來源:RouteboxDemoTestSupport.java

示例5: sendFindBookRequest

import org.apache.camel.ProducerTemplate; //導入方法依賴的package包/類
public Book sendFindBookRequest(ProducerTemplate template, String endpointUri, String operation, String body) throws Exception {
    Book response = (Book) template.requestBodyAndHeader(endpointUri, body, "ROUTE_DISPATCH_KEY", operation);  
    return response;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:5,代碼來源:RouteboxDemoTestSupport.java


注:本文中的org.apache.camel.ProducerTemplate.requestBodyAndHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。