Reputation: 237
I have created a Route that looks roughly like this:
@Override
public void configure() throws Exception {
from("direct:twitter")
.from("twitter://timeline/user?type=direct&user=" + this.uri)
.choice()
.when(body().isInstanceOf(Status.class))
.process(new MyTwitterProcessor())
.convertBodyTo(MyClass.class)
.to("log:do something")
.endChoice()
.to("log:mi amigo");
}
Calling this route directly from producerTemplate.requestBody("direct:twitter", object), I expected to receive a list of MyClass.class instances. Instead, it is returning the object I sent in the requestBody method call.
Based on log statements "log:do something" I can see that Status objects are being returned- the request and response from twitter are clearly occuring.
I would like to understand why my route configuration is returning the object I send it, rather than the Status object results from twitter. I have written two other routes for Facebook posts and an RSS feed. They follow a similar pattern and return the response objects, rather than the request I sent.
I would also like to know what I can do to change the behavior so that producerTemplate.requestBody(...) returns a list of twitter messages.
Thank you for your time.
Upvotes: 2
Views: 112
Reputation: 7636
Use the pollEnrich component to obtain additional data:
from("direct:twitter")
.pollEnrich("twitter://timeline/user?type=direct&user=" + this.uri)
.choice()
...
Alternatively, you may just use following route that is automatically started:
from("twitter://timeline/user?type=direct&user=" + this.uri)
.choice()
...
Note, that the twitter component creates one route exchange per returned object and not a list.
Upvotes: 1