use of facebook4j.ResponseList in project camel by apache.
the class FacebookComponentPageIdProducerTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() {
from("timer:period=20000").setHeader("CamelFacebook.reading.limit", constant("10")).process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
if (lastTimestamp > 0) {
exchange.getIn().setHeader("CamelFacebook.reading.since", lastTimestamp);
}
}
}).to("facebook://getPosts?" + getOauthParams() + "&userId=" + APACHE_FOUNDATION_PAGE_ID + "&reading.limit=5").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
ResponseList<Post> body = (ResponseList<Post>) exchange.getIn().getBody();
log.info("Number of posts received: {}", body.size());
for (Post post : body) {
log.debug(post.toString());
}
if (!body.isEmpty()) {
lastTimestamp = body.get(0).getUpdatedTime().getTime();
}
}
}).to("mock:page");
}
};
}
Aggregations