summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/qpid/messaging/Receiver.h6
-rw-r--r--cpp/include/qpid/messaging/Sender.h7
-rw-r--r--cpp/include/qpid/messaging/Session.h7
-rw-r--r--cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp6
-rw-r--r--cpp/src/qpid/client/amqp0_10/ReceiverImpl.h1
-rw-r--r--cpp/src/qpid/client/amqp0_10/SenderImpl.cpp6
-rw-r--r--cpp/src/qpid/client/amqp0_10/SenderImpl.h1
-rw-r--r--cpp/src/qpid/client/amqp0_10/SessionImpl.cpp6
-rw-r--r--cpp/src/qpid/client/amqp0_10/SessionImpl.h6
-rw-r--r--cpp/src/qpid/messaging/Receiver.cpp2
-rw-r--r--cpp/src/qpid/messaging/ReceiverImpl.h2
-rw-r--r--cpp/src/qpid/messaging/Sender.cpp2
-rw-r--r--cpp/src/qpid/messaging/SenderImpl.h2
-rw-r--r--cpp/src/qpid/messaging/Session.cpp6
-rw-r--r--cpp/src/qpid/messaging/SessionImpl.h5
-rw-r--r--cpp/src/tests/MessagingSessionTests.cpp15
16 files changed, 73 insertions, 7 deletions
diff --git a/cpp/include/qpid/messaging/Receiver.h b/cpp/include/qpid/messaging/Receiver.h
index 2dc62b1598..51630b12a2 100644
--- a/cpp/include/qpid/messaging/Receiver.h
+++ b/cpp/include/qpid/messaging/Receiver.h
@@ -37,6 +37,7 @@ namespace messaging {
class Message;
class ReceiverImpl;
+class Session;
/**
* Interface through which messages are received.
@@ -116,6 +117,11 @@ class Receiver : public qpid::client::Handle<ReceiverImpl>
*/
QPID_CLIENT_EXTERN const std::string& getName() const;
+ /**
+ * Returns a handle to the session associated with this receiver.
+ */
+ QPID_CLIENT_EXTERN Session getSession() const;
+
private:
friend class qpid::client::PrivateImplRef<Receiver>;
};
diff --git a/cpp/include/qpid/messaging/Sender.h b/cpp/include/qpid/messaging/Sender.h
index 29af3810f4..335e61260c 100644
--- a/cpp/include/qpid/messaging/Sender.h
+++ b/cpp/include/qpid/messaging/Sender.h
@@ -37,7 +37,7 @@ namespace messaging {
class Message;
class SenderImpl;
-
+class Session;
/**
* Interface through which messages are sent.
*/
@@ -73,6 +73,11 @@ class Sender : public qpid::client::Handle<SenderImpl>
* Returns the name of this sender.
*/
QPID_CLIENT_EXTERN const std::string& getName() const;
+
+ /**
+ * Returns a handle to the session associated with this sender.
+ */
+ QPID_CLIENT_EXTERN Session getSession() const;
private:
friend class qpid::client::PrivateImplRef<Sender>;
};
diff --git a/cpp/include/qpid/messaging/Session.h b/cpp/include/qpid/messaging/Session.h
index edb6fa6331..46372cb849 100644
--- a/cpp/include/qpid/messaging/Session.h
+++ b/cpp/include/qpid/messaging/Session.h
@@ -37,6 +37,7 @@ template <class> class PrivateImplRef;
namespace messaging {
class Address;
+class Connection;
class Message;
class MessageListener;
class Sender;
@@ -133,6 +134,12 @@ class Session : public qpid::client::Handle<SessionImpl>
* if there is none for that name.
*/
QPID_CLIENT_EXTERN Receiver getReceiver(const std::string& name) const;
+ /**
+ * Returns a handle to the connection this session is associated
+ * with.
+ */
+ QPID_CLIENT_EXTERN Connection getConnection() const;
+
private:
friend class qpid::client::PrivateImplRef<Session>;
};
diff --git a/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp b/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp
index fbaff7ec04..bc5c53fde6 100644
--- a/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp
+++ b/cpp/src/qpid/client/amqp0_10/ReceiverImpl.cpp
@@ -23,6 +23,7 @@
#include "MessageSource.h"
#include "SessionImpl.h"
#include "qpid/messaging/Receiver.h"
+#include "qpid/messaging/Session.h"
namespace qpid {
namespace client {
@@ -185,6 +186,9 @@ void ReceiverImpl::setCapacityImpl(uint32_t c)
}
}
}
-
+qpid::messaging::Session ReceiverImpl::getSession() const
+{
+ return qpid::messaging::Session(&parent);
+}
}}} // namespace qpid::client::amqp0_10
diff --git a/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h b/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h
index 8033546c51..d40aac4058 100644
--- a/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h
+++ b/cpp/src/qpid/client/amqp0_10/ReceiverImpl.h
@@ -63,6 +63,7 @@ class ReceiverImpl : public qpid::messaging::ReceiverImpl
uint32_t available();
uint32_t pendingAck();
void received(qpid::messaging::Message& message);
+ qpid::messaging::Session getSession() const;
private:
SessionImpl& parent;
const std::string destination;
diff --git a/cpp/src/qpid/client/amqp0_10/SenderImpl.cpp b/cpp/src/qpid/client/amqp0_10/SenderImpl.cpp
index ef16b26b91..24aaa054d2 100644
--- a/cpp/src/qpid/client/amqp0_10/SenderImpl.cpp
+++ b/cpp/src/qpid/client/amqp0_10/SenderImpl.cpp
@@ -23,6 +23,7 @@
#include "SessionImpl.h"
#include "AddressResolution.h"
#include "OutgoingMessage.h"
+#include "qpid/messaging/Session.h"
namespace qpid {
namespace client {
@@ -134,4 +135,9 @@ const std::string& SenderImpl::getName() const
return name;
}
+qpid::messaging::Session SenderImpl::getSession() const
+{
+ return qpid::messaging::Session(&parent);
+}
+
}}} // namespace qpid::client::amqp0_10
diff --git a/cpp/src/qpid/client/amqp0_10/SenderImpl.h b/cpp/src/qpid/client/amqp0_10/SenderImpl.h
index 8140b3479a..80d9843d9e 100644
--- a/cpp/src/qpid/client/amqp0_10/SenderImpl.h
+++ b/cpp/src/qpid/client/amqp0_10/SenderImpl.h
@@ -55,6 +55,7 @@ class SenderImpl : public qpid::messaging::SenderImpl
uint32_t pending();
void init(qpid::client::AsyncSession, AddressResolution&);
const std::string& getName() const;
+ qpid::messaging::Session getSession() const;
private:
SessionImpl& parent;
diff --git a/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp b/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
index 8545347b8c..0c09f26039 100644
--- a/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
+++ b/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
@@ -28,6 +28,7 @@
#include "qpid/Exception.h"
#include "qpid/log/Statement.h"
#include "qpid/messaging/Address.h"
+#include "qpid/messaging/Connection.h"
#include "qpid/messaging/Message.h"
#include "qpid/messaging/MessageImpl.h"
#include "qpid/messaging/Sender.h"
@@ -424,4 +425,9 @@ void SessionImpl::reconnect()
connection.reconnect();
}
+qpid::messaging::Connection SessionImpl::getConnection() const
+{
+ return qpid::messaging::Connection(&connection);
+}
+
}}} // namespace qpid::client::amqp0_10
diff --git a/cpp/src/qpid/client/amqp0_10/SessionImpl.h b/cpp/src/qpid/client/amqp0_10/SessionImpl.h
index 872f66801d..30391fc0c5 100644
--- a/cpp/src/qpid/client/amqp0_10/SessionImpl.h
+++ b/cpp/src/qpid/client/amqp0_10/SessionImpl.h
@@ -32,8 +32,8 @@
namespace qpid {
namespace messaging {
-struct Address;
-struct Filter;
+class Address;
+class Connection;
class Message;
class Receiver;
class Sender;
@@ -71,6 +71,8 @@ class SessionImpl : public qpid::messaging::SessionImpl
bool nextReceiver(qpid::messaging::Receiver& receiver, qpid::sys::Duration timeout);
qpid::messaging::Receiver nextReceiver(qpid::sys::Duration timeout);
+ qpid::messaging::Connection getConnection() const;
+
bool get(ReceiverImpl& receiver, qpid::messaging::Message& message, qpid::sys::Duration timeout);
void receiverCancelled(const std::string& name);
diff --git a/cpp/src/qpid/messaging/Receiver.cpp b/cpp/src/qpid/messaging/Receiver.cpp
index 17bad6baed..bf9c056db8 100644
--- a/cpp/src/qpid/messaging/Receiver.cpp
+++ b/cpp/src/qpid/messaging/Receiver.cpp
@@ -21,6 +21,7 @@
#include "qpid/messaging/Receiver.h"
#include "qpid/messaging/Message.h"
#include "qpid/messaging/ReceiverImpl.h"
+#include "qpid/messaging/Session.h"
#include "qpid/client/PrivateImplRef.h"
namespace qpid {
@@ -48,4 +49,5 @@ uint32_t Receiver::available() { return impl->available(); }
uint32_t Receiver::pendingAck() { return impl->pendingAck(); }
void Receiver::cancel() { impl->cancel(); }
const std::string& Receiver::getName() const { return impl->getName(); }
+Session Receiver::getSession() const { return impl->getSession(); }
}} // namespace qpid::messaging
diff --git a/cpp/src/qpid/messaging/ReceiverImpl.h b/cpp/src/qpid/messaging/ReceiverImpl.h
index 3d60437aba..447a505518 100644
--- a/cpp/src/qpid/messaging/ReceiverImpl.h
+++ b/cpp/src/qpid/messaging/ReceiverImpl.h
@@ -32,6 +32,7 @@ namespace messaging {
class Message;
class MessageListener;
+class Session;
class ReceiverImpl : public virtual qpid::RefCounted
{
@@ -47,6 +48,7 @@ class ReceiverImpl : public virtual qpid::RefCounted
virtual uint32_t pendingAck() = 0;
virtual void cancel() = 0;
virtual const std::string& getName() const = 0;
+ virtual Session getSession() const = 0;
};
}} // namespace qpid::messaging
diff --git a/cpp/src/qpid/messaging/Sender.cpp b/cpp/src/qpid/messaging/Sender.cpp
index 6087af3514..f2303f4126 100644
--- a/cpp/src/qpid/messaging/Sender.cpp
+++ b/cpp/src/qpid/messaging/Sender.cpp
@@ -21,6 +21,7 @@
#include "qpid/messaging/Sender.h"
#include "qpid/messaging/Message.h"
#include "qpid/messaging/SenderImpl.h"
+#include "qpid/messaging/Session.h"
#include "qpid/client/PrivateImplRef.h"
namespace qpid {
@@ -44,5 +45,6 @@ void Sender::setCapacity(uint32_t c) { impl->setCapacity(c); }
uint32_t Sender::getCapacity() { return impl->getCapacity(); }
uint32_t Sender::pending() { return impl->pending(); }
const std::string& Sender::getName() const { return impl->getName(); }
+Session Sender::getSession() const { return impl->getSession(); }
}} // namespace qpid::messaging
diff --git a/cpp/src/qpid/messaging/SenderImpl.h b/cpp/src/qpid/messaging/SenderImpl.h
index 058ecf96f8..5f30417f6a 100644
--- a/cpp/src/qpid/messaging/SenderImpl.h
+++ b/cpp/src/qpid/messaging/SenderImpl.h
@@ -30,6 +30,7 @@ namespace client {
namespace messaging {
class Message;
+class Session;
class SenderImpl : public virtual qpid::RefCounted
{
@@ -41,6 +42,7 @@ class SenderImpl : public virtual qpid::RefCounted
virtual uint32_t getCapacity() = 0;
virtual uint32_t pending() = 0;
virtual const std::string& getName() const = 0;
+ virtual Session getSession() const = 0;
private:
};
}} // namespace qpid::messaging
diff --git a/cpp/src/qpid/messaging/Session.cpp b/cpp/src/qpid/messaging/Session.cpp
index 5c702051d7..99896caad4 100644
--- a/cpp/src/qpid/messaging/Session.cpp
+++ b/cpp/src/qpid/messaging/Session.cpp
@@ -20,6 +20,7 @@
*/
#include "qpid/messaging/Session.h"
#include "qpid/messaging/Address.h"
+#include "qpid/messaging/Connection.h"
#include "qpid/messaging/Message.h"
#include "qpid/messaging/Sender.h"
#include "qpid/messaging/Receiver.h"
@@ -98,6 +99,11 @@ Receiver Session::getReceiver(const std::string& name) const
return impl->getReceiver(name);
}
+Connection Session::getConnection() const
+{
+ return impl->getConnection();
+}
+
KeyError::KeyError(const std::string& msg) : Exception(msg) {}
}} // namespace qpid::messaging
diff --git a/cpp/src/qpid/messaging/SessionImpl.h b/cpp/src/qpid/messaging/SessionImpl.h
index c4139a27ea..164a6f6bc9 100644
--- a/cpp/src/qpid/messaging/SessionImpl.h
+++ b/cpp/src/qpid/messaging/SessionImpl.h
@@ -31,8 +31,8 @@ namespace client {
namespace messaging {
-struct Address;
-struct Filter;
+class Address;
+class Connection;
class Message;
class Sender;
class Receiver;
@@ -56,6 +56,7 @@ class SessionImpl : public virtual qpid::RefCounted
virtual uint32_t pendingAck() = 0;
virtual Sender getSender(const std::string& name) const = 0;
virtual Receiver getReceiver(const std::string& name) const = 0;
+ virtual Connection getConnection() const = 0;
private:
};
}} // namespace qpid::messaging
diff --git a/cpp/src/tests/MessagingSessionTests.cpp b/cpp/src/tests/MessagingSessionTests.cpp
index 082c639636..09440cc183 100644
--- a/cpp/src/tests/MessagingSessionTests.cpp
+++ b/cpp/src/tests/MessagingSessionTests.cpp
@@ -718,7 +718,7 @@ QPID_AUTO_TEST_CASE(testGetReceiver)
BOOST_CHECK_THROW(fix.session.getReceiver("UnknownReceiver"), qpid::messaging::KeyError);
}
-QPID_AUTO_TEST_CASE(testGetSession)
+QPID_AUTO_TEST_CASE(testGetSessionFromConnection)
{
QueueFixture fix;
fix.connection.newSession("my-session");
@@ -731,6 +731,19 @@ QPID_AUTO_TEST_CASE(testGetSession)
BOOST_CHECK_THROW(fix.connection.getSession("UnknownSession"), qpid::messaging::KeyError);
}
+QPID_AUTO_TEST_CASE(testGetConnectionFromSession)
+{
+ QueueFixture fix;
+ Message out(Uuid(true).str());
+ Sender sender = fix.session.createSender(fix.queue);
+ sender.send(out);
+ Message in;
+ sender.getSession().getConnection().newSession("incoming");
+ BOOST_CHECK(fix.connection.getSession("incoming").createReceiver(fix.queue).fetch(in));
+ BOOST_CHECK_EQUAL(out.getContent(), in.getContent());
+}
+
+
QPID_AUTO_TEST_SUITE_END()
}} // namespace qpid::tests