|
activemq-cpp-3.3.0
|
00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _ACTIVEMQ_TRANSPORT_INACTIVITY_INACTIVITYMONITOR_H_ 00019 #define _ACTIVEMQ_TRANSPORT_INACTIVITY_INACTIVITYMONITOR_H_ 00020 00021 #include <activemq/util/Config.h> 00022 00023 #include <activemq/transport/TransportFilter.h> 00024 #include <activemq/commands/Command.h> 00025 #include <activemq/commands/Response.h> 00026 #include <activemq/commands/WireFormatInfo.h> 00027 #include <activemq/wireformat/WireFormat.h> 00028 00029 #include <decaf/lang/Pointer.h> 00030 #include <decaf/util/Timer.h> 00031 #include <decaf/util/Properties.h> 00032 #include <decaf/util/concurrent/atomic/AtomicBoolean.h> 00033 00034 namespace activemq { 00035 namespace transport { 00036 namespace inactivity { 00037 00038 using decaf::lang::Pointer; 00039 00040 class ReadChecker; 00041 class WriteChecker; 00042 class AsyncSignalReadErrorkTask; 00043 class AsyncWriteTask; 00044 class InactivityMonitorData; 00045 00046 class AMQCPP_API InactivityMonitor : public TransportFilter { 00047 private: 00048 00049 // Internal Class used to house the data structures for this object 00050 InactivityMonitorData* members; 00051 00052 friend class ReadChecker; 00053 friend class AsyncSignalReadErrorkTask; 00054 friend class WriteChecker; 00055 friend class AsyncWriteTask; 00056 00057 private: 00058 00059 InactivityMonitor( const InactivityMonitor& ); 00060 InactivityMonitor operator= ( const InactivityMonitor& ); 00061 00062 public: 00063 00064 InactivityMonitor( const Pointer<Transport>& next, 00065 const Pointer<wireformat::WireFormat>& wireFormat ); 00066 00067 InactivityMonitor( const Pointer<Transport>& next, 00068 const decaf::util::Properties& properties, 00069 const Pointer<wireformat::WireFormat>& wireFormat ); 00070 00071 virtual ~InactivityMonitor(); 00072 00073 public: // TransportFilter Methods 00074 00075 virtual void close(); 00076 00077 virtual void onException( const decaf::lang::Exception& ex ); 00078 00079 virtual void onCommand( const Pointer<Command>& command ); 00080 00081 virtual void oneway( const Pointer<Command>& command ); 00082 00083 public: 00084 00085 bool isKeepAliveResponseRequired() const; 00086 00087 void setKeepAliveResponseRequired( bool value ); 00088 00089 long long getReadCheckTime() const; 00090 00091 void setReadCheckTime( long long value ); 00092 00093 long long getWriteCheckTime() const; 00094 00095 void setWriteCheckTime( long long value ); 00096 00097 long long getInitialDelayTime() const; 00098 00099 void setInitialDelayTime( long long value ) const; 00100 00101 private: 00102 00103 // Throttles read checking 00104 bool allowReadCheck( long long elapsed ); 00105 00106 // Performs a Read Check on the current connection, called from a separate Thread. 00107 void readCheck(); 00108 00109 // Perform a Write Check on the current connection, called from a separate Thread. 00110 void writeCheck(); 00111 00112 // Stops all the monitoring Threads, cannot restart once called. 00113 void stopMonitorThreads(); 00114 00115 // Starts the monitoring Threads, 00116 void startMonitorThreads(); 00117 00118 }; 00119 00120 }}} 00121 00122 #endif /* _ACTIVEMQ_TRANSPORT_INACTIVITY_INACTIVITYMONITOR_H_ */