本文整理汇总了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();
}
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}