RTI Connext Modern C++ API Version 7.3.0
rti::queuing::QueueReplier< TReq, TRep > Class Template Reference

Allows receiving requests and sending replies. More...

#include <rti/queuing/QueueReplier.hpp>

Inheritance diagram for rti::queuing::QueueReplier< TReq, TRep >:
dds::core::Reference< detail::QueueReplierImpl< TReq, TRep > >

Public Member Functions

 QueueReplier (const QueueReplierParams &params, bool is_enabled=true, Listener *replier_listener=NULL, const rti::core::Guid &replier_guid=rti::core::Guid::unknown())
 Creates a queue replier. More...
 
 QueueReplier (const QueueReplierParams &params, bool is_enabled, std::shared_ptr< Listener > replier_listener, const rti::core::Guid &replier_guid=rti::core::Guid::unknown())
 Creates a Replier with parameters. More...
 
void listener (Listener *the_listener, const dds::core::status::StatusMask &event_mask=dds::core::status::StatusMask::none())
 Sets the listener associated with this queue requester. More...
 
Listenerlistener () const
 Returns the listener currently associated with this requester. More...
 
std::shared_ptr< Listenerget_listener () const
 Gets the listener. More...
 
void set_listener (std::shared_ptr< Listener > the_listener)
 Sets a listener to be notified of status updates. More...
 
void enable ()
 Enables the QueueReplier to send data, receive data and receive listener notifications. More...
 
void send_reply (const TRep &reply, const dds::sub::SampleInfo &related_request_info)
 Sends a reply for a previous request. More...
 
void send_reply (const TRep &reply, rti::pub::WriteParams &write_params)
 Sends a reply with the specified parameters and gets back metadata information related to the reply sent. More...
 
void acknowledge_request (const dds::sub::SampleInfo &sample_info, bool is_positive_acknowledgment=true)
 Explicitly acknowledges a single request. More...
 
void acknowledge_all (bool is_positive_acknowledgment=true)
 Acknowledges all previously accessed requests. More...
 
bool wait_for_acknowledgments (const dds::core::Duration &max_wait)
 Blocks the calling thread until all replies written by this QueueReplier are acknowledged by Queuing Service, or until a timeout occurs. More...
 
bool wait_for_acknowledgments (const rti::core::SampleIdentity &identity, const dds::core::Duration &max_wait)
 Blocks the calling thread until the reply identified by identity is acknowledged by Queuing Service, or until a timeout occurs. More...
 
rti::queuing::QueueConsumer< TReq > consumer () const
 Retrieves the underlying dds::sub::DataReader. More...
 
rti::queuing::QueueProducer< TRep > producer () const
 Retrieves the underlying dds::pub::DataWriter. More...
 
void send_availability (ConsumerAvailabilityParams parameters)
 Sends an availability sample with the specified parameters. The availability applies to the reply queue. More...
 
bool has_matching_request_reader_queue ()
 Checks whether or not this QueueReplier has matched with at least one request SharedReaderQueue. More...
 
bool has_matching_reply_reader_queue ()
 Checks whether or not this QueueReplier has matched with at least one reply SharedReaderQueue. More...
 
bool wait_for_requests (const dds::core::Duration &max_wait)
 Waits for requests. More...
 
bool wait_for_requests (int min_count, const dds::core::Duration &max_wait)
 Waits for requests. More...
 
dds::sub::LoanedSamples< TReq > receive_requests (const dds::core::Duration &max_wait)
 Waits for multiple requests and provides a loaned container to access them. More...
 
dds::sub::LoanedSamples< TReq > receive_requests (int min_count, int max_count, const dds::core::Duration &max_wait)
 Waits for multiple requests and provides a loaned container to access them. More...
 
rti::pub::WriteParams get_write_params_for_related_request (rti::pub::WriteParams &write_params, const dds::sub::SampleInfo &related_request_info)
 Gets the write parameters ready to send a reply for a given related request. More...
 
dds::sub::LoanedSamples< TReq > take_requests ()
 Provides a loaned container to access the existing requests. More...
 
dds::sub::LoanedSamples< TReq > take_requests (int max_count)
 Provides a loaned container to access the existing requests. More...
 
dds::sub::LoanedSamples< TReq > read_requests ()
 Provides a loaned container from which you can access the existing requests. More...
 
dds::sub::LoanedSamples< TReq > read_requests (int max_count)
 Provides a loaned container from which you can access the existing requests. More...
 
dds::pub::DataWriter< TRep > writer () const
 Retrieves the underlying dds::pub::DataWriter used to send replies. More...
 
dds::sub::DataReader< TReq > reader () const
 Retrieves the underlying dds::sub::DataReader used to receive requests. More...
 
