2016-05-10 84 views
0

问题很简单,但实现似乎难以捉摸。我想只发送一次安装POST到REST服务器,然后在GET成功后每5秒开始使用GET进行轮询。使用Camel CXFRS组件在Camel Spring XML中实现这种外观如何?我不想编写新的代码或骆驼端点,并希望用现有的骆驼工具来做到这一点。骆驼CXF REST:安装后轮询

回答

1

你可以尝试下面的东西。有关骆驼组件的详细信息,请参阅Apache camel documentation

<camelContext xmlns="http://camel.apache.org/schema/spring" 
    <route id="abc" shutdownRoute="Default" streamCache="true"> 
      <from uri="timer://foo?fixedRate=true&amp;period=100000" /> 
      <setHeader headerName="CamelHttpMethod"> 
       <constant>POST</constant> 
      </setHeader> 
      --setheader for Content-Type 
      <recipientList> 
       <simple>https4://post url</simple> 
      </recipientList> 
      <log message="After Transmission " loggingLevel="DEBUG" 
       logName="com.domain" /> 
      <recipientList> 
       <simple>https4://get url</simple> 
      </recipientList> 
      --unmarshall 
</route> 
</camelContext> 
+0

谢谢@RamPrakash!虽然这不会导致服务总是发布帖子,然后获得? – Thirlan

+0

对不起,让我澄清一下我的评论,你的代码不会让它做一个帖子,并得到每100000ms?我期待它可以做2-3次POST,然后每100000ms做一次GET。 – Thirlan

+0

@Thirlan是的。我的不好,看起来我没有完全满足你的要求。同样,您可以在POST和GET之间使用延迟,请参阅本文档以获取更多信息http://camel.apache.org/delayer.html或者您可以为POST'S和GET'S编写多个流程(时间)你的任务。 – RamPrakash