What is the best way to create a JMS-like solution on top of Infinispan?
susanin Jun 27, 2011 6:10 AMHi,
I'm new to Infinispan and try to use Infinispan for distributed caching in our Java-based application. In addition to that, I was thinking to build a small messaging queue solution on top of it. My hope is that it would be much more efficient that usage of a standard RMI approach or JMS, as these two add quite some overhead based on our profiling. And we need a very fast (async) communication between our nodes/sub-systems.
The question is: What is the best to implement such a queue in terms of performance (latency, throughput)?
We had a previous solution that used Hazelcast and it was very easy to do such a queue there, because Hazelcast's API supports out-of-the-box distributed queues as well as distributed topics and subscriptions. But Infinispan does not provide any distributed data-structures other than distributed maps. Everything else should be modeled on top of it.
Questions:
1) Are there any plans to add support for any further distributed data-structures, like queues, topics, lists, etc? It would be very valueable for many practical use-cases. And would make Infinispan stronger against competition, e.g. Teracotta or Hazelcast.
2) I tried to implement a queue by means of a distributed map. A producer would add an entry to the distributed cache (eventually with autoexpiration after a certain period of inactivity), and a consumer would be subscribed to the entry modification events. As a result, every time a new item is added to the map, the consumer would be notified and can process it. I use something like this as a configuration:
Configuration c = new Configuration();
c.setCacheMode(Configuration.CacheMode.DIST_ASYNC);
// Do not try to group updates. Publish changes in the cluster as soon as possible
c.setUseLockStriping(false);
c.setUseAsyncMarshalling(true);
c.setUseReplQueue(false);
c.setEvictionStrategy(EvictionStrategy.FIFO);
c.setEvictionWakeUpInterval(5000);
I set these values in the configuration after reading some Infinispan guides and doing some experimentation. Overall, it seems to work. But performance of this implementation is not very good, e.g. compared to Hazelcast topics-based approach. It is about 3-4 times slower for some reason. I guess I'm doing something wrong either in configuration or in the overall implementation of the queuing. I'd be very interested if someone could tell me what's wrong or propose a better way to implement it.
Thanks,
Ivan