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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to