本文整理匯總了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;
}