activemq-cpp-3.9.5
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
22
30
31#include <decaf/util/List.h>
33#include <decaf/net/URI.h>
35
36namespace activemq {
37namespace transport {
38namespace failover {
39
40 using namespace decaf::lang;
41 using activemq::commands::Command;
42 using activemq::commands::Response;
43
46 class FailoverTransportImpl;
47
48 class AMQCPP_API FailoverTransport : public CompositeTransport,
50 private:
51
53 friend class BackupTransportPool;
54
56
57 FailoverTransportImpl* impl;
58
59 private:
60
61 FailoverTransport(const FailoverTransport&);
62 FailoverTransport& operator=(const FailoverTransport&);
63
64 public:
65
67
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
106 const Pointer<ResponseCallback> responseCallback);
107
109
110 virtual Pointer<Response> request(const Pointer<Command> command, unsigned int timeout);
111
113
114 virtual void setWireFormat(const Pointer<wireformat::WireFormat> wireFormat AMQCPP_UNUSED) {}
115
117
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
176
177 void setUseExponentialBackOff(bool value);
178
179 bool isRandomize() const;
180
181 void setRandomize(bool value);
182
184
185 void setMaxReconnectAttempts(int value);
186
188
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
208
210
211 int getMaxCacheSize() const;
212
213 void setMaxCacheSize(int value);
214
216
217 void setMaxPullCacheSize(int value);
218
220
221 void setReconnectSupported(bool value);
222
224
225 void setUpdateURIsSupported(bool value);
226
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
238
240
242
243 protected:
244
255
262
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_ */
#define AMQCPP_API
Definition Config.h:30
Definition ConnectionStateTracker.h:41
Represents a single task that can be part of a set of Tasks that are contained in a CompositeTaskRunn...
Definition CompositeTask.h:33
A Composite Transport is a Transport implementation that is composed of several Transports.
Definition CompositeTransport.h:40
Interface for a transport layer for command objects.
Definition Transport.h:60
A listener of asynchronous exceptions from a command transport object.
Definition TransportListener.h:38
Definition BackupTransportPool.h:43
virtual void start()
Starts the Transport, the send methods of a Transport will throw an exception if used before the Tran...
virtual Pointer< FutureResponse > asyncRequest(const Pointer< Command > command, const Pointer< ResponseCallback > responseCallback)
Sends a commands asynchronously, returning a FutureResponse object that the caller can use to check t...
virtual std::string getRemoteAddress() const
friend class BackupTransportPool
Definition FailoverTransport.h:53
virtual bool isFaultTolerant() const
Is this Transport fault tolerant, meaning that it will reconnect to a broker on disconnect.
Definition FailoverTransport.h:120
virtual void close()
Closes this object and deallocates the appropriate resources.
friend class FailoverTransportListener
Definition FailoverTransport.h:52
virtual void stop()
Stops the Transport.
virtual bool isClosed() const
Has the Transport been shutdown and no longer usable.
const decaf::util::List< decaf::net::URI > & getPriorityURIs() const
virtual Pointer< wireformat::WireFormat > getWireFormat() const
Gets the WireFormat instance that is in use by this transport.
virtual bool iterate()
Performs the actual Reconnect operation for the FailoverTransport, when a connection is made this met...
virtual Pointer< Response > request(const Pointer< Command > command)
Sends the given command to the broker and then waits for the response.
void setPriorityURIs(const std::string &priorityURIs)
virtual void oneway(const Pointer< Command > command)
Sends a one-way command.
virtual Pointer< Response > request(const Pointer< Command > command, unsigned int timeout)
Sends the given command to the broker and then waits for the response.
void setConnectionInterruptProcessingComplete(const Pointer< commands::ConnectionId > connectionId)
void setRebalanceUpdateURIs(bool rebalanceUpdateURIs)
virtual void addURI(bool rebalance, const List< decaf::net::URI > &uris)
Add a URI to the list of URI's that will represent the set of Transports that this Transport is a com...
virtual void removeURI(bool rebalance, const List< decaf::net::URI > &uris)
Remove a URI from the set of URI's that represents the set of Transports that this Transport is compo...
void add(bool rebalance, const std::string &uri)
Adds a New URI to the List of URIs this transport can Connect to.
virtual void reconnect(const decaf::net::URI &uri)
reconnect to another location
void handleTransportFailure(const decaf::lang::Exception &error)
Called when this class' TransportListener is notified of a Failure.
virtual Transport * narrow(const std::type_info &typeId)
Narrows down a Chain of Transports to a specific Transport to allow a higher level transport to skip ...
virtual TransportListener * getTransportListener() const
Gets the observer of asynchronous events from this transport.
virtual void setTransportListener(TransportListener *listener)
Sets the observer of asynchronous events from this transport.
void reconnect(bool rebalance)
Indicates that the Transport needs to reconnect to another URI in its list.
virtual void updateURIs(bool rebalance, const decaf::util::List< decaf::net::URI > &uris)
Updates the set of URIs the Transport can connect to.
void restoreTransport(const Pointer< Transport > transport)
Given a Transport restore the state of the Client's connection to the Broker using the data accumulat...
void handleConnectionControl(const Pointer< Command > control)
Called when the Broker sends a ConnectionControl command which could signal that this Client needs to...
virtual void setWireFormat(const Pointer< wireformat::WireFormat > wireFormat AMQCPP_UNUSED)
Sets the WireFormat instance to use.
Definition FailoverTransport.h:114
virtual bool isConnected() const
Is the Transport Connected to its Broker.
Utility class used by the Transport to perform the work of responding to events from the active Trans...
Definition FailoverTransportListener.h:37
Definition Exception.h:38
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition Pointer.h:53
This class represents an instance of a URI as defined by RFC 2396.
Definition URI.h:37
An ordered collection (also known as a sequence).
Definition List.h:47
Definition BackupTransport.h:31
Definition AbstractTransportFactory.h:30
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition CachedConsumer.h:24