Apache camel 设置端点(驼峰)
我是骆驼新手,正在学习设置路线 所以我从一个简单的场景开始,我点击一个URL,它会返回一些数据。在这个例子中,我用它来返回数据 这是我的路径设置Apache camel 设置端点(驼峰),apache-camel,Apache Camel,我是骆驼新手,正在学习设置路线 所以我从一个简单的场景开始,我点击一个URL,它会返回一些数据。在这个例子中,我用它来返回数据 这是我的路径设置 from("direct:greet") .autoStartup(true) .routeId("greet") .setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.GET)) .to("http4://services.groupkt.com/c
from("direct:greet")
.autoStartup(true)
.routeId("greet")
.setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.GET))
.to("http4://services.groupkt.com/country/get/all")
现在我有了一个URL/check
的请求映射,当我点击这个URLhttp://localhost:8080/check
它返回这个
{
“时间戳”:1527882311362,
“状态”:404,
“错误”:“未找到”,
“消息”:“没有可用消息”,
“路径”:“/检查”
}
我希望JSON响应会显示您在浏览器中点击URL()时看到的所有国家/地区的数据
映射在其他类中:
@RequestMapping(value = "/check", method = RequestMethod.GET)
public String get(@RequestParam(value = "name") String name) {
return serviceProcessor.getServiceResponse(name);
getServiceResponse如下所示:
public String getServiceResponse(String name) {
final ModelCamelContext context = userServiceRoute.getContext();
final ProducerTemplate template = new DefaultProducerTemplate(context);
try {
template.start();
} catch (Exception e) {
LOGGER.error("Error starting producerTemplate with userServiceRoute" + e);
}
final Endpoint endpoint = context.getEndpoint("direct:greet");
template.setDefaultEndpoint(endpoint);
return template.requestBody((Object)name, String.class);
}
路径设置是否有问题,或者此处的方法本身是否有问题?您的/检查映射在哪里?你怎么称呼它?@pvpkiran我已经在描述中添加了映射