Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET
Apache Qpid Documentation
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
qpid
console
Broker.h
Go to the documentation of this file.
1
/*
2
*
3
* Licensed to the Apache Software Foundation (ASF) under one
4
* or more contributor license agreements. See the NOTICE file
5
* distributed with this work for additional information
6
* regarding copyright ownership. The ASF licenses this file
7
* to you under the Apache License, Version 2.0 (the
8
* "License"); you may not use this file except in compliance
9
* with the License. You may obtain a copy of the License at
10
*
11
* http://www.apache.org/licenses/LICENSE-2.0
12
*
13
* Unless required by applicable law or agreed to in writing,
14
* software distributed under the License is distributed on an
15
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
* KIND, either express or implied. See the License for the
17
* specific language governing permissions and limitations
18
* under the License.
19
*
20
*/
21
#ifndef _QPID_CONSOLE_BROKER_H_
22
#define _QPID_CONSOLE_BROKER_H_
23
24
#include "
qpid/console/ConsoleImportExport.h
"
25
#include "
qpid/client/Connection.h
"
26
#include "
qpid/client/ConnectionSettings.h
"
27
#include "
qpid/client/SubscriptionManager.h
"
28
#include "
qpid/client/Session.h
"
29
#include "
qpid/client/AsyncSession.h
"
30
#include "
qpid/client/Message.h
"
31
#include "
qpid/client/MessageListener.h
"
32
#include "
qpid/sys/Thread.h
"
33
#include "
qpid/sys/Runnable.h
"
34
#include "
qpid/sys/Mutex.h
"
35
#include "
qpid/sys/Condition.h
"
36
#include "
qpid/Url.h
"
37
#include "
qpid/framing/Buffer.h
"
38
#include "
qpid/framing/Uuid.h
"
39
#include <string>
40
#include <iostream>
41
42
namespace
qpid {
43
namespace
console {
44
class
SessionManager;
45
class
Agent;
46
class
Object;
47
52
class
Broker
:
public
client::MessageListener
{
53
public
:
54
QPID_CONSOLE_EXTERN
Broker
(
SessionManager
& sm,
55
client::ConnectionSettings
& settings);
56
QPID_CONSOLE_EXTERN
~Broker
();
57
58
QPID_CONSOLE_INLINE_EXTERN
bool
isConnected
()
const
{
return
connected; }
59
QPID_CONSOLE_INLINE_EXTERN
const
std::string&
getError
()
const
{
return
error; }
60
QPID_CONSOLE_INLINE_EXTERN
const
std::string&
getSessionId
()
const
{
return
amqpSessionId; }
61
QPID_CONSOLE_INLINE_EXTERN
const
framing::Uuid
&
getBrokerId
()
const
{
return
brokerId; }
62
QPID_CONSOLE_INLINE_EXTERN
uint32_t
getBrokerBank
()
const
{
return
1; }
63
QPID_CONSOLE_INLINE_EXTERN
void
addBinding
(
const
std::string& key) {
64
connThreadBody.bindExchange(
"qpid.management"
, key);
65
}
66
QPID_CONSOLE_EXTERN
std::string
getUrl
()
const
;
67
QPID_CONSOLE_EXTERN
void
waitForStable
();
68
69
private
:
70
friend
class
SessionManager
;
71
friend
class
Object
;
72
typedef
std::map<uint64_t,Agent*> AgentMap;
73
static
const
int
SYNC_TIME = 60;
74
75
SessionManager
& sessionManager;
76
AgentMap agents;
77
bool
connected;
78
std::string
error
;
79
std::string amqpSessionId;
80
client::ConnectionSettings
connectionSettings;
81
sys::Mutex
lock;
82
sys::Condition
cond;
83
framing::Uuid
brokerId;
84
uint32_t
reqsOutstanding;
85
bool
syncInFlight;
86
bool
topicBound;
87
Object
* methodObject;
88
89
friend
class
ConnectionThread
;
90
class
ConnectionThread
:
public
sys::Runnable
{
91
bool
operational;
92
bool
shuttingDown;
93
Broker&
broker
;
94
framing::Uuid
sessionId;
95
client::Connection
connection;
96
client::Session
session;
97
client::SubscriptionManager
* subscriptions;
98
std::stringstream queueName;
99
sys::Mutex
connLock;
100
void
run();
101
public
:
102
ConnectionThread
(Broker& _broker) :
103
operational(false), shuttingDown(false),
broker
(_broker), subscriptions(0) {}
104
~
ConnectionThread
();
105
void
sendBuffer(
qpid::framing::Buffer
& buf,
106
uint32_t
length,
107
const
std::string& exchange =
"qpid.management"
,
108
const
std::string& routingKey =
"broker"
);
109
void
bindExchange(
const
std::string& exchange,
const
std::string& key);
110
void
shutdown();
111
};
112
113
ConnectionThread
connThreadBody;
114
sys::Thread
connThread;
115
116
void
encodeHeader(
framing::Buffer
& buf,
uint8_t
opcode,
uint32_t
seq = 0)
const
;
117
bool
checkHeader(
framing::Buffer
& buf,
uint8_t
*opcode,
uint32_t
*seq)
const
;
118
void
received(
client::Message
& msg);
119
void
resetAgents();
120
void
updateAgent(
const
Object
&
object
);
121
void
incOutstanding();
122
void
decOutstanding();
123
void
setBrokerId(
const
framing::Uuid
&
id
) { brokerId = id; }
124
void
appendAgents(std::vector<Agent*>& agents)
const
;
125
126
friend
std::ostream&
operator<<
(std::ostream& o,
const
Broker& k);
127
};
128
129
std::ostream&
operator<<
(std::ostream& o,
const
Broker& k);
130
}
131
}
132
133
#endif
Qpid C++ API Reference
Generated on Fri Aug 9 2013 for Qpid C++ Client API by
1.8.3.1