// Start HornetQ server
HornetQBootstrapServer.main(new String[]{"hornetq-beans.xml"});
// Start Infinispan remote data grid, listening on localhost:11222
HotRodServerConfigurationBuilder builder = new HotRodServerConfigurationBuilder();
HotRodServer server = new HotRodServer();
EmbeddedCacheManager cm = new DefaultCacheManager();
server.start(builder.build(), cm);
Context ctx = new InitialContext();
Connection con = null;
try {
con = ((ConnectionFactory) ctx.lookup("/ConnectionFactory"))
.createConnection();
con.start(); // Start delivery
// Add a message producer to send invalidation messages to near cache clients
Session s = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Set up the datagrid topic (TODO: Selective key/cache topics)
Topic topic = (Topic) ctx.lookup("/topic/datagrid");
// Add invalidation listener for default cache
cm.getCache().addListener(new InvalidationProducer(s, topic));
} finally {
while (in.read() != -1) {}
ctx.close();
if (con != null) con.close();
server.stop();
cm.stop();
System.exit(0);
}
}