17 junho 2009

Vendo Sofá e Estante

Esse negócio chamado Internet é ótimo pra vender coisas. Eu mesmo, coloquei à venda meu sofá e minha estante. Se alguém estiver interessado, por favor me procura!

Segue fotos:

Moveis para Vender

15 junho 2009

Curso de Wicket

Uma das coisas boas da comunidade Java é a vontade que muitas pessoas tem em contribuir com a própria comunidade. O Cristiano Kliemann, um dos membros da Wicket-pt_BR mostrou isso ao disponibilizar o material do Curso de Wicket que ele ministrou há algum tempo atrás.

Tenho certeza que este material será de grande valia para muita gente.

Valeu Cristiano!

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!
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