Wednesday, May 30, 2012

Let the JBI go

People considering using the ServiceMix (Fuse ESB) sometimes ask me about JBI (Java Business Integration) support in ServiceMix. However in the majority of cases they don't need the JBI. They just read about it on the ServiceMix page or in some old Manning book, so they're asking.

JBI is almost dead. This is as sure as bad lecture is JBI JSR. There will be no JBI 2.0. All new ServiceMix projects I know use pure Camel routing with ActiveMQ instead of the NMR (Normalized Message Router). ServiceMix is not a JBI implementation anymore. Now it is Karaf with bundled Camel, ActiveMQ and CXF support. Of course, you can deploy JBI components on ServiceMix, but only for legacy reasons.

If somebody ask you about JBI, make world a better place and tell - "JBI has gone".

Thursday, May 24, 2012

Aggregating multiple web services behind Camel facade

I've found an interesting problem on Stack Overflow. I've answered the question but want to elaborate it a little bit.

The problem

You got two web services. Service A and Service B. The services are independent from each others. You need to create a REST web service that calls the latter services, aggregates the results and returns them to the client.

Some terminology

What we want to achieve here is an example of simple orchestration i.e. coordination of calling of multiple services on the ESB. Orchestration of the services (not necessarily web ones) has been repeatedly raped by many commercial tools and solutions. One of the most prominent example of orchestration's torturer is BPEL.

When we use ESB as a proxy between services we refer to it as Pure ESB. Pure ESB doesn't contain heavyweight processing logic - it only serves as a mediation router.

ServiceMix and Camel are excellent tools for creating lightweight orchestration based on the pure ESB concept.

Aggregation of two or more services can be referred as Aggregating Service, Facade Service or Proxy Service.


Aggregating web services in Camel

We want to call Service A and Service B in parallel (since they are independent), then aggregate the incoming results into a single answer.

The following Camel route is responsible for collecting results from the sub-services (A and B) and aggregating them into single message.

from("direct:serviceAggregator")
  .multicast(new GroupedExchangeAggregationStrategy()).parallelProcessing()
    .enrich("http://servicea.com").enrich("http://serviceb.com")
  .end();


We use multicast pattern to concurrently call two web services. Then multicast uses message enricher pattern to add data from the external services to the original message. When Camel finally finishes aggregation of the results of A and B services' calls, it attaches the latter results to the original message passed to the direct:serviceFacade endpoint. The messages fetched from the A and B services will be stored as exchange property identified by Exchange.GROUPED_EXCHANGE key.

To expose our facade service F on the ESB we will use Camel's Jetty component.

from("jetty:http://0.0.0.0:8080/myapp/myComplexService").enrich("direct:serviceFacade").setBody(property(Exchange.GROUPED_EXCHANGE));

We use enricher again - this time each message passed to the Jetty HTTP connector will be enriched by our aggregating route (direct:serviceAggregator). In practice that means that all request to the HTTP connector exposed as our service will be injected with two additional messages from A and B services. In this particular example we extract data from the received messages and render them as HTTP response to the client.

Monday, May 21, 2012

I'm Android user from now on

I thought I would soon become the last person on earth using Sony Ericsson K750i. I'm not a kind of a hardware geek, so I replace the mobile phone when the old one is unusable. However the problem with my old Sony Ericsson is that it is almost indestructible (it even survived all my crashes during the downhill riding). Fortunately I calculated that using mobile phone as HSDPA modem is cheaper than paying for pre-paids for both mobile Internet and mobile phone.

Since I perceive Apple products as a bit too... pink? ..., I decided to buy an Android device. The cheapest one for the sensible monthly fee.

That's how a become an owner of the Samsung Galaxy Ace.

My general impression is as follows - I'm amazed how useful it is to own a smartphone. :) I would like to stress it once again - I'm not a kind of hardware of gadgets geek. I'm usually not getting easily excited by these kind of things. But this time I must admit - I'm pretty excited by the possibilities offered even by the cheap Android device like the one I own.

Saturday, May 19, 2012

How to host your own instance of Cloud Foundry

