Class MessageDispatchInterceptor
- java.lang.Object
- 
- org.apache.catalina.tribes.group.ChannelInterceptorBase
- 
- org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor
 
 
- 
- All Implemented Interfaces:
- ChannelInterceptor,- MessageDispatchInterceptorMBean,- Heartbeat,- MembershipListener
 
 public class MessageDispatchInterceptor extends ChannelInterceptorBase implements MessageDispatchInterceptorMBean The message dispatcher is a way to enable asynchronous communication through a channel. The dispatcher will look for theChannel.SEND_OPTIONS_ASYNCHRONOUSflag to be set, if it is, it will queue the message for delivery and immediately return to the sender.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.apache.catalina.tribes.ChannelInterceptorChannelInterceptor.InterceptorEvent
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected booleanalwaysSendprotected java.util.concurrent.atomic.AtomicLongcurrentSizeprotected java.util.concurrent.ExecutorServiceexecutorprotected longkeepAliveTimeprotected longmaxQueueSizeprotected intmaxSpareThreadsprotected intmaxThreadsprotected booleanrunprotected static StringManagersmprotected booleanuseDeepClone- 
Fields inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBaseoptionFlag
 
- 
 - 
Constructor SummaryConstructors Constructor Description MessageDispatchInterceptor()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description longaddAndGetCurrentSize(long inc)booleanaddToQueue(ChannelMessage msg, Member[] destination, InterceptorPayload payload)intgetActiveCount()Return the current number of threads that are in use.longgetCompletedTaskCount()Return the total number of tasks that have completed execution by the pool.longgetCurrentSize()longgetKeepAliveTime()longgetMaxQueueSize()intgetMaxSpareThreads()intgetMaxThreads()intgetPoolSize()Return the current number of threads that are managed by the pool.longgetTaskCount()Return the total number of tasks that have ever been scheduled for execution by the pool.booleangetUseDeepClone()booleanisAlwaysSend()protected voidsendAsyncData(ChannelMessage msg, Member[] destination, InterceptorPayload payload)voidsendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)ThesendMessagemethod is called when a message is being sent to one more destinations.voidsetAlwaysSend(boolean alwaysSend)longsetAndGetCurrentSize(long value)voidsetKeepAliveTime(long keepAliveTime)voidsetMaxQueueSize(long maxQueueSize)voidsetMaxSpareThreads(int maxSpareThreads)voidsetMaxThreads(int maxThreads)voidsetOptionFlag(int flag)Sets the option flagvoidsetUseDeepClone(boolean useDeepClone)voidstart(int svc)Starts up the channel.voidstartQueue()voidstop(int svc)Shuts down the channel.voidstopQueue()- 
Methods inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBasefireInterceptorEvent, getChannel, getLocalMember, getMember, getMembers, getNext, getOptionFlag, getPrevious, hasMembers, heartbeat, memberAdded, memberDisappeared, messageReceived, okToProcess, setChannel, setNext, setPrevious
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptorMBeangetOptionFlag
 
- 
 
- 
- 
- 
Field Detail- 
smprotected static final StringManager sm 
 - 
maxQueueSizeprotected long maxQueueSize 
 - 
runprotected volatile boolean run 
 - 
useDeepCloneprotected boolean useDeepClone 
 - 
alwaysSendprotected boolean alwaysSend 
 - 
currentSizeprotected final java.util.concurrent.atomic.AtomicLong currentSize 
 - 
executorprotected java.util.concurrent.ExecutorService executor 
 - 
maxThreadsprotected int maxThreads 
 - 
maxSpareThreadsprotected int maxSpareThreads 
 - 
keepAliveTimeprotected long keepAliveTime 
 
- 
 - 
Method Detail- 
sendMessagepublic void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException Description copied from interface:ChannelInterceptorThesendMessagemethod is called when a message is being sent to one more destinations. The interceptor can modify any of the parameters and then pass on the message down the stack by invokinggetNext().sendMessage(destination,msg,payload)
 Alternatively the interceptor can stop the message from being sent by not invokinggetNext().sendMessage(destination,msg,payload)
 If the message is to be sent asynchronous the application can be notified of completion and errors by passing in an error handler attached to a payload object.
 The ChannelMessage.getAddress contains Channel.getLocalMember, and can be overwritten to simulate a message sent from another node.- Specified by:
- sendMessagein interface- ChannelInterceptor
- Overrides:
- sendMessagein class- ChannelInterceptorBase
- Parameters:
- destination- Member[] - the destination for this message
- msg- ChannelMessage - the message to be sent
- payload- InterceptorPayload - the payload, carrying an error handler and future useful data, can be null
- Throws:
- ChannelException- if a serialization error happens.
- See Also:
- ErrorHandler,- InterceptorPayload
 
 - 
addToQueuepublic boolean addToQueue(ChannelMessage msg, Member[] destination, InterceptorPayload payload) 
 - 
startQueuepublic void startQueue() 
 - 
