woensdag 21 maart 2012

Analyzing twitter using JBossESB

Most ESB example start from some HelloWorld use case, where you have to send a message to the ESB and it will print it to the console. In this post I would like to show that you can do a lot more with an ESB, for example reading and analyzing data from social media like twitter.

The example below will demonstrate how you can use JBossESB to retweet every message containing a certain hashtag. If you want you can extend the example an store all the message to database, or keep track of those users who have posted the most amount of messages with a certain content.


Step 1) Create a scheduler using JBossESB
When you want to retweet all messages containing a certain hasshtag, you need some kind of scheduler that is fired every second, minute or hour. In the jboss-esb.xml file you can do this by using a 'schedule-provider'.
This cron-trigger can be used in a schedule-listener to invoke a certain action or chain of actions which is explained in the next step. The cron-expression above will be fired every hour.

Step 2) Create a listener that creates an ESB aware message
Each time the above trigger is fired, a listener should be triggered that can catch the event and process it. In this example the event processor will create a new ESB aware message and put the hashtag in it to look for.


In this case we put "Xebia" as the hashtag to look for. If you want you can configure some property file for example that contain all the hashtags to look for.

Step 3) Create an action that searches for the tweets and reposts them if needed
Next step is to create a service that contains an action that will search for all tweets containing the String that was put in the message body in step 2 and retweets those messages if they are new.


For the configurationBuilder you will have to create the OAuth Access token yourself, by registering your application on the twitter website. 
First we query for the last tweeted message by the current user. The id of that tweet will be used in the next query to fetch only those tweets with a higher id.
For each tweet found, we retweet that by passing the original id. Notice that we only send the id, and not the whole message.

Step 4) Deploy and have fun
You can use maven to create a jar file out of it and deploy this to the JBoss AS. Once deployed this application will start retweeting all tweets containing #Xebia to your own twitter account.

Possible extensions: Of course you can add additional actions that analyze the contents of the messages.
  • Only tweeting positive messages
  • Change messages before retweeting. Example, always add #like
  • Forward tweets to other social media
  • Organize a game where you keep track of who has send the most tweets
  • Convert all tweets to email
  • Anything else you would like to do...
All code snippets can be found in this zip file

Joris De Winne recently moved from Belgium to the Netherlands, and is now working for Xebia as an IT architect, with a lot of experience in open source and Agile/Scrum consultancy.

dinsdag 20 maart 2012

Questions to ask when looking for a new job?

When you’re looking for a new job, you typically have to go through several interviews. In most cases at the end of each interview, you get the opportunity to ask some questions. Most people ask typical questions like “What are the extra benefits?”, “What will I do when I’m on a project?”, …

Below you can find some non typical questions you can ask when having an interview.
1) Can I decide myself what laptop I’ll be working on? Or will I receive the same laptop everyone is getting?
This will give you an idea, if you can work on your favorite OS and/or laptop. Whether it is Apple, Linux or Windows, the fact that you can choose makes it more fun. Remember that as IT consultant you will be working on that system on a daily basis. You have to like it, and each person tend to like different things to work on and work with.

2) Is the company using VPN to allow employees to work @ home?
With this question, you touch directly two different topics. If a company doesn’t allow working at home, you might think they don’t trust you. And isn’t working for a company all about trust? Having the freedom to work where you want and where you’re the most productive is definitely an extra value.
Having a VPN (Virtual Private Network), causes in many cases a lot of headaches for the employees. You have to make an additional login or use some kind of token device. And sometimes the usage of VPN is blocked when you’re working outside the office, for example from a hotel room.

3) How will I get to the office on day 1?
Most consultants in IT these days are using a company car. So you typically receive your company car the first day when you start working. Now the question is if the company will deliver the car to your home, or you have to use public transport, taxi, … and loose a lot of time on your first working day. The first day you’re in most cases already having a lot of stress, so having a company car being delivered at your home is just nice.

4) What are the working hours?
These days, flexibility is being asked from each employee and/or consultant. This also means that the company you work for should offer this kind of flexibility. Part of that will be having no working hours. In that way you can start when you want in the morning, and for example bringing the children first to school.

5) Are lunches provided by the employee?
Wouldn’t it just be nice to have free lunches when you’re at the office. And of course also free drinks, candy, cookies, …. It just makes it more nice to go to the office and make you feel at home, also when you’re at the office. And for the coffee lovers, just ask for coffee during the first interview. If it is good coffee, it means they deliver quality stuff ;-)

6) Is facebook, skype, hotmail, gmail, … blocked?
Maybe you can consider this as a very strange questions, because you will be working for the company, and not browsing on facebook, etc. So why is this so important? In the past employees had to use the office phone to make a private call. Now everything is being done through email, facebook, … So why should a company block these applications? They shouldn’t! Let the employees be free on also doing private stuff during the working day. This is some kind of flexibility the employer should give to the employees.

7) Is there a dress code within the company?
In the 20th century employees working at IBM had to wear some kind of uniform when going to work. In the 90ties this has changed, into some more business casual dress code. Some companies did go even further than that and gave their employees full freedom. So if you want to go to work in swimming pants, that is your choice and allowed. Maybe you should think of how you would like to go to work everyday and check if that corresponds with the typical dress code at the company you want to work for.

The questions above will give you an idea how the company works and if it will be really fun working for them. Of course you can and should ask also other typical questions. When looking for a new job opportunity, don’t let the company choose you, but you should choose the company!
Joris De Winne recently moved from Belgium to the Netherlands, and is now working for Xebia as an IT architect, with a lot of experience in open source and Agile/Scrum consultancy.