There are companies out there making the business based on the Cloud Foundry instances hosted on their own infrastructure (instead of the VMware's one). Cloud Foundry platform is released as Open Source project. So theoretically I also could build my own instance of Cloud Foundry and start hosting services.

So what steps I need to perform in order to start my brand new Cloud Foundry instance?

  • install VMware's VM image of Ubuntu 10.04.02 .
  • download and execute VCAP (VMware Cloud Application Platform) installer:
  • $ sudo apt-get install curl
    $ bash < <(curl -s -k -B https://raw.github.com/cloudfoundry/vcap/master/dev_setup/bin/vcap_dev_setup)
  • make yourself a cup of coffee and wait until the installation process completes.
  • restart Ubuntu VM.
  • start VCAP service (~/cloudfoundry/vcap/dev_setup/bin/vcap_dev start).
  • validate your installation:
  • $ vmc target api.vcap.me
    $ vmc info

If you see something similar to...

VMware's Cloud Application Platform
For support visit support@cloudfoundry.com

Target:   http://api.vcap.me (v0.999)
Client:   v0.3.10M
... it means that you've just successfully started your own Cloud Foundry instance.

Wednesday, May 16, 2012

Custom domain for application deployed on Cloud Foundry (or any other cloud provider)

The problem

The problem with an amazing Cloud Foundry, is that due to the limitations of beta version, it doesn't support mapping of custom (aka external) domains to the applications. It's a pity since free Cloud Foundry account has some impressive quota and could be used for initial production deployment of many web applications.

Are we then doomed to the http://applicationWithUglyUrl.cloudfoundry.com kind of URLs when deploying to the Cloud Foundry?


Reverse proxy to the rescue

The trick to deal the with ugly domain names is to use reverse proxy to forward requests from our custom domain to the Cloud Foundry application.

Reverse proxy allows to transparently forward HTTP requests from one server to another. The interesting side effect of the usage of reverse proxy is that you can hide your destination server behind the domain name mapped to that proxy.


Probably the most popular reverse HTTP proxy implementation is Apache HTTP server with enabled mod_proxy module.


Reverse proxy and the Cloud Foundry

In the case of Cloud Foundry you need to configure your custom domain (for example myapplication.com) to point to some reverse proxy.  Then configure the reverse proxy to forward the requests matching your custom domain (http://myapplication.com) to the Cloud Foundry instance (for example http://myapplication.cloudfoundry.com).


What if I don't have Apache HTTP instance?

You don't have your personal Apache HTTP to host reverse proxy? No problem. As I read at this brilliant blog you can use bs2grproxy reverse proxy application hosted on free Google App Engine Account. Here's what exactly you need to do:
  • download Python Google App Engine SDK and unzip it.
  • create application for proxy on Google App Engine (give it a nice name, like myapplication-proxy).
  • download bs2grproxy application template and unzip it.
  • open file bs2grpconfig.py in text editor and change value of TARGET_HOST property to the address of your Cloud Foundry application (for example to the http://myapplication.cloudfoundry.com).
  • open file app.yaml in text editor and set the proper id and version of your Google App Engine proxy application (for example application: myapplication-proxy and version: 1).
  • install Python (sudo apt-get install python under Ubuntu) since bs2grproxy is written in it.
  • from Python GAE SDK directory execute the following command - ./appcfg.py update /home/user/projects/myapplication-proxy . The latter command will deploy your proxy application to the Google App Engine infrastructure.
  • since Google App Engine allows you to configure custom external domains even for free accounts, set your custom domain (myapplication.com in our example) to point to the proxy deployed on the Google App Engine (for example to myapplication-proxy.appspot.com).
Congratulations. From now on all requests to the http://myapplication.com will be transparently forwarded by reverse proxy to the http://myapplication.cloudfoundry.com.


What about the other hosting providers?

Remember that you can use reverse HTTP proxy to mirror any domain. So you can use it to deal with all kinds of ugly URL mappings.

Saturday, May 12, 2012

Praise for the Cloud Foundry

I'm pretty excited about beta version of VMware's Cloud Foundry. Probably as excited as disappointed by Google App Engine.

GAE is a vendor-lock-in PAAS providing services with little business value for the majority of the projects I've been involved into. On the other hand Cloud Foundry is a PAAS providing amazingly simple hosting services. The services that just works. For example:


If you're looking for the good place to deploy your WAR and make use of the following types of resources...
  • file system (sic!)
  • MySQL
  • PostgreSQL
  • Redis
  • MongoDB
...you will be at home using Cloud Foundry.

I cannot overemphasize the fact that pretty decent Cloud Foundry account is available for free. By saying "pretty decent" I mean  2 GB of memory (sic!), 2 GB of disc space and 4 core CPU. Such free account really encourage to play with the Cloud Foundry.

At this moment VMware doesn't tell how much will it charge for Cloud Foundry after closing the beta phase. However practically no vendor-lock-in makes CF a perfect choice for the initial deployment of many web applications. With no vendor burden you can just switch to another provider without any special effort.

VMware, kudos for you :) .

Tuesday, May 8, 2012

Ubuntu 12.04 - first impression

I've installed Ubuntu 12.04 just before the long weekend. Here are my two cents regarding this release of the favorite Linux distribution of the many.

Some cool things I've noticed

  • Compiz animations are more fluent and nicer for the eyes in general.
  • system seems to work more stable than 11.10.
  • system seems to have less bugs too.
  • you can choose the size of the laucher icons on the applications bar (check out my new cool tiny icons below).




Some not cool things I've noticed

  • Huawei E220 HDSPA modem support is still broken.
  • package manager laucher icon sometimes gets unresponsive (old bug from Ubuntu 11.10) .
  • Windows Overview feature in Compiz (Win+W) sometimes doesn't display some opened applications.
  • Show Desktop feature in Compiz (Ctrl+Win+D) sometimes doesn't respond.
  • it is hard to create custom lauchers in Unity (bug existing since Ubuntu 11.10).
  • system sometimes hangs after wake up from hibernate state (guess what? It's bug from Ubuntu 11.10).

My general impression about Ubuntu 12.04 is on plus so far. It seems that Canonical guys learned their lesson from 11.10 bugs (at least from some of them).

Sunday, May 6, 2012

Huawei E220 HDSPA modem under Ubuntu 11.10 and 12.04

Support for 11.10 Huawei E220 HDSPA modem is broken since Ubuntu 11.10. Unfortunately version 12.04 of my favorite Linux distribution doesn't fix the issue.

The problem with the modem manifests itself by refusing to establish the network connection.

I use mobile Internet from Play Mobile with Huawei E220 USB modem delivered by the service provider. In order to establish connection with The Internet, I need to perform some mambo-jumbo hacking.

First I try to connect to the network with modem. It fails of course. Then I execute the following shell command:

$ sudo usb_modeswitch -v 0x12d1 -p 1003 -V 0x12d1 -P 1003 -R


The trick is to reset (-R) the USB modem firmware with the usb_modeswitch command. Note that both vendor and product do not change in the command - I just reset the device.

After I execute the magic fix-huawei command I plug and unplug the modem. Then I try to connect to the network again - this time connection is established successfully.