@Override
 public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
     throws ChannelException {
   if (!okToProcess(msg.getOptions())) {
     super.sendMessage(destination, msg, payload);
     return;
   }
   ChannelException cx = null;
   for (int i = 0; i < destination.length; i++) {
     try {
       int nr = 0;
       try {
         outLock.writeLock().lock();
         nr = incCounter(destination[i]);
       } finally {
         outLock.writeLock().unlock();
       }
       // reduce byte copy
       msg.getMessage().append(nr);
       try {
         getNext().sendMessage(new Member[] {destination[i]}, msg, payload);
       } finally {
         msg.getMessage().trim(4);
       }
     } catch (ChannelException x) {
       if (cx == null) cx = x;
       cx.addFaultyMember(x.getFaultyMembers());
     }
   } // for
   if (cx != null) throw cx;
 }
 @Override
 public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
     throws ChannelException {
   try {
     super.sendMessage(destination, msg, payload);
   } catch (ChannelException cx) {
     ChannelExceptionFaultyMember[] mbrs = cx.getFaultyMembers();
     for (int i = 0; i < mbrs.length; i++) {
       if (mbrs[i].getCause() != null
           && (!(mbrs[i].getCause()
               instanceof RemoteProcessException))) { // RemoteProcessException's are ok
         this.memberDisappeared(mbrs[i].getMember());
       } // end if
     } // for
     throw cx;
   }
 }
    @Override
    public void sendMessage(Member[] destination, ChannelMessage msg, org.apache.catalina.tribes.group.InterceptorPayloadRemoteInterface payload) throws ChannelException, RemoteException {
		try {
		    try {
		        super.sendMessage(destination, msg, payload);
		    }catch ( ChannelException cx ) {
		    	org.apache.catalina.tribes.ChannelExceptionFaultyMemberRemoteInterface[] mbrs = cx.getFaultyMembers();
		        for ( int i=0; i<mbrs.length; i++ ) {
		            if ( mbrs[i].getCause()!=null &&
		                 (!(mbrs[i].getCause() instanceof RemoteProcessException)) ) {//RemoteProcessException's are ok
		                this.memberDisappeared(mbrs[i].getMember());
		            }//end if
		        }//for
		        throw cx;
		    }
		} catch (Exception excp) {
			excp.printStackTrace();
		}
	}
  @Override
  public synchronized void sendMessage(Member[] destination, ChannelMessage msg)
      throws ChannelException, RemoteException {
    try {
      long start = System.currentTimeMillis();
      this.setUdpBased((msg.getOptions() & Channel.SEND_OPTIONS_UDP) == Channel.SEND_OPTIONS_UDP);
      byte[] data =
          gerenciadornuvem1.XByteBuffercreateDataPackage(
              (org.apache.catalina.tribes.io.ChannelDataRemoteInterface) msg);
      org.apache.catalina.tribes.transport.nio.NioSenderRemoteInterface[] senders =
          setupForSend(destination);
      connect(senders);
      setData(senders, data);

      int remaining = senders.length;
      ChannelException cx = null;
      try {
        // loop until complete, an error happens, or we timeout
        long delta = System.currentTimeMillis() - start;
        boolean waitForAck =
            (Channel.SEND_OPTIONS_USE_ACK & msg.getOptions()) == Channel.SEND_OPTIONS_USE_ACK;
        while ((remaining > 0) && (delta < getTimeout())) {
          try {
            remaining -= doLoop(selectTimeout, getMaxRetryAttempts(), waitForAck, msg);
          } catch (Exception x) {
            if (log.isTraceEnabled()) log.trace("Error sending message", x);
            int faulty = (cx == null) ? 0 : cx.getFaultyMembers().length;
            if (cx == null) {
              if (x instanceof ChannelException) cx = (ChannelException) x;
              else cx = gerenciadornuvem1.getChannelException("Parallel NIO send failed.", x);
            } else {
              if (x instanceof ChannelException)
                cx.addFaultyMember(((ChannelException) x).getFaultyMembers());
            }
            // count down the remaining on an error
            if (faulty < cx.getFaultyMembers().length)
              remaining -= (cx.getFaultyMembers().length - faulty);
          }
          // bail out if all remaining senders are failing
          if (cx != null && cx.getFaultyMembers().length == remaining) throw cx;
          delta = System.currentTimeMillis() - start;
        }
        if (remaining > 0) {
          // timeout has occurred
          ChannelException cxtimeout =
              gerenciadornuvem1.getChannelException(
                  "Operation has timed out(" + getTimeout() + " ms.).");
          if (cx == null)
            cx =
                gerenciadornuvem1.getChannelException(
                    "Operation has timed out(" + getTimeout() + " ms.).");
          for (int i = 0; i < senders.length; i++) {
            if (!senders[i].isComplete())
              cx.addFaultyMember(senders[i].getDestination(), cxtimeout);
          }
          throw cx;
        } else if (cx != null) {
          // there was an error
          throw cx;
        }
      } catch (Exception x) {
        try {
          this.disconnect();
        } catch (Exception e) {
          /* Ignore */
        }
        if (x instanceof ChannelException) throw (ChannelException) x;
        else throw new ChannelException(x);
      }

    } catch (Exception excp) {
      excp.printStackTrace();
    }
  }