Apache camel ApacheCamel轮询rest端点
我有一个rest endpoint sample.org,它返回以下形式的json响应Apache camel ApacheCamel轮询rest端点,apache-camel,Apache Camel,我有一个rest endpoint sample.org,它返回以下形式的json响应 { "response" : "pending" } 我的路线是这样的 from("http://sample.org") .marshal(xmlFormatConverterUtil.getxmlJsonDataFormat()) //To convert into json as I receive data in xml format which needs to be converted
{
"response" : "pending"
}
我的路线是这样的
from("http://sample.org")
.marshal(xmlFormatConverterUtil.getxmlJsonDataFormat()) //To convert into json as I receive data in xml format which needs to be converted to json
我读过,但找不到一个关于如何继续轮询端点的示例,直到它返回“success”响应
是否应该使用轮询消费者?如果是这样的话,可以举一个与我的案例相关的例子。轮询rest端点的任何其他资源都非常有用。您需要从计时器开始,然后调用rest端点。然后,您可以检查结果,如果结果正确,则使用controlbus停止路线。过滤器可用于检查其是否挂起,然后停止继续路由,然后下一个计时器将重试 沿着这条伪路线的一些东西
from timer
to http
marshal
filter (if pending)
stop
end
to something with positive response
to controlbus stop route
您可以在以下网址找到更多详细信息:
- 我也遇到了类似的问题,最后进行了投票
它充当生产者并轮询指定的uri,直到满足指定的谓词或轮询达到最大尝试次数
from(“直接:开始”)
.投票:http://example.com/status?maxRetries=3&successPredicate=#statusSuccess")
轮询端点使用一个简单的处理器,该处理器使用轮询消费者进行轮询
公共类PollProcessor实现处理器{
私有最终字符串uri;
私人最终长请求超时;
私人最终长期;
私有最终整数最大值;
私有最终谓词successPredicate;
公共PollProcessor(字符串uri、长请求超时、长周期、整数最大值、谓词成功谓词){
先决条件。检查参数(最大值>0);
先决条件。checkArgument(句点>=0);
先决条件.checkNotNull(successPredicate);
this.uri=uri;
this.requestTimeoutMs=requestTimeoutMs;
这个周期=周期;
this.maxTries=maxTries;
this.successPredicate=successPredicate;
}
@凌驾
公共作废进程(Exchange)引发异常{
PollingConsumer消费者=exchange.getContext().getEndpoint(uri).createPollingConsumer();
对于(int-tryNumber=1;tryNumber轮询http端点是什么意思?路由正在侦听公开的http url。每当有人向该url发送请求时,您将收到消息。此处没有轮询。通过轮询,我的意思是,我将继续向端点触发GET请求,每次我都将检查我的响应。当响应如果成功了,我将停止投票。新书进展如何?我的第一版全是弯角的。我们有2.5章要写,亨利克将写国际奥委会的章节。但是明年年初我们已经完成了所有的工作,然后是校对、排版。2017年夏天之前就完成了。很好:D我通过在我的路线内用定时器循环解决了这个问题然后重试计数,与您所做的类似。