Look at chapter 6.3 of the JGroups manual at http://www.jgroups.org/javagroupsnew/docs/manual/html/user-advanced.html#d0e2318.
You'll need to create 2 MuxChannels, 1 per service that wants to share the channel. Also, there are unit tests in the JGroups src distro that show you how to use the Multiplexer, or take a look at ChannelMultiplexer.java for a demo.
You could also look into the JBoss source code (JBoss 5, CVS head): ClusterPartition.java:
protected void createService()
log.debug("Creating Multiplexer Channel for partition " + getPartitionName() +
" using stack " + getMultiplexerStack());
channel = (JChannel) getMultiplexer().createMultiplexerChannel(getMultiplexerStack(), getPartitionName());
if(use_debugger && debugger == null)
channel.setOpt(Channel.AUTO_RECONNECT, new Boolean(true));
channel.setOpt(Channel.AUTO_GETSTATE, new Boolean(true));
partition = createPartition();
// JBAS-2769 Init partition in create
log.debug("Initializing ClusterPartition: " + partition);
Thanks for the quick reply Bela.
I think do understand the way the MuxChannels work. My problem was more specific to using MuxChannels with TreeCache. After further investigation, it turns out that in the following code:
TreeCache cache = new TreeCache(muxChannel);
PropertyConfigurator config = new PropertyConfigurator();
The PropertyConfigurator seems to be culprit. Somehow when I use the PropertyConfigurator my cache doesn't seem to start. If I get rid of the PropertyConfigurator, everything seems to work fine.
Am I missing something obvious here ...
Missing something, but not something obvious :(.
Multiplexer integration is not supported in 1.4.0.SP1. The configuration attributes were added, but the ability to access the multiplexer was not enabled (for reasons due to release timing.)
Multiplexer integration is enabled in the just released 1.4.1.Beta1.
It's not so much the PropertyConfigurator, it was happening whenever I enable REPLICATION on the Cache. I had to setInactiveOnStartUp(true) for my cache(s) to startup. Now I am running into issues where its not actually replicating :(
I'll give 1.4.1.Beta1 a try and post my observations here ... Thanks Brian
Brian I copied the configureForMux() method from the MultiplexerTestHelper class and modified it a little so that I can use it in my standalone app (w/o JMX and stuff). It works as expected now.
Brian and Bela thanks for all your help.