RMQ - RabbitMQ C++ Library
Public Types | Public Member Functions | Static Public Member Functions | List of all members
BloombergLP::rmqtestmocks::MockConnection Class Referenceabstract

Mocks rmqp::Connection and/or rmqa::Connection. More...

#include <rmqtestmocks_mockconnection.h>

Inheritance diagram for BloombergLP::rmqtestmocks::MockConnection:
Inheritance graph
[legend]
Collaboration diagram for BloombergLP::rmqtestmocks::MockConnection:
Collaboration graph
[legend]

Public Types

enum  ReturnCode { SUCCESS = 0 , FAIL }
 

Public Member Functions

bsl::shared_ptr< rmqp::Connectionconnection ()
 
rmqt::Future< rmqp::Connectionsuccess ()
 
 MOCK_METHOD0 (close, void())
 
 MOCK_METHOD3 (createProducerAsync, rmqt::Future< rmqp::Producer >(const rmqt::Topology &topology, rmqt::ExchangeHandle exchange, uint16_t maxOutstandingConfirms))
 
 MOCK_METHOD3 (createProducer, rmqt::Result< rmqp::Producer >(const rmqt::Topology &topology, rmqt::ExchangeHandle exchange, uint16_t maxOutstandingConfirms))
 
 MOCK_METHOD4 (createConsumer, rmqt::Result< rmqp::Consumer >(const rmqt::Topology &topology, rmqt::QueueHandle queue, const rmqp::Consumer::ConsumerFunc &messageConsumer, const rmqt::ConsumerConfig &config))
 
 MOCK_METHOD4 (createConsumerAsync, rmqt::Future< rmqp::Consumer >(const rmqt::Topology &topology, rmqt::QueueHandle queue, const rmqp::Consumer::ConsumerFunc &messageConsumer, const rmqt::ConsumerConfig &config))
 
 MOCK_METHOD5 (createConsumer, rmqt::Result< rmqp::Consumer >(const rmqt::Topology &topology, rmqt::QueueHandle queue, const rmqp::Consumer::ConsumerFunc &messageConsumer, const bsl::string &consumerTag, uint16_t prefetchCount))
 
 MOCK_METHOD5 (createConsumerAsync, rmqt::Future< rmqp::Consumer >(const rmqt::Topology &topology, rmqt::QueueHandle queue, const rmqp::Consumer::ConsumerFunc &messageConsumer, const bsl::string &consumerTag, uint16_t prefetchCount))
 
virtual rmqt::Result< Producer > createProducer (const rmqt::Topology &topology, rmqt::ExchangeHandle exchange, uint16_t maxOutstandingConfirms)=0
 
virtual rmqt::Result< rmqp::ConsumercreateConsumer (const rmqt::Topology &topology, rmqt::QueueHandle queue, const rmqp::Consumer::ConsumerFunc &onMessage, const rmqt::ConsumerConfig &consumerConfig)=0
 Create an asynchronous consumer using the provided Topology. More...
 
virtual rmqt::Result< rmqp::ConsumercreateConsumer (const rmqt::Topology &topology, rmqt::QueueHandle queue, const rmqp::Consumer::ConsumerFunc &messageConsumer, const bsl::string &consumerTag, uint16_t prefetchCount)
 
virtual void close ()=0
 Flush all data pending and then close the connection. Close the connection and invalidates all consumers and producers created through this connection. More...
 
virtual rmqt::Future< Producer > createProducerAsync (const rmqt::Topology &topology, rmqt::ExchangeHandle exchange, uint16_t maxOutstandingConfirms)=0
 
virtual rmqt::Future< rmqp::ConsumercreateConsumerAsync (const rmqt::Topology &topology, rmqt::QueueHandle queue, const rmqp::Consumer::ConsumerFunc &onMessage, const rmqt::ConsumerConfig &consumerConfig)=0
 
virtual rmqt::Future< rmqp::ConsumercreateConsumerAsync (const rmqt::Topology &topology, rmqt::QueueHandle queue, const rmqp::Consumer::ConsumerFunc &messageConsumer, const bsl::string &consumerTag, uint16_t prefetchCount)
 

Static Public Member Functions

static rmqt::Future< rmqp::Connectiontimeout ()
 
static rmqt::Future< rmqp::Connectionerror ()
 

Detailed Description

Mocks rmqp::Connection and/or rmqa::Connection.

Member Function Documentation

◆ close()

virtual void BloombergLP::rmqp::Connection::close ( )
pure virtualinherited

Flush all data pending and then close the connection. Close the connection and invalidates all consumers and producers created through this connection.

Implemented in BloombergLP::rmqa::ConnectionImpl, and BloombergLP::rmqa::VHostImpl.

◆ createConsumer() [1/2]

rmqt::Result< rmqp::Consumer > BloombergLP::rmqp::Connection::createConsumer ( const rmqt::Topology topology,
rmqt::QueueHandle  queue,
const rmqp::Consumer::ConsumerFunc messageConsumer,
const bsl::string &  consumerTag,
uint16_t  prefetchCount 
)
virtualinherited

Create an asynchronous consumer using the topology provided. This method also creates the topology on the target broker synchronously using the timeout provided. If the timeout expires, the converted bool value of Result object returned by this function will be false. The value of the result Result::value() will be still usable in this case though. User-defined callbacks are run on the thread-pool, as messages are received from the broker.

◆ createConsumer() [2/2]

virtual rmqt::Result< rmqp::Consumer > BloombergLP::rmqp::Connection::createConsumer ( const rmqt::Topology topology,
rmqt::QueueHandle  queue,
const rmqp::Consumer::ConsumerFunc onMessage,
const rmqt::ConsumerConfig consumerConfig 
)
pure virtualinherited

Create an asynchronous consumer using the provided Topology.

Parameters
topologyThe RabbitMQ topology which will be declared on the broker with this consumer.
queueThe queue to consume from. This queue must be contained within topology.
onMessageThe callback to be invoked on each message. This will be invoked from the RabbitContext threadpool.
consumerConfigdictates any optional tunables for the consumer, e.g. consumerTag, prefetchCount, threadpool to process the messages on
Returns
A result which will contain either the connected consumer object which has been registered on the Event Loop thread or an error.

Implemented in BloombergLP::rmqa::VHostImpl, and BloombergLP::rmqa::ConnectionImpl.

◆ createProducer()

virtual rmqt::Result< Producer > BloombergLP::rmqp::Connection::createProducer ( const rmqt::Topology topology,
rmqt::ExchangeHandle  exchange,
uint16_t  maxOutstandingConfirms 
)
pure virtualinherited

Create a producer for the given exchange using the topology provided. This method starts the process of declaring the topology, and creating the producer. The returned Future provides access to the Producer when it is ready.

Parameters
topologyThe topology declared by this producer. This topology will be re-declared on reconnection. The passed exchange must exist in the given topology
exchangeThe exchange to which all produced messages will be published
maxOutstandingConfirmsThe maximum number of confirms the Producer will allow before blocking, and waiting for a confirm from the broker

Implemented in BloombergLP::rmqa::ConnectionImpl, and BloombergLP::rmqa::VHostImpl.


The documentation for this class was generated from the following files: