当前位置: 首页>>代码示例>>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;未经允许,请勿转载。