Apache camel 如何使用ApacheCamel使用分块HTTP流?
我在使用Camel使用分块的httprsvp流时遇到了一个问题 该流是可用的,您可以在本文末尾找到有关它的更多信息 我创建了一条简单的路线,例如:Apache camel 如何使用ApacheCamel使用分块HTTP流?,apache-camel,Apache Camel,我在使用Camel使用分块的httprsvp流时遇到了一个问题 该流是可用的,您可以在本文末尾找到有关它的更多信息 我创建了一条简单的路线,例如: from("http4://stream.meetup.com/2/rsvps").log(org.apache.camel.LoggingLevel.INFO, "MeetupElasticSearch.Log", "JSON RSVP ${body}") 但是什么也没有发生,没有消息被消耗。我以前尝试过添加camel计时器,因为我不确定您是否可
from("http4://stream.meetup.com/2/rsvps").log(org.apache.camel.LoggingLevel.INFO, "MeetupElasticSearch.Log", "JSON RSVP ${body}")
但是什么也没有发生,没有消息被消耗。我以前尝试过添加camel计时器,因为我不确定您是否可以在的中直接使用http4组件,但结果是一样的
您能帮助我吗?您不能在from()
指令中使用http4
组件
但是,有几种方法可以调用URL并检索结果:
一种方法是创建一个计时器并从到()
调用http4
组件,如下所示:
from("quartz2://HttpPoll/myTimer?trigger.repeatCount=0")
.to("http4://stream.meetup.com/2/rsvps")
.log("Body is: ${body}")
.to(mockDestination);
另一种方法是使用模式,例如,如果您想将结果聚集到另一个结构中
另外请注意,如果您的URL是动态的,则必须改用to()
更新:
另一种使用来自Internet的流的方法是使用除http4之外的另一个组件:
您可以在from()
指令中声明它:
// Read stream from the given URL... an publish in a queue
from("stream:url?url=http://stream.meetup.com/2/rsvps&scanStream=true&retry=true").
to("seda:processingQueue");
// Read records from the processing queue
// and do something with them.
from("seda:processingQueue").to("log:out")
您可以在中看到更多示例