activemq-cpp-3.8.2
FailoverTransport.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _ACTIVE_TRANSPORT_FAILOVER_FAILOVERTRANSPORT_H_
19 #define _ACTIVE_TRANSPORT_FAILOVER_FAILOVERTRANSPORT_H_
20 
21 #include <activemq/util/Config.h>
22 
30 
31 #include <decaf/util/List.h>
32 #include <decaf/util/Properties.h>
33 #include <decaf/net/URI.h>
34 #include <decaf/io/IOException.h>
35 
36 namespace activemq {
37 namespace transport {
38 namespace failover {
39 
40  using namespace decaf::lang;
43 
44  class FailoverTransportListener;
45  class BackupTransportPool;
46  class FailoverTransportImpl;
47 
50  private:
51 
53  friend class BackupTransportPool;
54 
55  state::ConnectionStateTracker stateTracker;
56 
57  FailoverTransportImpl* impl;
58 
59  private:
60 
62  FailoverTransport& operator=(const FailoverTransport&);
63 
64  public:
65 
67 
68  virtual ~FailoverTransport();
69 
77  void reconnect(bool rebalance);
78 
87  void add(bool rebalance, const std::string& uri);
88 
89  public: // CompositeTransport methods
90 
91  virtual void addURI(bool rebalance, const List<decaf::net::URI>& uris);
92 
93  virtual void removeURI(bool rebalance, const List<decaf::net::URI>& uris);
94 
95  public:
96 
97  virtual void start();
98 
99  virtual void stop();
100 
101  virtual void close();
102 
103  virtual void oneway(const Pointer<Command> command);
104 
105  virtual Pointer<FutureResponse> asyncRequest(const Pointer<Command> command,
106  const Pointer<ResponseCallback> responseCallback);
107 
108  virtual Pointer<Response> request(const Pointer<Command> command);
109 
110  virtual Pointer<Response> request(const Pointer<Command> command, unsigned int timeout);
111 
112  virtual Pointer<wireformat::WireFormat> getWireFormat() const;
113 
114  virtual void setWireFormat(const Pointer<wireformat::WireFormat> wireFormat AMQCPP_UNUSED) {}
115 
116  virtual void setTransportListener(TransportListener* listener);
117 
118  virtual TransportListener* getTransportListener() const;
119 
120  virtual bool isFaultTolerant() const {
121  return true;
122  }
123 
124  virtual bool isConnected() const;
125 
126  virtual bool isClosed() const;
127 
128  bool isInitialized() const;
129 
130  void setInitialized(bool value);
131 
132  virtual Transport* narrow(const std::type_info& typeId);
133 
134  virtual std::string getRemoteAddress() const;
135 
136  virtual void reconnect(const decaf::net::URI& uri);
137 
138  virtual void updateURIs(bool rebalance, const decaf::util::List<decaf::net::URI>& uris);
139 
140  public:
141 
146  virtual bool isPending() const;
147 
155  virtual bool iterate();
156 
157  public:
158 
159  long long getTimeout() const;
160 
161  void setTimeout(long long value);
162 
163  long long getInitialReconnectDelay() const;
164 
165  void setInitialReconnectDelay(long long value);
166 
167  long long getMaxReconnectDelay() const;
168 
169  void setMaxReconnectDelay(long long value);
170 
171  long long getBackOffMultiplier() const;
172 
173  void setBackOffMultiplier(long long value);
174 
175  bool isUseExponentialBackOff() const;
176 
177  void setUseExponentialBackOff(bool value);
178 
179  bool isRandomize() const;
180 
181  void setRandomize(bool value);
182 
183  int getMaxReconnectAttempts() const;
184 
185  void setMaxReconnectAttempts(int value);
186 
187  int getStartupMaxReconnectAttempts() const;
188 
189  void setStartupMaxReconnectAttempts(int value);
190 
191  long long getReconnectDelay() const;
192 
193  void setReconnectDelay(long long value);
194 
195  bool isBackup() const;
196 
197  void setBackup(bool value);
198 
199  int getBackupPoolSize() const;
200 
201  void setBackupPoolSize(int value);
202 
203  bool isTrackMessages() const;
204 
205  void setTrackMessages(bool value);
206 
207  bool isTrackTransactionProducers() const;
208 
209  void setTrackTransactionProducers(bool value);
210 
211  int getMaxCacheSize() const;
212 
213  void setMaxCacheSize(int value);
214 
215  int getMaxPullCacheSize() const;
216 
217  void setMaxPullCacheSize(int value);
218 
219  bool isReconnectSupported() const;
220 
221  void setReconnectSupported(bool value);
222 
223  bool isUpdateURIsSupported() const;
224 
225  void setUpdateURIsSupported(bool value);
226 
227  bool isRebalanceUpdateURIs() const;
228 
229  void setRebalanceUpdateURIs(bool rebalanceUpdateURIs);
230 
231  bool isPriorityBackup() const;
232 
233  void setPriorityBackup(bool priorityBackup);
234 
235  void setPriorityURIs(const std::string& priorityURIs);
236 
237  const decaf::util::List<decaf::net::URI>& getPriorityURIs() const;
238 
239  void setConnectionInterruptProcessingComplete(const Pointer<commands::ConnectionId> connectionId);
240 
241  bool isConnectedToPriority() const;
242 
243  protected:
244 
254  void restoreTransport(const Pointer<Transport> transport);
255 
261  void handleTransportFailure(const decaf::lang::Exception& error);
262 
271  void handleConnectionControl(const Pointer<Command> control);
272 
273  private:
274 
283  Pointer<Transport> createTransport(const decaf::net::URI& location) const;
284 
285  void processNewTransports(bool rebalance, std::string newTransports);
286 
287  void processResponse(const Pointer<Response> response);
288 
289  };
290 
291 }}}
292 
293 #endif /* _ACTIVE_TRANSPORT_FAILOVER_FAILOVERTRANSPORT_H_ */
virtual void setWireFormat(const Pointer< wireformat::WireFormat > wireFormat AMQCPP_UNUSED)
Sets the WireFormat instance to use.
Definition: FailoverTransport.h:114
#define AMQCPP_API
Definition: Config.h:30
Definition: BackupTransportPool.h:43
virtual bool isFaultTolerant() const
Is this Transport fault tolerant, meaning that it will reconnect to a broker on disconnect.
Definition: FailoverTransport.h:120
Definition: Response.h:46
Interface for a transport layer for command objects.
Definition: Transport.h:59
A Composite Transport is a Transport implementation that is composed of several Transports.
Definition: CompositeTransport.h:40
Represents a single task that can be part of a set of Tasks that are contained in a CompositeTaskRunn...
Definition: CompositeTask.h:33
Definition: ConnectionStateTracker.h:41
Utility class used by the Transport to perform the work of responding to events from the active Trans...
Definition: FailoverTransportListener.h:37
This class represents an instance of a URI as defined by RFC 2396.
Definition: URI.h:36
Definition: ThreadingTypes.h:31
Definition: FailoverTransport.h:48
Definition: Command.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: CachedConsumer.h:24
Definition: Exception.h:38
An ordered collection (also known as a sequence).
Definition: List.h:47
Decaf&#39;s implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition: Pointer.h:53
A listener of asynchronous exceptions from a command transport object.
Definition: TransportListener.h:38