The Channel Interceptor object

Table of Contents

Introduction

Apache Tribes supports an interceptor architecture to intercept both messages and membership notifications. This architecture allows decoupling of logic and opens the way for some very kewl feature add ons.

Available Interceptors

  • org.apache.catalina.tribes.group.interceptors.TcpFailureDetector
  • org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor
  • org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor
  • org.apache.catalina.tribes.group.interceptors.NonBlockingCoordinator
  • org.apache.catalina.tribes.group.interceptors.OrderInterceptor
  • org.apache.catalina.tribes.group.interceptors.SimpleCoordinator
  • org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor
  • org.apache.catalina.tribes.group.interceptors.TwoPhaseCommitInterceptor
  • org.apache.catalina.tribes.group.interceptors.DomainFilterInterceptor
  • org.apache.catalina.tribes.group.interceptors.FragmentationInterceptor
  • org.apache.catalina.tribes.group.interceptors.GzipInterceptor
  • org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor

Static Membership

In addition to dynamic discovery, Apache Tribes also supports static membership, with membership verification. To achieve this add the org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor after the org.apache.catalina.tribes.group.interceptors.TcpFailureDetector interceptor. Inside the StaticMembershipInterceptor you can add the static members you wish to have. The TcpFailureDetector will do a health check on the static members,and also monitor them for crashes so they will have the same level of notification mechanism as the members that are automatically discovered.

     <Interceptor className="org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor">
       <LocalMember className="org.apache.catalina.tribes.membership.StaticMember"
                  domain="staging-cluster"
                  uniqueId="{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1}"/>
       <Member className="org.apache.catalina.tribes.membership.StaticMember"
                  port="5678"
                  securePort="-1"
                  host="tomcat01.mydomain.com"
                  domain="staging-cluster"
                  uniqueId="{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}"/>
     </Interceptor>

Attributes

Common Attributes

Attribute Description
className Required, as there is no default
optionFlag If you want the interceptor to trigger on certain message depending on the message's option flag, you can setup the interceptors flag here. The default value is 0, meaning this interceptor will trigger on all messages.

org.apache.catalina.tribes.group.interceptors.DomainFilterInterceptor Attributes

Attribute Description
domain The logical cluster domain that this Interceptor accepts. Two different type of values are possible:
1. Regular string values like "staging-domain" or "tomcat-cluster" will be converted into bytes using ISO-8859-1 encoding.
2. byte array in string form, for example {216,123,12,3}
logInterval This value indicates the interval for logging for messages from different domains. The default is 100, which means that to log per 100 messages.

org.apache.catalina.tribes.group.interceptors.FragmentationInterceptor Attributes

Attribute Description
expire How long do we keep the fragments in memory and wait for the rest to arrive. The default is 60000 ms.
maxSize The maximum message size in bytes. If the message size exceeds this value, this interceptor fragments the message and sends them. If it is less than this value, this interceptor does not fragment the message and sent in as one message. The default is 1024*100.

org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor Attributes

Attribute Description
optionFlag The default and hard coded value is 8 (org.apache.catalina.tribes.Channel.SEND_OPTIONS_ASYNCHRONOUS). The dispatcher will trigger on this value only, as it is predefined by Tribes.
alwaysSend What behavior should be executed when the dispatch queue is full. If true (default), then the message is is sent synchronously, if false an error is thrown.
maxQueueSize Size in bytes of the dispatch queue, the default value is 1024*1024*64 (64MB) sets the maximum queue size for the dispatch queue if the queue fills up, one can trigger the behavior, if alwaysSend is set to true, the message will be sent synchronously if the flag is false, an error is thrown
maxThreads The maximum number of threads in this pool, default is 10.
maxSpareThreads The number of threads to keep in the pool, default is 2.
keepAliveTime Maximum number of milliseconds of until Idle thread terminates. Default value is 5000(5 seconds).