Tuesday, October 30, 2012

Team bootstrap

As some of you may know, recently I changed my employer. I decided to start working for the pretty large american corporation - Pitney Bowes. We specialize in hardware and software solutions for automation and monitoring of postal processes and surroundings (printing, packaging, delivery and so forth).

I'm responsible for setting up and leading engineering team for Java development center emerging here in Poland (Bielsko-Biała). This is the very first Polish team outsourcing the US Pitney Bowes Global Technology Center. This is pretty exciting opportunity as I've been granted much freedom in shaping the form of the team being created here on the Polish site.

As I'd like to summarize my existing team leading experiences and confront them with the best practices of others, I decided to create this blog tag - team bootstrap. I plan to publish here my thoughts on building the efficient Java team with the strong engineering culture.

BTW If you...

  • are available to work in the office in Bielsko-Biała (Poland)
  • know Java
  • would like to work on the challenging messaging-related project
  • would like to work in the team with engineering culture certified by my humble person
...then you should drop me a line :) .

Thursday, October 18, 2012

Getting unchecked result of Future with Guava

If you like Java Executor Framework as much as I do (and hate checked exceptions as much as I do), then you probably start to swear each time you need to handle all these annoying checked exceptions of Future#get.
Future<MyMessage> response =
  camelProducerTemplate.asyncRequestBody(
    "http://veryslow.com/esb/service",
    "request", MyMessage.class);
...
// Do something else waiting for the HTTP response.
...
try {
  handleResponse(response.get());
} catch (InterruptedException e) {
  throw new RuntimeException(e);
} catch (ExecutionException e) {
  throw new RuntimeException(e);
}
Handling checked exceptions of Future is especially annoying, as Executor Framework is widely used when implementing popular Request-Reply pattern in messaging systems.

Fortunately Guava's Futures utility provides glue code for handling Future#get exceptions. This extremely useful method is called getUnchecked.
import static com.google.common.util.concurrent.Futures.getUnchecked;
...
Future<MyMessage> response =
  camelProducerTemplate.asyncRequestBody(
    "http://veryslow.com/esb/service",
    "request", MyMessage.class);
...
// Do something else waiting for the HTTP response.
...
handleResponse(getUnchecked(response));

Thank you Google.

Sunday, October 14, 2012

New JGroups component for Camel is out

Starting from the version 2.10.0 of Camel you can use new JGroups component.

JGroups is a toolkit for reliable multicast communication. The latter communication is usually (but not only) based on the IP multicast. I personally find JGroups-based communication extremely useful for clustering almost anything.

With new Camel component you can broadcast multicast messages to the JGroups cluster. For example when you save message to the persistent store, you may like to notify some other parties that they need to invalide cached data.
from("direct:persistDataEvent").
multicast().parallelProcessing().
  to("sql:insert into MyTable (column1, column2) values (#,#)", 
     "jgroups:MyTableCacheInvalidation");
On the other hand, when you need to listen for the multicast notification, you can use JGroups component on the consumer side of the route. For example to listen for the cache invalidation events you could use the route below.
from("jgroups:MyTableCacheInvalidation").
to("bean:myTableCache?method=invalidate")

Due to the licensing issues (JGroups is licensed under LGPL) this component is developed under the umbrella of the Camel Extra project.

And here are Maven coordinates for new artifact:
<dependency>
  <groupId>org.apache-extra.camel</groupId>
  <artifactId>camel-jgroups</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

Enjoy your ride with new Camel in our herd :) .