本文整理匯總了Java中org.apache.camel.ProducerTemplate.requestBodyAndHeaders方法的典型用法代碼示例。如果您正苦於以下問題:Java ProducerTemplate.requestBodyAndHeaders方法的具體用法?Java ProducerTemplate.requestBodyAndHeaders怎麽用?Java ProducerTemplate.requestBodyAndHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.camel.ProducerTemplate
的用法示例。
在下文中一共展示了ProducerTemplate.requestBodyAndHeaders方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: requestBodyAndHeaders
import org.apache.camel.ProducerTemplate; //導入方法依賴的package包/類
public Object requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws Exception {
ProducerTemplate template = context.createProducerTemplate();
Object answer = null;
try {
answer = template.requestBodyAndHeaders(endpointUri, body, headers);
} finally {
template.stop();
}
return answer;
}