rti::core::Guid guid ()
 Returns the GUID of this QueueReplier. More...
 

Detailed Description

template<typename TReq, typename TRep>
class rti::queuing::QueueReplier< TReq, TRep >

Allows receiving requests and sending replies.

A QueueReplier is a component suited for the queuing request-reply use case. A QueueReplier plays the role of a request QueueConsumer and reply QueueProducer.

A QueueReplier is an entity that allows you to receive requests from a request SharedReaderQueue and send replies to a reply SharedReaderQueue, which are hosted by Queuing Service.

To communicate with the SharedReaderQueues, the QueueReplier creates two topics. The first topic corresponds to the request SharedReaderQueue topic and the second topic to the reply SharedReaderQueue topic.

Valid types for these topics (TReq and TRep) are: those generated by rtiddsgen, the DDS built-in types, and dds::core::xtypes::DynamicData.

See also
QueueConsumer
QueueProducer
Template Parameters
TReqThe data type for the request SharedReaderQueue topic
TRepThe data type for the reply SharedReaderQueue topic

Constructor & Destructor Documentation

◆ QueueReplier() [1/2]

template<typename TReq , typename TRep >
rti::queuing::QueueReplier< TReq, TRep >::QueueReplier ( const QueueReplierParams params,
bool  is_enabled = true,
Listener replier_listener = NULL,
const rti::core::Guid replier_guid = rti::core::Guid::unknown() 
)
inlineexplicit

Creates a queue replier.

[DEPRECATED] When using a listener, prefer the constructor that receives a shared_ptr<Listener> instead of a regular Listener* pointer.

◆ QueueReplier() [2/2]

template<typename TReq , typename TRep >
rti::queuing::QueueReplier< TReq, TRep >::QueueReplier ( const QueueReplierParams params,
bool  is_enabled,
std::shared_ptr< Listener replier_listener,
const rti::core::Guid replier_guid = rti::core::Guid::unknown() 
)
inlineexplicit

Creates a Replier with parameters.

Parameters
paramsAll the parameters that configure this QueueReplier See QueueReplierParams for the list of required parameters.
is_enabledSpecifies if the QueueReplier is created ready to receive notifications in its listener and send or receive data. If you choose to bind the QueueReplier to a QueueReplierListener using an rti::core::ListenerBinder you should create the QueueReplier disabled to avoid missing listener notifications. You can later enable the disabled QueueReplier using QueueReplier::enable.
replier_listenerA shared_ptr to a QueueReplierListener object to receive event notifications.
replier_guidA GUID identifier for the replier. When replier_guid is set to rti::core::Guid::unknown() the Guid identifier is generated automatically. You can retrieve the generated QueueReplier Guid using the QueueReplier::guid() method. To restart a QueueReplier just create a new one with its same GUID.
Exceptions
Oneof the Standard Exceptions
See also
QueueReplierParams

Member Function Documentation

◆ listener() [1/2]

template<typename TReq , typename TRep >
void rti::queuing::QueueReplier< TReq, TRep >::listener ( Listener the_listener,
const dds::core::status::StatusMask event_mask = dds::core::status::StatusMask::none() 
)
inline

Sets the listener associated with this queue requester.

[DEPRECATED] The use of set_listener() is recommended. Unlike this function, set_listener receives a shared_ptr which simplifies the management of listener's lifecycle.

Parameters
the_listenerThe QueueReplierListener to set
event_maskThe dds::core::status::StatusMask associated with the listener

◆ listener() [2/2]

template<typename TReq , typename TRep >
Listener * rti::queuing::QueueReplier< TReq, TRep >::listener ( ) const
inline

Returns the listener currently associated with this requester.

[DEPRECATED] Prefer get_listener() instead of this function.

If there is no listener it returns NULL.

◆ get_listener()

template<typename TReq , typename TRep >
std::shared_ptr< Listener > rti::queuing::QueueReplier< TReq, TRep >::get_listener ( ) const
inline

Gets the listener.

◆ set_listener()

template<typename TReq , typename TRep >
void rti::queuing::QueueReplier< TReq, TRep >::set_listener ( std::shared_ptr< Listener the_listener)
inline

Sets a listener to be notified of status updates.

Warning
It's recommended that the listener implementation doesn't hold a permanent reference to this object. If it does, the application needs to manually reset the listener or manually close this object to ensure that there is no cycle that prevents the destruction of these two objects.
Parameters
the_listenerA shared pointer to the listener to receive updates or nullptr to reset the current listener and stop receiving updates.

◆ enable()

template<typename TReq , typename TRep >
void rti::queuing::QueueReplier< TReq, TRep >::enable ( )
inline

