CXF & Heroku, one more time…


One more Apache CXF and Heroku article to push Web services to the Java PaaS… In some previous articles I explained how to create JAXWS and JAXRS service by cloning/forking/whatever git repositories. This time it is almost the same but I created a maven archetype to generate tons of maven modules quickly and to integrate them in your maven-based projects (OK cloning a repository is faster, it does not download the entire Internet as Maven does…).

Let’s do it with a screen record to check how fast it is. With my poor Internet connection and some typos, I have something running on Heroku in less than 2 min 30…

Here are the commands used in the sample above:

The archetype source code is located at https://github.com/petalslink/petalscloud-maven-archetypes and deployed on OW2 repository. Once the project is generated from the archetype, one can add his own JAXWS-annotated services and associated Spring configuration (src/main/webapp/WEB-INF/beans.xml). Generated project is also available on github at https://github.com/chamerlingdotorg/maven-heroku-jaxws-sample.

Can it really be more easy?

Notify me when someone forks me


All is cool in Github and the API really rocks! I created several tools around it and especially QuickHub, an OS X app to quickly access to your Github space and be notified when something changes.

Last night, I was thinking about creating something which can notify you when someone forks or start watching your repositories even if you are offline. So I had a look to the Repository Hook API and just found that almost all the hooks are targeting push ie you can use tens of connector to be notified on the system of your choice only when a push occurs on your repository. Let’s have a look to the event API but this is not a really good idea, I already use it in QuickHub to notify about activities and it’s just about polling for changes.
So what? Hopefully, there is one alternative: The pubsubhubbub API. According to the GitHub documentation, one can subscribe to any event type using this API. You just have to tell which one on which repository and give it a callback. Giving it a callback is just what we want: Having something which runs online and which can receive events and notify me even if I am offline… Here we go for some Web development with the PlayFramework and Heroku for hosting, here is mygithubnotifier.

mygithubnotifier uses the GitHub Java API from Eclipse. Even if JSON is easy to parse, having it already done is faster. The application retrieves all your personal repositories and provides the user the choice to subscribe/unsubscribe using the pubsubhubbub protocol. This protocol is really simple to use: One endpoint and three parameters are enough. If I want to subscribe to forks on my repository, I just need an authenticated HTTP call like to https://api.github.com/hub with some parameters for defining the topic (repository), the mode (subscribe/unsubscribe), the event type (fork, watch, …) and the callback URL which will be some REST endpoint exposed by the Play application. The application will send an email every time someone forks one of your repository if you subscribed to this event before.

The code is really simple and will not be detailed here. You can get it from GitHub at chamerling/mygithubnotifier. I assume that deploying the Play application to Heroku is as easy as described in their documentation. You just have to configure the application by specifying the right email and GitHub properties as described in the README.md.

Simple HeartBeat Manager with Play


One more time, one more tiny (and maybe useful in some cases…) application with Play!.

WTF, my server is dead again!?

This app is a simple heartbeat manager looking at remote HTTP services and notifying you by email when something becomes unreachable. It uses the background Job feature of the Play framework and just does HTTP GETs on the specified list. That’s all, that’s simple, but that’s can be useful sometimes…

The code is located at https://github.com/chamerling/heartbeat-manager

Pushing your Web services in the Cloud in 5 minutes…


… or less! Heroku is defined as a "Cloud application platform". I just want to redefine it to "Awesome Cloud application Platform". So, this awesome platform provides a way to host and scale your application in the Cloud really easily with 3 or 4 commands…

Since I am currently working on my talk at #OW2Con 2011 (coming later this week) dealing with BPM, Services and the Cloud, I wanted to host some Web services on several places. I never had time to test Heroku but I just took this precious time today. After looking some examples, I created a Maven project template (no I do not have time to create an archetype, maybe there is one somewhere) which uses Jetty and Apache CXF to expose JAXWS annotated classes as Web services. So now, using heroku to freely expose your services is easy as:

  1.  Sign up to heroku
  2. Download the heroku client for your platform
  3. Clone/Fork the repository at https://github.com/chamerling/heroku-cxf-jaxws
  4. Add your own services
  5. Login to heroku ‘heroku auth:login
  6. Create the app on heroku ‘heroku create -s cedar
  7. Push your services to heroku ‘git push heroku master‘. There is a git hook somewhere which just automatically compile and start your application after you pushed it.
  8. Open your CXF services summary page ‘heroku open’
The default application name is some random one, you can rename it by using the ‘heroku rename yournewname‘ but in the current case I had an issue on the generated Web service endpoint name. So I suggest restarting your app after renaming (have a look to the ‘heroku ps‘ command).
That’s all, that’s quick!

Open Source Tweet Wall


I am a big fan of Twitter and last week devoxx live tweet wall (http://wall.devoxx.com/) just made me want to create an open source live tweet wall. So last saturday night, I took some time to code it using the now well known Play! framework, some Web sockets and Twitter4J which supports the Twitter Stream API. This streaming API is really nice and provide a way to be notified almost instantly according to what you decided to listen to. After less than one hour (most of the time was consumed to read to Twitter4J documentation), the result is really fun. In the video below, I configured the wall to catch all the tweets containing ‘Apple’ and ‘Microsoft’ terms (I am not a MS supporter, but OMG, there are lot of tweets about it… probably only jokes and bugs…), and tweets are displayed in live on the wall (no I am not moving anything, the page is populated through a Web socket)

The resulting prototype is quite simple but works, and since I am not a front-end developer at all, it uses Twitter Bootstrap as CSS… The code is available on GitHub at https://github.com/chamerling/play-twall and is not perfect at all but just works: Twitter configuration is available in the Play! application.conf file and the Twitter connection is created in the Bootstrap…

Looks like I should start creation sort of "Coding a nice thing in one hour" collection…