diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/client/amqp0_10/SenderImpl.cpp | 3 | ||||
-rw-r--r-- | cpp/src/qpid/client/amqp0_10/SenderImpl.h | 2 | ||||
-rw-r--r-- | cpp/src/qpid/client/amqp0_10/SessionImpl.cpp | 3 | ||||
-rw-r--r-- | cpp/src/qpid/client/amqp0_10/SessionImpl.h | 2 | ||||
-rw-r--r-- | cpp/src/qpid/messaging/Sender.cpp | 2 | ||||
-rw-r--r-- | cpp/src/qpid/messaging/SenderImpl.h | 2 | ||||
-rw-r--r-- | cpp/src/qpid/messaging/Session.cpp | 2 | ||||
-rw-r--r-- | cpp/src/qpid/messaging/SessionImpl.h | 2 | ||||
-rw-r--r-- | cpp/src/tests/MessagingSessionTests.cpp | 12 |
9 files changed, 22 insertions, 8 deletions
diff --git a/cpp/src/qpid/client/amqp0_10/SenderImpl.cpp b/cpp/src/qpid/client/amqp0_10/SenderImpl.cpp index 9bb785e13f..e8c106976f 100644 --- a/cpp/src/qpid/client/amqp0_10/SenderImpl.cpp +++ b/cpp/src/qpid/client/amqp0_10/SenderImpl.cpp @@ -34,7 +34,7 @@ SenderImpl::SenderImpl(SessionImpl& _parent, const std::string& _name, parent(&_parent), name(_name), address(_address), state(UNRESOLVED), capacity(50), window(0), flushed(false), unreliable(AddressResolution::is_unreliable(address)) {} -void SenderImpl::send(const qpid::messaging::Message& message) +void SenderImpl::send(const qpid::messaging::Message& message, bool sync) { if (unreliable) { UnreliableSend f(*this, &message); @@ -43,6 +43,7 @@ void SenderImpl::send(const qpid::messaging::Message& message) Send f(*this, &message); while (f.repeat) parent->execute(f); } + if (sync) parent->sync(); } void SenderImpl::close() diff --git a/cpp/src/qpid/client/amqp0_10/SenderImpl.h b/cpp/src/qpid/client/amqp0_10/SenderImpl.h index a99d4bd294..7ea68fd187 100644 --- a/cpp/src/qpid/client/amqp0_10/SenderImpl.h +++ b/cpp/src/qpid/client/amqp0_10/SenderImpl.h @@ -48,7 +48,7 @@ class SenderImpl : public qpid::messaging::SenderImpl SenderImpl(SessionImpl& parent, const std::string& name, const qpid::messaging::Address& address); - void send(const qpid::messaging::Message&); + void send(const qpid::messaging::Message&, bool sync); void close(); void setCapacity(uint32_t); uint32_t getCapacity(); diff --git a/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp b/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp index 209ab93909..bb0a735fde 100644 --- a/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp +++ b/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp @@ -75,13 +75,14 @@ void SessionImpl::rollback() execute<Rollback>(); } -void SessionImpl::acknowledge() +void SessionImpl::acknowledge(bool sync_) { //Should probably throw an exception on failure here, or indicate //it through a return type at least. Failure means that the //message may be redelivered; i.e. the application cannot delete //any state necessary for preventing reprocessing of the message execute<Acknowledge>(); + if (sync_) sync(); } void SessionImpl::reject(qpid::messaging::Message& m) diff --git a/cpp/src/qpid/client/amqp0_10/SessionImpl.h b/cpp/src/qpid/client/amqp0_10/SessionImpl.h index a616db6239..ab29d2c1e1 100644 --- a/cpp/src/qpid/client/amqp0_10/SessionImpl.h +++ b/cpp/src/qpid/client/amqp0_10/SessionImpl.h @@ -58,7 +58,7 @@ class SessionImpl : public qpid::messaging::SessionImpl SessionImpl(ConnectionImpl&, bool transactional); void commit(); void rollback(); - void acknowledge(); + void acknowledge(bool sync); void reject(qpid::messaging::Message&); void close(); void sync(); diff --git a/cpp/src/qpid/messaging/Sender.cpp b/cpp/src/qpid/messaging/Sender.cpp index 2d5cfbcec5..b4c247d1d9 100644 --- a/cpp/src/qpid/messaging/Sender.cpp +++ b/cpp/src/qpid/messaging/Sender.cpp @@ -32,7 +32,7 @@ Sender::Sender(SenderImpl* impl) { PI::ctor(*this, impl); } Sender::Sender(const Sender& s) : qpid::messaging::Handle<SenderImpl>() { PI::copy(*this, s); } Sender::~Sender() { PI::dtor(*this); } Sender& Sender::operator=(const Sender& s) { return PI::assign(*this, s); } -void Sender::send(const Message& message) { impl->send(message); } +void Sender::send(const Message& message, bool sync) { impl->send(message, sync); } void Sender::close() { impl->close(); } void Sender::setCapacity(uint32_t c) { impl->setCapacity(c); } uint32_t Sender::getCapacity() { return impl->getCapacity(); } diff --git a/cpp/src/qpid/messaging/SenderImpl.h b/cpp/src/qpid/messaging/SenderImpl.h index 7653049c26..66651a16dc 100644 --- a/cpp/src/qpid/messaging/SenderImpl.h +++ b/cpp/src/qpid/messaging/SenderImpl.h @@ -33,7 +33,7 @@ class SenderImpl : public virtual qpid::RefCounted { public: virtual ~SenderImpl() {} - virtual void send(const Message& message) = 0; + virtual void send(const Message& message, bool sync) = 0; virtual void close() = 0; virtual void setCapacity(uint32_t) = 0; virtual uint32_t getCapacity() = 0; diff --git a/cpp/src/qpid/messaging/Session.cpp b/cpp/src/qpid/messaging/Session.cpp index 4d1e633a86..2c09bdf7a6 100644 --- a/cpp/src/qpid/messaging/Session.cpp +++ b/cpp/src/qpid/messaging/Session.cpp @@ -38,7 +38,7 @@ Session::~Session() { PI::dtor(*this); } Session& Session::operator=(const Session& s) { return PI::assign(*this, s); } void Session::commit() { impl->commit(); } void Session::rollback() { impl->rollback(); } -void Session::acknowledge() { impl->acknowledge(); } +void Session::acknowledge(bool sync) { impl->acknowledge(sync); } void Session::reject(Message& m) { impl->reject(m); } void Session::close() { impl->close(); } diff --git a/cpp/src/qpid/messaging/SessionImpl.h b/cpp/src/qpid/messaging/SessionImpl.h index 79f0d007b5..711acc324c 100644 --- a/cpp/src/qpid/messaging/SessionImpl.h +++ b/cpp/src/qpid/messaging/SessionImpl.h @@ -40,7 +40,7 @@ class SessionImpl : public virtual qpid::RefCounted virtual ~SessionImpl() {} virtual void commit() = 0; virtual void rollback() = 0; - virtual void acknowledge() = 0; + virtual void acknowledge(bool sync) = 0; virtual void reject(Message&) = 0; virtual void close() = 0; virtual void sync() = 0; diff --git a/cpp/src/tests/MessagingSessionTests.cpp b/cpp/src/tests/MessagingSessionTests.cpp index bdfb8b389c..e1c0a6bb16 100644 --- a/cpp/src/tests/MessagingSessionTests.cpp +++ b/cpp/src/tests/MessagingSessionTests.cpp @@ -231,6 +231,18 @@ QPID_AUTO_TEST_CASE(testSimpleSendReceive) BOOST_CHECK_EQUAL(in.getContent(), out.getContent()); } +QPID_AUTO_TEST_CASE(testSyncSendReceive) +{ + QueueFixture fix; + Sender sender = fix.session.createSender(fix.queue); + Message out("test-message"); + sender.send(out, true); + Receiver receiver = fix.session.createReceiver(fix.queue); + Message in = receiver.fetch(Duration::IMMEDIATE); + fix.session.acknowledge(true); + BOOST_CHECK_EQUAL(in.getContent(), out.getContent()); +} + QPID_AUTO_TEST_CASE(testSendReceiveHeaders) { QueueFixture fix; |