Enables the QueueReplier to send data, receive data and receive listener notifications.

If you create the QueueReplier disabled you can enable it using this mehtod. To avoid missing listener notifciation when you use an rti::core::ListenerBinder to bind the QueueReplier to a QueueReplierListener use QueueReplier::enable to enable the QueueReplier after it is bound to the listener.

◆ send_reply() [1/2]

template<typename TReq , typename TRep >
void rti::queuing::QueueReplier< TReq, TRep >::send_reply ( const TRep &  reply,
const dds::sub::SampleInfo related_request_info 
)
inline

Sends a reply for a previous request.

The related request identity can be retrieved from an existing request sample (Sample).

Parameters
replyThe reply to be sent
related_request_infoThe identity of a previously received request
Exceptions
Oneof the Standard Exceptions
See also
QueueProducer::send_sample(const T&)

◆ send_reply() [2/2]

template<typename TReq , typename TRep >
void rti::queuing::QueueReplier< TReq, TRep >::send_reply ( const TRep &  reply,
rti::pub::WriteParams write_params 
)
inline

Sends a reply with the specified parameters and gets back metadata information related to the reply sent.

After calling this operation, write_params contains metadata information associated with the reply sent.

Contrary to the QueueRequester, where retrieving the sample identity for correlation is common, on the QueueReplier side using a write_params is only necessary when the default write parameters need to be overridden, and QueueReplier::send_reply(const TRep&, const dds::sub::SampleInfo&) may be used if that is not necessary.

Parameters
reply<<in>> the reply sample to send.
write_params<<inout>> Parameters used to send the reply. When this call ends successfully, write_params contains valid metadata information associated with the reply sent.
Exceptions
Oneof the Standard Exceptions or NoMatchingQueueException if by the time this operation is called there is not a single matching SharedReaderQueue.
MT Safety:
SAFE
See also
QueueReplier::send_reply(const TRep&, const dds::sub::SampleInfo&)
QueueProducer::send_sample(const T&, rti::pub::WriteParams&)
QueueRequester::wait_for_replies(int, const dds::core::Duration&, const rti::core::SampleIdentity&)
QueueReplier::take_requests(int)

◆ acknowledge_request()

template<typename TReq , typename TRep >
void rti::queuing::QueueReplier< TReq, TRep >::acknowledge_request ( const dds::sub::SampleInfo sample_info,
bool  is_positive_acknowledgment = true 
)
inline

◆ acknowledge_all()

template<typename TReq , typename TRep >
void rti::queuing::QueueReplier< TReq, TRep >::acknowledge_all ( bool  is_positive_acknowledgment = true)
inline

◆ wait_for_acknowledgments() [1/2]

template<typename TReq , typename TRep >
bool rti::queuing::QueueReplier< TReq, TRep >::wait_for_acknowledgments ( const dds::core::Duration max_wait)
inline

Blocks the calling thread until all replies written by this QueueReplier are acknowledged by Queuing Service, or until a timeout occurs.

See also
QueueProducer::wait_for_acknowledgments(const dds::core::Duration&)
QueueReplier::send_reply(const TRep&, const dds::sub::SampleInfo&)
QueueReplierListener::on_reply_acknowledged

◆ wait_for_acknowledgments() [2/2]

template<typename TReq , typename TRep >
bool rti::queuing::QueueReplier< TReq, TRep >::wait_for_acknowledgments ( const rti::core::SampleIdentity identity,
const dds::core::Duration max_wait 
)
inline

Blocks the calling thread until the reply identified by identity is acknowledged by Queuing Service, or until a timeout occurs.

See also
QueueProducer::wait_for_acknowledgments(const rti::core::SampleIdentity&, const dds::core::Duration&)
QueueReplier::send_reply(const TRep&, const dds::sub::SampleInfo&)
QueueReplierListener::on_reply_acknowledged

◆ consumer()

template<typename TReq , typename TRep >
rti::queuing::QueueConsumer< TReq > rti::queuing::QueueReplier< TReq, TRep >::consumer ( ) const
inline

Retrieves the underlying dds::sub::DataReader.

◆ producer()

template<typename TReq , typename TRep >
rti::queuing::QueueProducer< TRep > rti::queuing::QueueReplier< TReq, TRep >::producer ( ) const
inline

Retrieves the underlying dds::pub::DataWriter.

◆ send_availability()

template<typename TReq , typename TRep >
void rti::queuing::QueueReplier< TReq, TRep >::send_availability ( ConsumerAvailabilityParams  parameters)
inline

Sends an availability sample with the specified parameters. The availability applies to the reply queue.

See also
QueueConsumer::send_availability(ConsumerAvailabilityParams)
QueueReplierParams::enable_availability

