[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Re: Can't configure a single, shared JGroups channel

bstansberry@jboss.com do-not-reply at jboss.com
Mon Sep 17 15:15:22 EDT 2007


This shouldn't be an issue.  From the JBM point of view, you have two separate channels. Code written to use your control channel will not see messages destined for your data channel, and vice versa. It's just that the JGroups multiplexes them on top of the same underlying JChannel.

When you call JChannelFactory.createMultiplexerChannel("udp", "DefaultPartition-JMS", true, "DefaultPartition-JMS") you're asking the channel factory to give you a channel based on the "udp" config.  If there isn't already a multiplexed channel based on "udp" the factory will create a regular JChannel based on the "udp" config. It will then attach an instance of Multiplexer to that JChannel.  It will then create an instance of MuxChannel and register it with the Multiplexer under the id "DefaultPartition-JMS". That MuxChannel is what gets returned to you.  When you send messages using the MuxChannel, the Multiplexer adds "DefaultPartition-JMS" as a header to the message.  On the other side, the Multiplexer reads messages off the underlying JChannel, reads out the "DefaultPartition-JMS" header, and passes them on to the correct MuxChannel.

Note that the factory will only create one underlying JChannel based on "udp"; anyone who passes "udp" as an arg will get a MuxChannel that's using that same underlying JChannel. So, if other AS services also use "udp", they'll be sharing the same underlying channel with JBM.

The problem I'm describing occurs from this usage in MultiplexerJChannelFactory:


  |    public JChannel createControlChannel() throws Exception
  |    {
  |       return (JChannel) server.invoke(this.channelFactory, MUX_OPERATION,
  |          new Object[]{syncStack, uniqueID, Boolean.TRUE, uniqueID}, MUX_SIGNATURE);
  |    }
  | 
  |    public JChannel createDataChannel() throws Exception
  |    {
  |       return (JChannel) server.invoke(this.channelFactory, MUX_OPERATION,
  |          new Object[]{asyncStack, uniqueID, Boolean.TRUE, uniqueID}, MUX_SIGNATURE);
  |    }
  | 

If syncStack and asyncStack are the same, JGroups will barf when you ask for the 2nd channel.  This fixes the problem in a brute way:


  |    public JChannel createControlChannel() throws Exception
  |    {
  |       String controlId = uniqueId + "-CTRL";
  |       return (JChannel) server.invoke(this.channelFactory, MUX_OPERATION,
  |          new Object[]{syncStack, controlId, Boolean.TRUE, controlID}, MUX_SIGNATURE);
  |    }
  | 
  |    public JChannel createDataChannel() throws Exception
  |    {
  |       String dataId = uniqueId + "-DATA";
  |       return (JChannel) server.invoke(this.channelFactory, MUX_OPERATION,
  |          new Object[]{asyncStack, dataID, Boolean.TRUE, dataID}, MUX_SIGNATURE);
  |    }
  | 


BTW, I see in MultiplexerJChannelFactory you're casting the return from createMultiplexerChannel() to the concrete class JChannel.  The API for the method returns interface Channel.  The cast works because MuxChannel subclasses JChannel.  But that's really an implementation detail you *shouldn't* count on.  I doubt Bela will change it any time soon, but...

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4085228#4085228

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4085228



More information about the jboss-dev-forums mailing list