26 março 2009

Leverage EIP with Apache Camel and Twitter

I had no clue Enterprise Integration Patterns could actually work together with Twitter, for a business need. The thing is that, everybody is looking for ways to integrate everything within everything. And that's what this article tries to explain.

The idea to integrate Apache Camel and Twitter came when a customer was looking for a way to advertise on Twitter into different accounts, each one for different segments as no one actually wants to follow 100+ departments in the same account. That said, the enterprise will have 100+ Twitter accounts and its customers will now be able to follow only the departments they actually want to.

To create a lot of different accounts, there's nothing we could do about it. But to tweet a lot, well, that was piece of cake. Now, the advertisement system can be easily integrated with Web Services, file upload, Web requests, etc. A server that can tweet for different enterprises, sending messages in any format, to advertise.

Another interesting thing to do is to follow customers from these enterprises. If they put on their accounts their Twitter screen names, we can easily follow them and massively process everything they are talking about. Then see what's going on about new tendencies, products and services.

Apache Camel is a great EIP framework that can be embedded into different applications, from Web to Desktop. Twitter4J is a great API developed by Yusuke Yamamoto. With these two libraries all I mentioned previously can be easily achieved.

To give an idea, here is an example:


public class TwitterRoute extends RouteBuilder {
public void configure() throws Exception {
// Message Channel - polling ads from files
from("file:ads-inbox")
// MessageTranslator
.transform(body().convertToString())
// Tweet it!
.to("twitter:tweetit?user=cameltweet&pass=***");

// get all friends timeline from user 'brunoborges' and wire tap them
from("twitter:tweets?user=cameltweet&pass=***&type=FRIENDS&follow=brunoborges")
.transform(body().convertToString())
.to("bean:wiretap");
}
}


On my next post I've put more details about the architecture involving Camel and Twitter.

** UPDTE 03/30/09 **
If you are interested in this component and architecture, please read the Part 2.

See ya!

Nenhum comentário:

Contato

Email:bruno.borges(at)gmail.com

LinkedIn: www.linkedin.com/in/brunocborges
Twitter: www.twitter.com/brunoborges
Comprei e Não Vou
Rio de Janeiro, RJ Brasil
Oracle
São Paulo, SP Brasil