RTI Connext Java API
Version 5.0.0
|
Allows sending requests and receiving replies. More...
Public Member Functions | |
Requester (RequesterParams params) | |
Creates a Requester with parameters. | |
Requester (DomainParticipant participant, String serviceName, TypeSupport requestTypeSupport, TypeSupport replyTypeSupport) | |
Creates a Requester with the minimum set of parameters. | |
void | close () |
Releases the internal entities created by this object. | |
void | sendRequest (TReq request) |
Sends a request. | |
void | sendRequest (WriteSample< TReq > request) |
Sends a request and gets back information about it that allows correlation with future replies. | |
boolean | receiveReply (Sample< TRep > reply, Duration_t maxWait) |
Waits for a reply and copies its contents into a Sample. | |
List< Sample< TRep > > | receiveReplies (List< Sample< TRep >> replies, int maxCount, Duration_t maxWait) |
Waits for multiple replies and copies them into a list. | |
List< Sample< TRep > > | receiveReplies (List< Sample< TRep >> replies, int minCount, int maxCount, Duration_t maxWait) |
Waits for multiple replies and copies them into a list. | |
Sample.Iterator< TRep > | receiveReplies (Duration_t maxWait) |
Waits for multiple replies and provides a loaned iterator to access them. | |
Sample.Iterator< TRep > | receiveReplies (int minCount, int maxCount, Duration_t maxWait) |
Waits for multiple replies and provides a loaned iterator to access them. | |
boolean | takeReply (Sample< TRep > reply) |
Copies the contents of a reply into a Sample. | |
Sample.Iterator< TRep > | takeReplies () |
Provides a loaned iterator to access the existing replies. | |
Sample.Iterator< TRep > | takeReplies (int maxCount) |
Provides a loaned iterator to access the existing replies. | |
List< Sample< TRep > > | takeReplies (List< Sample< TRep >> replies, int maxCount) |
Copies existing replies into a list. | |
boolean | takeReply (Sample< TRep > reply, SampleIdentity_t relatedRequestId) |
Copies the contents of a reply for a specific request. | |
Sample.Iterator< TRep > | takeReplies (SampleIdentity_t relatedRequestId) |
Provides a loaned iterator to access the existing replies for a specific request. | |
Sample.Iterator< TRep > | takeReplies (int maxCount, SampleIdentity_t relatedRequestId) |
Provides a loaned iterator to access the existing replies for a specific request. | |
List< Sample< TRep > > | takeReplies (List< Sample< TRep >> replies, int maxCount, SampleIdentity_t relatedRequestId) |
Copies existing replies for a specific request into a list. | |
boolean | readReply (Sample< TRep > reply) |
Copies the contents of a reply into a Sample. | |
Sample.Iterator< TRep > | readReplies () |
Provides a loaned iterator to access the existing replies. | |
Sample.Iterator< TRep > | readReplies (int maxCount) |
Provides a loaned iterator to access the existing replies. | |
List< Sample< TRep > > | readReplies (List< Sample< TRep >> replies, int maxCount) |
Copies existing replies into a list. | |
boolean | readReply (Sample< TRep > reply, SampleIdentity_t relatedRequestId) |
Copies the contents of a reply for a specific request. | |
Sample.Iterator< TRep > | readReplies (SampleIdentity_t relatedRequestId) |
Provides a loaned iterator to access the existing replies for a specific request. | |
Sample.Iterator< TRep > | readReplies (int maxCount, SampleIdentity_t relatedRequestId) |
Provides a loaned iterator to access the existing replies for a specific request. | |
List< Sample< TRep > > | readReplies (List< Sample< TRep >> replies, int maxCount, SampleIdentity_t relatedRequestId) |
Copies existing replies for a specific request into a list. | |
boolean | waitForReplies (Duration_t maxWait) |
Waits for replies to any request. | |
boolean | waitForReplies (int minCount, Duration_t maxWait) |
Waits for replies to any request. | |
boolean | waitForReplies (int minCount, Duration_t maxWait, SampleIdentity_t relatedRequestId) |
Waits for replies to a specific request. | |
DataWriter | getRequestDataWriter () |
Retrieves the underlying com.rti.dds.publication.DataWriter. | |
DataReader | getReplyDataReader () |
Retrieves the underlying com.rti.dds.subscription.DataReader. | |
WriteSample< TReq > | createRequestSample () |
Creates a WriteSample for sending requests. | |
WriteSample< TReq > | createRequestSample (TReq data) |
Creates a WriteSample for sending requests. | |
Sample< TRep > | createReplySample () |
Creates a Sample for getting replies. | |
Sample< TRep > | createReplySample (TRep data) |
Creates a Sample for getting replies. | |
Allows sending requests and receiving replies.
A requester is an entity with two associated topics: a request topic and a reply topic. It can send requests by publishing samples of the request topic and receive replies to those requests by subscribing to the reply topic.
Valid types for these topics (TReq
and TRep
) are: those generated by the rtiddsgen code generator, the DDS built-in types, and DynamicData
.
For example:
A Replier and a Requester communicate when they use the same topics for requests and replies (see com.rti.connext.requestreply.RequesterParams.setServiceName(String)) on the same domain.
A Requester can send requests and receive replies. It does that using the following operations:
In all cases, the middleware guarantees that a requester only receives reply samples that are associated with that requests that it sends.
A requester has an associated com.rti.dds.domain.DomainParticipant, which can be shared with other requesters or RTI Connext routines. All the other RTI Connext entities required for the request-reply interaction, including a com.rti.dds.publication.DataWriter for writing requests and a com.rti.dds.subscription.DataReader for reading replies, are automatically created when the requester is constructed.
Quality of Service for the underlying DataWriter and DataReader can be configured (see com.rti.connext.requestreply.RequesterParams.setQosProfile(String,String)). By default, they are created with reliable quality of service. The exact default configuration is described here: Configuring Request-Reply QoS profiles
TReq | The data type for the request topic |
TRep | The data type for the reply topic |
Requester | ( | RequesterParams | params | ) |
Creates a Requester with parameters.
params | All the parameters that configure this requester. See com.rti.connext.requestreply.RequesterParams for the list of mandatory parameters. |
One | of the Standard Return Codes |
Requester | ( | DomainParticipant | participant, |
String | serviceName, | ||
TypeSupport | requestTypeSupport, | ||
TypeSupport | replyTypeSupport | ||
) |
Creates a Requester with the minimum set of parameters.
participant | The DomainParticipant this requester uses to join a DDS domain |
serviceName | The service name. See com.rti.connext.requestreply.RequesterParams.setServiceName(String) |
requestTypeSupport | The type support for type TReq |
replyTypeSupport | The type support for type TReq |
One | of the Standard Return Codes |
void close | ( | ) |
Releases the internal entities created by this object.
Among other internal resources, it deletes the underlying DataReader and DataWriter.
void sendRequest | ( | TReq | request | ) |
Sends a request.
If a future reply needs to be correlated to exactly this request, use com.rti.connext.requestreply.Requester<TReq,TRep>.sendRequest(WriteSample<TReq>).
request | The request to be sent |
One | of the Standard Return Codes |
void sendRequest | ( | WriteSample< TReq > | request | ) |
Sends a request and gets back information about it that allows correlation with future replies.
After calling this operation, the sample contains a valid identity that can be used for correlation with future replies.
See example code in Correlating requests and replies.
request | <<inout>> Contains the request and optional write parameters. When this call ends succesfully, com.rti.connext.infrastructure.WriteSample<T> contains a valid identity that can be used for correlation with future replies. |
One | of the Standard Return Codes ; RETCODE_TIMEOUT may be reported in the same conditions as in com.rti.ndds.example.FooDataWriter.write. |
boolean receiveReply | ( | Sample< TRep > | reply, |
Duration_t | maxWait | ||
) |
Waits for a reply and copies its contents into a Sample.
This operation is equivalent to using waitForReplies(int,Duration_t) and takeReply(Sample<TRep>).
List<Sample<TRep> > receiveReplies | ( | List< Sample< TRep >> | replies, |
int | maxCount, | ||
Duration_t | maxWait | ||
) |
Waits for multiple replies and copies them into a list.
This operation is equivalent to using receiveReplies(List<Sample<TRep>>,int,int,Duration_t) with min_count = 0
List<Sample<TRep> > receiveReplies | ( | List< Sample< TRep >> | replies, |
int | minCount, | ||
int | maxCount, | ||
Duration_t | maxWait | ||
) |
Waits for multiple replies and copies them into a list.
This operation is equivalent to using waitForReplies(int,Duration_t) and takeReplies(List<Sample<TRep>>,int).
Sample.Iterator<TRep> receiveReplies | ( | Duration_t | maxWait | ) |
Waits for multiple replies and provides a loaned iterator to access them.
This operation is equivalent to using receiveReplies(int,int,Duration_t) with min_count=1
and max_count=com.rti.dds.infrastructure.ResourceLimitsQosPolicy.LENGTH_UNLIMITED
Sample.Iterator<TRep> receiveReplies | ( | int | minCount, |
int | maxCount, | ||
Duration_t | maxWait | ||
) |
Waits for multiple replies and provides a loaned iterator to access them.
This operation is equivalent to using waitForReplies(int,Duration_t) and takeReplies(int).
One | of the Standard Return Codes |
boolean takeReply | ( | Sample< TRep > | reply | ) |
Copies the contents of a reply into a Sample.
Takes a reply sample from the Requester and makes a copy.
This operation may be used after a call to waitForReplies(int,Duration_t).
To avoid copies, you can use takeReplies(int).
reply | The sample where the reply data and the related SampleInfo are copied |
reply
remain unchanged, except com.rti.dds.subscription.SampleInfo.valid_data becomes false. One | of the Standard Return Codes |
Sample.Iterator<TRep> takeReplies | ( | ) |
Provides a loaned iterator to access the existing replies.
Equivalent to using takeReplies(int) with max_count=com.rti.dds.infrastructure.ResourceLimitsQosPolicy.LENGTH_UNLIMITED
.
Sample.Iterator<TRep> takeReplies | ( | int | maxCount | ) |
Provides a loaned iterator to access the existing replies.
Takes all the existing replies up to maxCount
and provides a loaned iterator to access them.
This operation does not make a copy of the data.
The loan is returned with com.rti.connext.infrastructure.Sample<T>.Iterator<T>.close()
Since Sample.Iterator<T>
implements java.io.Closeable
, the loan is automatically returned when the iterator is enclosed in a try-with-resources
block (since Java 7)
This operation may be used after a call to waitForReplies(int,Duration_t)
See an example here: Taking loaned samples
maxCount | The maximum number of samples that are taken at a time. The special value com.rti.dds.infrastructure.ResourceLimitsQosPolicy.LENGTH_UNLIMITED may be used. This value will read up to the limit specified by com.rti.dds.infrastructure.DataReaderResourceLimitsQosPolicy.max_samples_per_read |
One | of the Standard Return Codes |
List<Sample<TRep> > takeReplies | ( | List< Sample< TRep >> | replies, |
int | maxCount | ||
) |
Copies existing replies into a list.
Takes all the existing replies up to maxCount
and copies them into a list.
If the first argument is null, a new list containing the copies is created and returned.
If a non-null list is passed as the first argument, the copies are inserted into that list. The list may already contain some elements. Any existing elements are overwritten. If the list contains less elements, samples are inserted at the end; if it contains more elements, the excess samples are removed from the end.
This operation may be used after a call to waitForReplies(int,Duration_t).
replies | The list where the samples are copied or null to create a new list. |
maxCount | The maximum number of samples that are taken at a time. The special value com.rti.dds.infrastructure.ResourceLimitsQosPolicy.LENGTH_UNLIMITED may be used. |
replies
if it's not null
. Otherwise it returns a new list. One | of the Standard Return Codes |
boolean takeReply | ( | Sample< TRep > | reply, |
SampleIdentity_t | relatedRequestId | ||
) |
Copies the contents of a reply for a specific request.
This operation is analogous to takeReply(Sample<TRep>) except the reply corresponds to a specific request.
reply | The sample where a reply is copied into |
relatedRequestId | The identity of a request previously sent by this Requester |
reply
remain unchanged, except com.rti.dds.subscription.SampleInfo.valid_data becomes false. Sample.Iterator<TRep> takeReplies | ( | SampleIdentity_t | relatedRequestId | ) |
Provides a loaned iterator to access the existing replies for a specific request.
Equivalent to using takeReplies(int,SampleIdentity_t) with max_count=com.rti.dds.infrastructure.ResourceLimitsQosPolicy.LENGTH_UNLIMITED
Sample.Iterator<TRep> takeReplies | ( | int | maxCount, |
SampleIdentity_t | relatedRequestId | ||
) |
Provides a loaned iterator to access the existing replies for a specific request.
This operation is analogous to takeReplies(int) except the replies this operation provides correspond to a specific request.
maxCount | The maximum number of samples that are taken at a time. The special value com.rti.dds.infrastructure.ResourceLimitsQosPolicy.LENGTH_UNLIMITED may be used. |
relatedRequestId | The identity of a request previously sent by this Requester |
List<Sample<TRep> > takeReplies | ( | List< Sample< TRep >> | replies, |
int | maxCount, | ||
SampleIdentity_t | relatedRequestId | ||
) |
Copies existing replies for a specific request into a list.
This operation is analogous to takeReplies(List<Sample<TRep>>,int) except the replies correspond to a specific request.
replies | The list where the samples are copied or null to create a new List. |
maxCount | The maximum number of samples that are taken at a time. The special value com.rti.dds.infrastructure.ResourceLimitsQosPolicy.LENGTH_UNLIMITED may be used. |
relatedRequestId | The identity of a request previously sent by this Requester |
replies
if it is not null
. Otherwise it returns a new List
. boolean readReply | ( | Sample< TRep > | reply | ) |
Copies the contents of a reply into a Sample.
This operation is equivalent to com.rti.connext.requestreply.Requester<TReq,TRep>.takeReply(Sample<TRep>) except the reply remains in the Requester and can be read or taken again.
Sample.Iterator<TRep> readReplies | ( | ) |
Provides a loaned iterator to access the existing replies.
This operation is equivalent to com.rti.connext.requestreply.Requester<TReq,TRep>.takeReplies() except the replies remain in the Requester and can be read or taken again.
Sample.Iterator<TRep> readReplies | ( | int | maxCount | ) |
Provides a loaned iterator to access the existing replies.
This operation is equivalent to com.rti.connext.requestreply.Requester<TReq,TRep>.takeReplies(int) except the replies remain in the Requester and can be read or taken again.
List<Sample<TRep> > readReplies | ( | List< Sample< TRep >> | replies, |
int | maxCount | ||
) |
Copies existing replies into a list.
This operation is equivalent to com.rti.connext.requestreply.Requester<TReq,TRep>.takeReplies(List<Sample<TRep>>,int) except the replies remain in the Requester and can be read or taken again.
boolean readReply | ( | Sample< TRep > | reply, |
SampleIdentity_t | relatedRequestId | ||
) |
Copies the contents of a reply for a specific request.
This operation is equivalent to com.rti.connext.requestreply.Requester<TReq,TRep>.takeReply(Sample<TRep>,SampleIdentity_t) except the reply remains in the Requester and can be read or taken again.
Sample.Iterator<TRep> readReplies | ( | SampleIdentity_t | relatedRequestId | ) |
Provides a loaned iterator to access the existing replies for a specific request.
This operation is equivalent to com.rti.connext.requestreply.Requester<TReq,TRep>.takeReplies(SampleIdentity_t) except the replies remain in the Requester and can be read or taken again.
Sample.Iterator<TRep> readReplies | ( | int | maxCount, |
SampleIdentity_t | relatedRequestId | ||
) |
Provides a loaned iterator to access the existing replies for a specific request.
This operation is equivalent to com.rti.connext.requestreply.Requester<TReq,TRep>.takeReplies(int,SampleIdentity_t) except the replies remain in the Requester and can be read or taken again.
List<Sample<TRep> > readReplies | ( | List< Sample< TRep >> | replies, |
int | maxCount, | ||
SampleIdentity_t | relatedRequestId | ||
) |
Copies existing replies for a specific request into a list.
This operation is equivalent to com.rti.connext.requestreply.Requester<TReq,TRep>.takeReplies(List<Sample<TRep>>,int,SampleIdentity_t) except the replies remain in the Requester and can be read or taken again.
boolean waitForReplies | ( | Duration_t | maxWait | ) |
Waits for replies to any request.
This operation is equivalent to using waitForReplies(int,Duration_t) with min_count=1
.
boolean waitForReplies | ( | int | minCount, |
Duration_t | maxWait | ||
) |
Waits for replies to any request.
This operation waits for minCount requests to be available for up to maxWait .
If this operation is called several times but the available replies are not taken (with takeReplies(int)), this operation may return immediately and will not wait for new replies. New replies may replace existing ones if they are not taken, depending on the com.rti.dds.infrastructure.HistoryQosPolicy used to configure this Requester.
minCount | Minimum number of replies that need to be available for this operation to unblock. |
maxWait | Maximum waiting time after which this operation unblocks, regardless of how many replies are available. |
boolean waitForReplies | ( | int | minCount, |
Duration_t | maxWait, | ||
SampleIdentity_t | relatedRequestId | ||
) |
Waits for replies to a specific request.
This operation is analogous to waitForReplies(int,Duration_t) except this operation waits for replies for a specific request.
minCount | Minimum number of replies for the related request that need to be available for this operation to unblock. |
maxWait | Maximum wait time after which this operation unblocks, regardless of how many replies are available. |
relatedRequestId | The identity of a request previously sent by this Requester |
One | of the Standard Return Codes |
DataWriter getRequestDataWriter | ( | ) |
Retrieves the underlying com.rti.dds.publication.DataWriter.
Accessing the request DataWriter may be useful for a number of advanced use cases, such as:
DataReader getReplyDataReader | ( | ) |
Retrieves the underlying com.rti.dds.subscription.DataReader.
Accessing the reply DataReader may be useful for a number of advanced use cases, such as:
WriteSample<TReq> createRequestSample | ( | ) |
Creates a WriteSample for sending requests.
TReq
initialized with default values and default write parameters. WriteSample<TReq> createRequestSample | ( | TReq | data | ) |
Creates a WriteSample for sending requests.
Sample<TRep> createReplySample | ( | ) |
Creates a Sample for getting replies.
TRep
and invalid SampleInfo. Sample<TRep> createReplySample | ( | TRep | data | ) |
Creates a Sample for getting replies.
TRep
and invalid SampleInfo.