Thursday, 31 May 2012

Infinispan 5.1.5 goes FINAL!

Infinispan 'Brahma' 5.1.5.FINAL has now been released fixing a whole bunch of issues around cache store preloading of distributed caches, Memcached server, tree module and Hot Rod client performance. We've also updated several libraries such as Netty (to 3.4.6) and JGroups (to 3.0.10).

Full details of what has been fixed can be found here, and if you have feedback, please visit our forums. Finally, as always, you can download the release from here.


Tuesday, 29 May 2012

Distributed execution framework enhancements

The initial release of the distributed execution included in Infinispan 5.0 was meant to be more of an experiment -- a testing ground -- rather than an industrial solution for distributed execution. We provided a simple interface similar to a familiar ExecutorService API and adapted it for execution on the Infinispan cluster. To our own surprise, use of the distributed execution framework took off and people started using it even in production environments. After the initial release users enthusiastically provided feedback and asked for enhancements. Some of these minor enhancements were integrated in subsequent Infinispan 5.1 and 5.2 releases. However, major improvements were put aside on a shelf, until now! The time is ripe to respond to these major enhancements so they can be ready for the Infinispan 6.0 release time. We have started a dedicated design page for distributed executor enhancements where you can provide your input and influence the design of the next iteration of the Infinispan distributed execution framework. Looking forward to more of your feedback!

Friday, 25 May 2012

On datagrid performance @ Berlinbuzzwords

I will be talking about datagrid performance and capacity planning and Radargun at this year's edition of Berlin Buzzwords, 4-5 June (I'll let you guess the location). My very first time at this conference but the amount of positive feedback I received about it was huge, so really looking forward to it!


Thursday, 24 May 2012

How to configure Infinispan with transactions, backed by relational DB on JBoss AS 7 vs. Tomcat 7

Migrating projects from one container to another is often problematic. Not as much with Infinispan. This article is about configuring Infinispan, using Transaction Manager for demarcating transaction boundaries, while keeping the data both in a memory and relational database - stored via JDBC cache store. I'll demonstrate all the features on code snippets. 

A complete application is located at and is called carmart-tx-jdbc. It's a web application based on JSF 2, Seam 3 and Infinispan 5.1.4.FINAL, is fully working, tested with JBoss  Application Server 7.1.1.Final and Tomcat 7.0.27. There  is one prerequisite, though. It needs an installed and working MySQL database in your system. The database name should be carmartdb, accessible by a user with carmart/carmart username/password.

First, look at what we need to configure for JBoss Application Server 7. 

Configuring transactions and JDBC cache store on JBoss AS 7

Infinispan will be configured via new fluent API using builders, hence the call to  .build() method at the end. We need to configure aspects related to  transactions and cache loaders. The configuration API for cache loaders  is likely going to be changed in not-so-far future. It should be fluent  and more intuitive, generally easier to use than current one. 

I purposely do not show XML configuration. Configuration examples can be found at In order to configure transactions and cache loaders, look for tags called  <transaction> and <loaders> and modify that sample file according to below configuration. Tag names and attribute names are very similar for both XML and Java configuration. If that is not enough, there is always a schema in Infinispan distribution.

The configuration of Infinispan is as follows: 

Lines marked with red are different in other containers/configurations, as you'll see in a minute. The code above implies that we need to specify proper TransactionManagerLookup implementation which is, in this case, GenericTransactionManagerLookup. We  also need to say: "Hey, I wanna use ManagedConnectionFactory as a connectionFactoryClass". OK, here we go. I should, as well, explain how to configure a datasource properly, right? In JBoss AS 7, this is configured as a subsystem in $JBOSS_HOME/standalone/configuration/standalone.xml:

The usage of transactions is very simple as we can obtain a transaction object by injection.


Quite easy, isn't it ...if you know how to do it. The only problem is that it does not work (at least not completely) :-) If you deploy the app, you find out that when storing a key-value pair in  the cache, an exception is thrown. This exception indicates that the operation with DB (and JDBC cache store) failed. The exception says:

A complete stack trace looks similar to
There's still an open issue in JIRA (ISPN-604) and it is being worked on. 

