本文整理汇总了Java中org.apache.camel.ProducerTemplate.request方法的典型用法代码示例。如果您正苦于以下问题:Java ProducerTemplate.request方法的具体用法?Java ProducerTemplate.request怎么用?Java ProducerTemplate.request使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.ProducerTemplate
的用法示例。
在下文中一共展示了ProducerTemplate.request方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCxfBusConfiguration
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@Test
public void testCxfBusConfiguration() throws Exception {
// get the camelContext from application context
ProducerTemplate template = context.createProducerTemplate();
Exchange reply = template.request("cxf:bean:serviceEndpoint", new Processor() {
public void process(final Exchange exchange) {
final List<String> params = new ArrayList<String>();
params.add("hello");
exchange.getIn().setBody(params);
exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "echo");
}
});
Exception ex = reply.getException();
assertTrue("Should get the fault here",
ex instanceof org.apache.cxf.interceptor.Fault
|| ex instanceof HTTPException);
}
示例2: testCxfBusConfiguration
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
@Test
public void testCxfBusConfiguration() throws Exception {
// get the camelContext from application context
CamelContext camelContext = ctx.getBean("camel", CamelContext.class);
ProducerTemplate template = camelContext.createProducerTemplate();
Exchange reply = template.request("cxf:bean:serviceEndpoint", new Processor() {
public void process(final Exchange exchange) {
final List<String> params = new ArrayList<String>();
params.add("hello");
exchange.getIn().setBody(params);
exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "echo");
}
});
Exception ex = reply.getException();
assertTrue("Should get the fault here",
ex instanceof org.apache.cxf.interceptor.Fault
|| ex instanceof HTTPException);
}
示例3: main
import org.apache.camel.ProducerTemplate; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
LOG.info("About to run splunk-camel integration...");
CamelContext camelContext = new DefaultCamelContext();
camelContext.addRoutes(new SplunkPublishEventRouteBuilder());
ProducerTemplate eventProducer = camelContext.createProducerTemplate();
camelContext.start();
eventProducer.request("direct:start", new SplunkEventProcessor());
LOG.info("Successfully published event to Splunk.");
camelContext.stop();
}