Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
FailoverManager.h
Go to the documentation of this file.
1 #ifndef QPID_CLIENT_FAILOVERMANAGER_H
2 #define QPID_CLIENT_FAILOVERMANAGER_H
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "qpid/Exception.h"
28 #include "qpid/client/Connection.h"
31 #include "qpid/sys/Monitor.h"
32 #include <vector>
33 
34 namespace qpid {
35 namespace client {
36 
38 {
39  CannotConnectException(const std::string& m) : qpid::Exception(m) {}
40 };
41 
46 {
47  public:
52  struct Command
53  {
64  virtual void execute(AsyncSession& session, bool isRetry) = 0;
65  virtual ~Command() {}
66  };
67 
69  {
77  virtual void editUrlList(std::vector<Url>& urls) = 0;
78  virtual ~ReconnectionStrategy() {}
79  };
80 
89  QPID_CLIENT_EXTERN FailoverManager(const ConnectionSettings& settings, ReconnectionStrategy* strategy = 0);
101  QPID_CLIENT_EXTERN Connection& connect(std::vector<Url> brokers = std::vector<Url>());
105  QPID_CLIENT_EXTERN Connection& getConnection();
109  QPID_CLIENT_EXTERN void close();
122  QPID_CLIENT_EXTERN void execute(Command&);
123  private:
124  enum State {IDLE, CONNECTING, CANT_CONNECT};
125 
126  qpid::sys::Monitor lock;
127  Connection connection;
128  std::auto_ptr<FailoverListener> failoverListener;
129  ConnectionSettings settings;
130  ReconnectionStrategy* strategy;
131  State state;
132 
133  void attempt(Connection&, ConnectionSettings settings, std::vector<Url> urls);
134  void attempt(Connection&, ConnectionSettings settings);
135 };
136 }} // namespace qpid::client
137 
138 #endif
#define QPID_CLIENT_CLASS_EXTERN
Settings for a Connection.
Base class for Qpid runtime exceptions.
Definition: Exception.h:39
Represents a connection to an AMQP broker.
Definition: Connection.h:63
Interface to implement for doing work that can be resumed on failover.
This file was automatically generated from the AMQP specification.
Definition: Address.h:27
CannotConnectException(const std::string &m)
Utility to manage failover.
#define QPID_CLIENT_EXTERN
A monitor is a condition variable and a mutex.
Definition: Monitor.h:33
AMQP 0-10 session API with keyword arguments.

Qpid C++ API Reference
Generated on Fri Feb 6 2015 for Qpid C++ Client API by doxygen 1.8.9.1