Configuring transactions and JDBC cache store on JBoss AS 7 - c3p0

But how do we cope with this inconvenience for now... By not using a managed datasource but rather a third party library called c3p0 (JDBC3  Connection and Statement Pooling, more information at Infinispan allows you to use this library for connecting to the database. If you really want to use it, you need to choose a different connectionFactoryClass which is, in this case, PooledConnectionFactory.

Infinispan configuration looks like this:

Transactions are accessible in the same way as in the previous use case. Now let's look at configuration for Tomcat servlet container. 

Configuring transactions and JDBC cache store on Tomcat 7

Tomcat does not have any Transaction Manager in it so we have to bundle one with the application. For the purpose of this exercise, we choose JBoss Transactions ( See dependencies at the end.

Cache manager and cache configuration is in this form:

For Tomcat, we need to specify a different transactionManagerLookup implementation and datasourceJndiLocation. Tomcat simply places objects  under a bit different JNDI locations. The datasource is defined in context.xml file which has to be on classpath. This file might look like this:

How do we get the transaction manager in the application then? Lets obtain  it directly from a cache. 

Infinispan knows how to find the manager and we need to know how to obtain it from Infinispan.

Sources: The transaction manager provides standard methods for transactions, such as begin(), commit() and rollback(). 

Now is the time for dependencies

So...which dependencies do we always need when using Infinispan with JDBC cache stores and transactions? These are infinspan-core, infinispan-cachestore-jdbc and javax.transaction.jta. The scope for jta dependency, as defined in Maven, is different for JBossAS and Tomcat.

Common dependencies for JBossAS and Tomcat

Of course, our application needs a few more dependencies but these are not directly related to Infinispan. Let's ignore them in this article. JBoss AS 7 provides managed datasource that is accessible from Infinispan. The only specific dependency (related to transactions or Infinispan) is JTA.

Dependencies specific to JBossAS - using managed Datasource (managed by the server)

Dependencies specific to JBossAS - using c3p0

Yes, you need to bundle also MySQL connector. On the other hand, for Tomcat use case and JBossAS with managed datasource, this jar file needs do be deployed to the server separately. For Tomcat, do this simply by copying the jar file to $TOMCAT_HOME/lib.  For JBoss AS 7, copy the jar file into $JBOSS_HOME/standalone/deployments.

Dependencies specific to Tomcat - using JBoss Transactions

That's it. I hope you've found this article helpful. Any feedback is welcome, especially the positive one :-) If you find any problem with the  application, feel free to comment here or participate in Infinispan forums (


Tuesday, 15 May 2012

One more micro release, Infinispan 5.1.5.CR1 out now!

Infinispan 5.1.5.CR1 has just been released with a handful of crucial issues that we considered required another community release. If you're a tree module user in JBoss AS7, or a an elastic Hot Rod server user,  or use XA datasources with Infinispan JDBC cache store, you should definitely upgrade to this version!

Infinispan 5.1 'Brahma' is a key component for a lot of projects both within and outside the boundaries of Red Hat, and this is reflected in all the micro releases we've done for 'Brahma' as Infinispan consumers near their final releases. From here I'd like to personally thank all the people behind these projects who have been crucial to the development of Infinispan. Expect a 5.1.5.FINAL in the next days which should wrap up the 'Brahma' release lifecycle barring a show-stopper! :)

As always, full details of what has been fixed can be found here, and if you have feedback, please visit our forums. Finally, as always, you can download the release from here.


Friday, 11 May 2012

Infinispan @ MOW 2012

A couple of weeks back I was speaking about Infinispan and Radargun at MOW 2012. Although this conference was originally focused on Oracle products, for a over a year now, Miracle have been expanding into other territories, such as Microsoft and Java middleware. However, there's still some work to be done in this area in order to make this a must-go conference for Java developers. Max Andersen and Thomas Heute were presenting as well on topics such as: Ceylon, JBoss AS7 and OpenShift.

If you want to find out more about Infinispan, don't miss Mircea Markus at Berlin Buzzwords 2012, at the beginning of June.