stopQueuepublic void stopQueue() 
 - 
setOptionFlagpublic void setOptionFlag(int flag) Description copied from interface:ChannelInterceptorSets the option flag- Specified by:
- setOptionFlagin interface- ChannelInterceptor
- Overrides:
- setOptionFlagin class- ChannelInterceptorBase
- Parameters:
- flag- int
- See Also:
- ChannelInterceptor.getOptionFlag()
 
 - 
setMaxQueueSizepublic void setMaxQueueSize(long maxQueueSize) 
 - 
setUseDeepClonepublic void setUseDeepClone(boolean useDeepClone) 
 - 
getMaxQueueSizepublic long getMaxQueueSize() - Specified by:
- getMaxQueueSizein interface- MessageDispatchInterceptorMBean
 
 - 
getUseDeepClonepublic boolean getUseDeepClone() 
 - 
getCurrentSizepublic long getCurrentSize() - Specified by:
- getCurrentSizein interface- MessageDispatchInterceptorMBean
 
 - 
addAndGetCurrentSizepublic long addAndGetCurrentSize(long inc) 
 - 
setAndGetCurrentSizepublic long setAndGetCurrentSize(long value) 
 - 
getKeepAliveTimepublic long getKeepAliveTime() - Specified by:
- getKeepAliveTimein interface- MessageDispatchInterceptorMBean
 
 - 
getMaxSpareThreadspublic int getMaxSpareThreads() - Specified by:
- getMaxSpareThreadsin interface- MessageDispatchInterceptorMBean
 
 - 
getMaxThreadspublic int getMaxThreads() - Specified by:
- getMaxThreadsin interface- MessageDispatchInterceptorMBean
 
 - 
setKeepAliveTimepublic void setKeepAliveTime(long keepAliveTime) 
 - 
setMaxSpareThreadspublic void setMaxSpareThreads(int maxSpareThreads) 
 - 
setMaxThreadspublic void setMaxThreads(int maxThreads) 
 - 
isAlwaysSendpublic boolean isAlwaysSend() - Specified by:
- isAlwaysSendin interface- MessageDispatchInterceptorMBean
 
 - 
setAlwaysSendpublic void setAlwaysSend(boolean alwaysSend) - Specified by:
- setAlwaysSendin interface- MessageDispatchInterceptorMBean
 
 - 
startpublic void start(int svc) throws ChannelExceptionDescription copied from class:ChannelInterceptorBaseStarts up the channel. This can be called multiple times for individual services to start The svc parameter can be the logical or value of any constants- Specified by:
- startin interface- ChannelInterceptor
- Overrides:
- startin class- ChannelInterceptorBase
- Parameters:
- svc- int value of
 DEFAULT - will start all services
 MBR_RX_SEQ - starts the membership receiver
 MBR_TX_SEQ - starts the membership broadcaster
 SND_TX_SEQ - starts the replication transmitter
 SND_RX_SEQ - starts the replication receiver
- Throws:
- ChannelException- if a startup error occurs or the service is already started.
- See Also:
- Channel
 
 - 
stoppublic void stop(int svc) throws ChannelExceptionDescription copied from class:ChannelInterceptorBaseShuts down the channel. This can be called multiple times for individual services to shutdown The svc parameter can be the logical or value of any constants- Specified by:
- stopin interface- ChannelInterceptor
- Overrides:
- stopin class- ChannelInterceptorBase
- Parameters:
- svc- int value of
 DEFAULT - will shutdown all services
 MBR_RX_SEQ - stops the membership receiver
 MBR_TX_SEQ - stops the membership broadcaster
 SND_TX_SEQ - stops the replication transmitter
 SND_RX_SEQ - stops the replication receiver
- Throws:
- ChannelException- if a startup error occurs or the service is already started.
- See Also:
- Channel
 
 - 
sendAsyncDataprotected void sendAsyncData(ChannelMessage msg, Member[] destination, InterceptorPayload payload) 
 - 
getPoolSizepublic int getPoolSize() Return the current number of threads that are managed by the pool.- Specified by:
- getPoolSizein interface- MessageDispatchInterceptorMBean
- Returns:
- the current number of threads that are managed by the pool
 
 - 
getActiveCountpublic int getActiveCount() Return the current number of threads that are in use.- Specified by:
- getActiveCountin interface- MessageDispatchInterceptorMBean
- Returns:
- the current number of threads that are in use
 
 - 
getTaskCountpublic long getTaskCount() Return the total number of tasks that have ever been scheduled for execution by the pool.- Specified by:
- getTaskCountin interface- MessageDispatchInterceptorMBean
- Returns:
- the total number of tasks that have ever been scheduled for execution by the pool
 
 - 
getCompletedTaskCountpublic long getCompletedTaskCount() Return the total number of tasks that have completed execution by the pool.- Specified by:
- getCompletedTaskCountin interface- MessageDispatchInterceptorMBean
- Returns:
- the total number of tasks that have completed execution by the pool
 
 
- 
 
-