◆ has_matching_request_reader_queue()

template<typename TReq , typename TRep >
bool rti::queuing::QueueReplier< TReq, TRep >::has_matching_request_reader_queue ( )
inline

Checks whether or not this QueueReplier has matched with at least one request SharedReaderQueue.

See also
QueueProducer::has_matching_reader_queue()

◆ has_matching_reply_reader_queue()

template<typename TReq , typename TRep >
bool rti::queuing::QueueReplier< TReq, TRep >::has_matching_reply_reader_queue ( )
inline

Checks whether or not this QueueReplier has matched with at least one reply SharedReaderQueue.

See also
QueueConsumer::has_matching_reader_queue()

◆ wait_for_requests() [1/2]

template<typename TReq , typename TRep >
bool rti::queuing::QueueReplier< TReq, TRep >::wait_for_requests ( const dds::core::Duration max_wait)
inline

◆ wait_for_requests() [2/2]

template<typename TReq , typename TRep >
bool rti::queuing::QueueReplier< TReq, TRep >::wait_for_requests ( int  min_count,
const dds::core::Duration max_wait 
)
inline

◆ receive_requests() [1/2]

template<typename TReq , typename TRep >
dds::sub::LoanedSamples< TReq > rti::queuing::QueueReplier< TReq, TRep >::receive_requests ( const dds::core::Duration max_wait)
inline

◆ receive_requests() [2/2]

template<typename TReq , typename TRep >
dds::sub::LoanedSamples< TReq > rti::queuing::QueueReplier< TReq, TRep >::receive_requests ( int  min_count,
int  max_count,
const dds::core::Duration max_wait 
)
inline

◆ get_write_params_for_related_request()

template<typename TReq , typename TRep >
rti::pub::WriteParams rti::queuing::QueueReplier< TReq, TRep >::get_write_params_for_related_request ( rti::pub::WriteParams write_params,
const dds::sub::SampleInfo related_request_info 
)
inline

Gets the write parameters ready to send a reply for a given related request.

You can use this method to modify the parameters before you send a reply using QueueReplier::send_reply(const TRep&, rti::pub::WriteParams&).

Parameters
write_params<<out>> the write params to send the reply.
related_request_info<<in>> The sample info of the releated request.
MT Safety:
SAFE
See also
QueueReplier::send_reply(const TRep&, rti::pub::WriteParams&)

◆ take_requests() [1/2]

template<typename TReq , typename TRep >
dds::sub::LoanedSamples< TReq > rti::queuing::QueueReplier< TReq, TRep >::take_requests ( )
inline

Provides a loaned container to access the existing requests.

See also
QueueConsumer::take_samples()

◆ take_requests() [2/2]

template<typename TReq , typename TRep >
dds::sub::LoanedSamples< TReq > rti::queuing::QueueReplier< TReq, TRep >::take_requests ( int  max_count)
inline

Provides a loaned container to access the existing requests.

See also
QueueConsumer::take_samples(int)

◆ read_requests() [1/2]

template<typename TReq , typename TRep >
dds::sub::LoanedSamples< TReq > rti::queuing::QueueReplier< TReq, TRep >::read_requests ( )
inline

Provides a loaned container from which you can access the existing requests.

This operation is equivalent to QueueReplier::take_requests(), except the sample remains in the QueueReplier and can be read or taken again.

◆ read_requests() [2/2]

template<typename TReq , typename TRep >
dds::sub::LoanedSamples< TReq > rti::queuing::QueueReplier< TReq, TRep >::read_requests ( int  max_count)
inline

Provides a loaned container from which you can access the existing requests.

This operation is equivalent to QueueReplier::take_requests(int), except the sample remains in the QueueReplier and can be read or taken again.

◆ writer()

template<typename TReq , typename TRep >
dds::pub::DataWriter< TRep > rti::queuing::QueueReplier< TReq, TRep >::writer ( ) const
inline

Retrieves the underlying dds::pub::DataWriter used to send replies.

See also
QueueProducer::writer()

◆ reader()

template<typename TReq , typename TRep >
dds::sub::DataReader< TReq > rti::queuing::QueueReplier< TReq, TRep >::reader ( ) const
inline

Retrieves the underlying dds::sub::DataReader used to receive requests.

See also
QueueConsumer::reader

◆ guid()

template<typename TReq , typename TRep >
rti::core::Guid rti::queuing::QueueReplier< TReq, TRep >::guid ( )
inline

Returns the GUID of this QueueReplier.

The QueueReplier's GUID is the same GUID of both underlying QueueProducer and QueueConsumer.

See also
QueueReplierParams::entity_name
QueueProducer::guid
QueueConsumer::guid