tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Kn├╝mann ...@business-code.de>
Subject What is the lifecycle of the apache tribes channel?
Date Mon, 18 Oct 2010 08:44:56 GMT

  Hi,

I'm using apache tribes for messaging between nodes within a cluster. My 
implementation bases on the quickstart example that is part of the 
related documentation.
At the moment there is Context Listener that starts the communication 
during the deployment of the webapp like this:
   public void start(ChannelListener msgListener, MembershipListener 
mbrListener) throws ChannelException
   {
     myChannel = new GroupChannel();

     this.msgListener = msgListener;
     this.mbrListener = mbrListener;

     //attach the listeners to the channel
     myChannel.addMembershipListener(mbrListener);
     myChannel.addChannelListener(msgListener);

     //start the channel
     myChannel.start(Channel.DEFAULT);

   }

and in case the application is stopped the communication channel is 
stopped like this:

   public void stop() throws ChannelException
   {

     myChannel.removeChannelListener(msgListener);
     myChannel.removeMembershipListener(mbrListener);
     myChannel.stop(Channel.DEFAULT);
   }

The sending of messages is implemented this way:

  public void sendMessage(ClusterCacheMessage message ) throws 
ChannelException, ClusterMessageCtrlException
   {
     assertStartedProperly();
     //create a message to be sent, message must implement 
java.io.Serializable
     //for performance reasons you probably want them to implement 
java.io.Externalizable
     //Serializable myMsg = new MyMessage();

     //retrieve my current members
     Member[] group = myChannel.getMembers();

     logger.fine("Send message:" + message.getCacheName());
     //send the message
     myChannel.send(group,message,Channel.SEND_OPTIONS_DEFAULT);

   }


My question is do I need the channel started the whole time, or I can 
open it every time I send a message?



with kind regards
     Michael




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message