07 abril 2009

Apache CouchDB on Fedora 10 64bit



CouchDB - Relax


I've been trying to install Apache CouchDB on my Fedora 10 and came to a few issues regardling libraries and other requirements to build it. If you are interested on CouchDB and/or how to install it on a Fedora system, this post might be useful for you.

The README file of Apache CouchDB doesn't list the equivalent packages for Fedora, so I had to dig a lot to finally get it right. First thing is to install all of these packages:
  • js-devel
  • libcurl-devel
  • libcurl
  • erlang
  • erlang-esdl-devel
  • erlang-pgsql-devel
  • compat-erlang
  • libicu
  • libicu-devel
  • libmozjs-dev
  • make
  • gcc
  • automake
  • gcc-c++
  • kernel-headers
  • glibc-devel
Then download Apache CouchDB, extract the file, and type:
[~/apache-couchdb-0.9.0]$ ./configure --with-erlang=/usr/lib64/erlang/usr/include/
The parameter above is needed because the script cannot find on Fedora, where the headers of Erlang are located. After this step, you should be ready to compile with make, and then install it as root with make install. But if you are NOT like me that likes to do things really fast - compile, install, run - you can create an RPM package. For this, you have to install rpmdevtools too. Follow this guide of How to create an RPM package.

Done. You can now type:
$ sudo couchdb
Open your web browser and point it to this URL: http://127.0.0.1:5984/.

Now relax and have fun!

06 abril 2009

Leverage EIP with Apache Camel and Twitter: Part 3


Alright, so I've just submitted a JIRA issue to the Apache Camel project, donating the source code of this component. Anybody interested just follow this link and download the component itself or wait to see if they commit it into the SCM.

The component can publish, like I've showed you on my last post, and also consume some user's twitter page / the friend's timeline of someone or the public timeline. It's really cool.

If you wanna try it by yourself, just download the attachment, set up the maven project as a module of Apache Camel (yes, you will have to download the whole Apache Camel sourcecode tree) and then build it. Or... edit the pom.xml to fix some parent references. I hope you know something about Apache Maven too.

On my next post, I promise to show you how to use it and all the possible parameters. Or take a look at the source code and play with it.

Have fun. :-)

30 março 2009

Leverage EIP with Apache Camel and Twitter: Part 2

On my first post I introduced you about a problem a customer brought to me to solve. And I thought using Apache Camel to advertise on Twitter could actually fit into his business needs (and mine as well). The first thing I had to think about was on how to receive ads from different customers in different formats. This way I could let them continue to use any format they are already using to publish ads online.


Fig 1. receiving advertisements

To receive messages in different formats is easy. Just open endpoints where they can connect to and publish their files/messages/whatever. Camel comes with a lot of different components to implement these “incoming” endpoints. I had to put some Pipes and Filters before the Message Normalizer to load data into Message Exchange headers, and to drop invalid messages.

After a valid message arrives into CamelContext, they need to be normalized to a common format. Using the pattern Message Normalizer (a Content-based routing connected to different message translators), I convert all messages into TweetAd Java objects. This class looks like this:
public class TweetAd {
private TwitterAccount account;
private String advertisement;
// getters and setters
}

To translate messages, I did something like this kind of route:
    from("file:ads-inbox")
.to("bean:loadTwitterAccountHeaders")
.to("bean:transformIntoTweetAd")
.to("direct:tweets");

Cool, now I have a normalized Twitter Advertise a. What's next? Just forward it to a Message Endpoint that publishes TweetAd objects.

I didn't want my Twitter Publisher to require all incoming messages to be a TweetAd object type. So I've coded it in a way that could also publish whatever String context that message could supply. If the Message Exchange's body wasn't a TweetAd, with a valid TwitterAccount object associated to it, this endpoint would require username and password.
This is how my route looks like after having a valid TweetAd object:
    from("direct:tweets").to("twitter:publisher");

And I could have routes like this, for non-TweetAd objects:
    from("bean:amazonAWSAds")
.transform(body().convertToString())
.to("twitter:amazon?user=amazon&pass=nozama");

Done. Now I can publish ads coming from different customers, in different formats, to different Twitter accounts massively. Problem 1 solved. On my next post I will show you the code of Twitter Publisher.

See ya!

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!

20 março 2009

Era digital: tweets, blogs e a evolução humana

Séculos atrás, ou talvez nem tanto assim, eram poucas as pessoas com quem podíamos nos comunicar. Hoje qualquer humano na Terra, conectado à Rede, pode saber quem você é, o que você faz, quem você conhece, o que você pensa, o que você ouve, onde você já foi ou ainda onde você está neste exato momento. Nos tempos atuais, também é possivel saber o que você anda comprando na Internet, quais seus interesses, seu perfil econômico-social e suas tendências.

Tudo isso é possível porque em algum momento, você permitiu. É irônico ver pessoas reclamarem de serviços que permitem isso ou aquilo. O que estes sociofóbicos não percebem é que nós, seres humanos, queremos ser públicos, ser vistos, ser notados por outros seres humanos. Nós optamos em deixar privacidade de lado.

É sensato dizer que a tempos atrás, pouco sabíamos das pessoas residentes de alguns bairros distantes do nosso. Ou mesmo de apenas 3 ou 4 quadras ao final da rua. Hoje, sabemos mais de um estrangeiro residente em Veneza, do que talvez um primo que ainda não possui Internet em casa.

Com a possibilidade de tornar a nossa vida pública, também vem a possibilidade de deixar que todos nos vejam pisando na bola, fazendo alguma besteira ou simplesmente, pagando o maior mico. E eu estou falando de atos leves; imagine outros pesados. Sim, aquele comentário que você fez no blog da sua amante, quando nem imaginava que a sua esposa assinava o RSS dela. :-)

"Vivemos a era da exposição e do compartilhamento. Público e privado começam a se confundir. A ideia de privacidade vai mudar ou desaparecer.” (Revista Época - 13/03/09)
Antes de realizarmos qualquer atitude hoje em dia, pensamos se não há alguém com um celular filmando a cena, ou se o que postaremos em um site poderá ser visto por alguém que não deveria. A Maldição dos Scraps no Orkut é um exemplo típico de "medo" que temos, por ter feito algo errado na vida real. Ter ficado com aquela garota na balada, ela te achar no Orkut e mandar um recado inocente, sem perceber que o seu estado civil é casado, é um de muitos casos onde nossas atitudes na vida real, podem ser facilmente divulgadas na vida virtual.

Entre querer ser público, e querer ter medo de um flagra, a maioria de nós prefere a primeira opção. É do ímpeto humano não querer admitir medo, e convenhamos, todos nós gostamos de um carinho no nosso ego. Nada melhor do que saber que existem outros por ae interessados em nossas vidas.

A evolução humana pode estar diretamente relacionada com a era digital. Fidelidade, companheirismo, honestidade, voluntarialismo, amizade, sinceridade, são adjetivos que queremos colher. Se nos abdicarmos da privacidade nos ajudar indiretamente a sermos pessoas melhores, então estamos diante talvez do ponto mais acelerado da evolução humana na história.

Aos que optam por tornarem suas vidas públicas, o medo de "vacilar" se transforma em coragem de fazer o que é certo, e consequentemente, evoluir. Blogs que expressam idéias, tweets que expressam sentimentos, álbuns de fotos que mostram o passado, redes de relacionamento que definem nosso gênero cultural. Estes fatores da nova era digital, e tantos outros serviços que servem para tornar público o que antes queríamos que ninguém soubesse, acabam de se tornar em os catalizadores da evolução humana.

Eu quero evoluir, e você?
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