I would like to build an Integration Flow on HCI that queries a timeline of a Twitter Handle. I want to make sure Tweets that have been read are not read again. Well this should be easy I thought. There was already a blog series on SCN describing how to set up the Twitter adapter to post a tweet and a direct message Integrating HCI with Twitter - Part 1 and Integrating HCI with Twitter - Part 2
So, I went about building my Integration Flow as below,
Integration Flow
Twitter Adapter
I was skeptical because this configuration did not make sense for multiple reasons,
I had nothing to loose and hence triggered my Integration Flow. As expected I did get a error and the error was as below stating: "No type convertor available to convert from type: java.util.ArrayList to the required type java.io.InputStream".
So, twitter did respond back to me but it sent back a Java Array List which meant I had to understand this a little more and then convert this Array List to a XML String. I looked up the documentation from SAP on this but unfortunately there wasn't much to go on here. So, how do we proceed from here? What could be the content of this ArrayList I wondered.
HCI uses the Apache Camel framework is something that all of us are aware of. When trying to figure out the answer to this question on Twitter adapter I decided to check Apache Camel on this and see if there was a means to reverse engineer the workings of the HCI twitter adapter
Apache Camel: Examples provides with a comprehensive list of examples that can be used to trigger an Apache Camel flow and understand its underlying components. One of the examples in this page listed was the Twitter Websocket Example.
The example is demonstrating how to poll a constant feed of twitter searches and publish results in real time using web socket to a web page
Exactly what I want was my first reaction. So how do I run this example locally? How do i test and play around with this example to understand the the HCI twitter adapter.
In part 1 of this blog series, we will set up this example locally and test the same.
In part 2, we will extend the learning from this standalone run to HCI and use the same in HCI Twitter Adapter.
Step | Details |
---|---|
| |
|
Step | Details |
---|---|
| |
|
Step | Details |
---|---|
| |
| |
| |
|
Step | Details |
---|---|
| |
| |
| |
| |
|
Step | Details |
---|---|
| |
| |
|
Step | Details |
---|---|
| |
| |
| |
|
So far so good, I thought! From the looks of it, it was clear that HCI was using the Twitter Component of Apache Camel as its underlying framework for the Twitter adapter. But, I still didn't have an answer as to how to restrict the twitter feed to only new tweets. I still do not understand what the Java Array List is all about.
I went about then digging on Apache Camel Twitter component documentation - Apache Camel: Twitter. Couple things were of interest here,
Apache Camel Documentation Excerpt | Inference |
---|---|
The Twitter component enables the most useful features of the Twitter API by encapsulating Twitter4J. |
|
sinceId - Camel 2.11.0: The last tweet id which will be used for pulling the tweets. It is useful when the camel route is restarted after a long running. |
|
|
So,in summary, it was clear to me now that I had to use a combination of Twitter4j.status and sinceID to build what was needed to meet my requirement.
I had been able to reach this point by running a built in apache camel twitter example and understanding the underlying working of HCI's twitter adapter. In the next part of this blog, we will look at how the info deciphered above is used in our Integration Flow.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |