00001 #ifndef _Broker_
00002 #define _Broker_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "ConnectionFactory.h"
00026 #include "ConnectionToken.h"
00027 #include "DirectExchange.h"
00028 #include "DtxManager.h"
00029 #include "ExchangeRegistry.h"
00030 #include "MessageStore.h"
00031 #include "QueueRegistry.h"
00032 #include "LinkRegistry.h"
00033 #include "SessionManager.h"
00034 #include "Vhost.h"
00035 #include "System.h"
00036 #include "qpid/management/Manageable.h"
00037 #include "qpid/management/ManagementBroker.h"
00038 #include "qpid/management/Broker.h"
00039 #include "qpid/management/ArgsBrokerConnect.h"
00040 #include "qpid/Options.h"
00041 #include "qpid/Plugin.h"
00042 #include "qpid/DataDir.h"
00043 #include "qpid/framing/FrameHandler.h"
00044 #include "qpid/framing/OutputHandler.h"
00045 #include "qpid/framing/ProtocolInitiation.h"
00046 #include "qpid/sys/Runnable.h"
00047 #include "qpid/sys/ProtocolAccess.h"
00048
00049 #include <vector>
00050
00051 namespace qpid {
00052
00053 namespace sys {
00054 class ProtocolFactory;
00055 class Poller;
00056 }
00057
00058 class Url;
00059
00060 namespace broker {
00061
00062 static const uint16_t DEFAULT_PORT=5672;
00063
00067 class Broker : public sys::Runnable, public Plugin::Target,
00068 public management::Manageable
00069 {
00070 public:
00071
00072 struct Options : public qpid::Options {
00073 Options(const std::string& name="Broker Options");
00074
00075 bool noDataDir;
00076 std::string dataDir;
00077 uint16_t port;
00078 int workerThreads;
00079 int maxConnections;
00080 int connectionBacklog;
00081 uint64_t stagingThreshold;
00082 bool enableMgmt;
00083 uint16_t mgmtPubInterval;
00084 bool auth;
00085 std::string realm;
00086 uint32_t ack;
00087 };
00088
00089 virtual ~Broker();
00090
00091 Broker(const Options& configuration);
00092 static shared_ptr<Broker> create(const Options& configuration);
00093 static shared_ptr<Broker> create(int16_t port = DEFAULT_PORT);
00094
00101 virtual uint16_t getPort() const;
00102
00107 virtual void run();
00108
00110 virtual void shutdown();
00111
00112 void setStore (MessageStore*);
00113 MessageStore& getStore() { return *store; }
00114 QueueRegistry& getQueues() { return queues; }
00115 ExchangeRegistry& getExchanges() { return exchanges; }
00116 LinkRegistry& getLinks() { return links; }
00117 uint64_t getStagingThreshold() { return config.stagingThreshold; }
00118 DtxManager& getDtxManager() { return dtxManager; }
00119 DataDir& getDataDir() { return dataDir; }
00120 Options& getOptions() { return config; }
00121
00122 SessionManager& getSessionManager() { return sessionManager; }
00123
00124 management::ManagementObject::shared_ptr GetManagementObject (void) const;
00125 management::Manageable* GetVhostObject (void) const;
00126 management::Manageable::status_t
00127 ManagementMethod (uint32_t methodId, management::Args& args);
00128
00130 void registerProtocolFactory(boost::shared_ptr<sys::ProtocolFactory>);
00131
00133 void accept();
00134
00136 void connect(const std::string& host, uint16_t port, bool useSsl,
00137 sys::ConnectionCodec::Factory* =0,
00138 sys::ProtocolAccess* =0);
00140 void connect(const Url& url, sys::ConnectionCodec::Factory* =0);
00141
00142
00143
00144 boost::shared_ptr<sys::ProtocolFactory> getProtocolFactory() const;
00145
00146 private:
00147 boost::shared_ptr<sys::Poller> poller;
00148 Options config;
00149 std::vector< boost::shared_ptr<sys::ProtocolFactory> > protocolFactories;
00150 MessageStore* store;
00151 DataDir dataDir;
00152
00153 QueueRegistry queues;
00154 ExchangeRegistry exchanges;
00155 LinkRegistry links;
00156 ConnectionFactory factory;
00157 DtxManager dtxManager;
00158 SessionManager sessionManager;
00159 management::ManagementAgent::shared_ptr managementAgent;
00160 management::Broker::shared_ptr mgmtObject;
00161 Vhost::shared_ptr vhostObject;
00162 System::shared_ptr systemObject;
00163
00164 void declareStandardExchange(const std::string& name, const std::string& type);
00165 };
00166
00167 }}
00168
00169
00170
00171 #endif