RTI Connext Java API
Version 6.1.0
|
Allows receiving requests and sending replies. More...
Public Member Functions | |
Replier (ReplierParams< TReq, TRep > params) | |
Creates a Replier with parameters. More... | |
Replier (DomainParticipant participant, String serviceName, TypeSupport requestTypeSupport, TypeSupport replyTypeSupport) | |
Creates a Replier with the minimum set of parameters. More... | |
void | close () |
Releases the internal entities created by this Replier. More... | |
void | sendReply (TRep reply, SampleIdentity_t relatedRequestId) |
Sends a reply for a previous request. More... | |
void | sendReply (WriteSample< TRep > reply, SampleIdentity_t relatedRequestId) |
Sends a reply for a previous request. More... | |
boolean | receiveRequest (Sample< TReq > request, Duration_t maxWait) |
Waits for a request and copies its contents into a Sample. More... | |
List< Sample< TReq > > | receiveRequests (List< Sample< TReq >> replies, int maxCount, Duration_t maxWait) |
Waits for multiple requests and copies them into a list. More... | |
List< Sample< TReq > > | receiveRequests (List< Sample< TReq >> replies, int minCount, int maxCount, Duration_t maxWait) |
Waits for multiple requests and copies them into a list. More... | |
Sample.Iterator< TReq > | receiveRequests (Duration_t maxWait) |
Waits for multiple requests and provides a loaned iterator to access them. More... | |
Sample.Iterator< TReq > | receiveRequests (int minCount, int maxCount, Duration_t maxWait) |
Waits for multiple requests and provides a loaned iterator to access them. More... | |
boolean | takeRequest (Sample< TReq > request) |
Copies the contents of a request into a Sample. More... | |
Sample.Iterator< TReq > | takeRequests () |
Provides a loaned iterator to access the existing requests. More... | |
Sample.Iterator< TReq > | takeRequests (int maxCount) |
Provides a loaned iterator to access the existing requests. More... | |
List< Sample< TReq > > | takeRequests (List< Sample< TReq >> requests, int maxCount) |
Copies existing requests into a list. More... | |
boolean | readRequest (Sample< TReq > request) |
Copies the contents of a request into a Sample. More... | |
Sample.Iterator< TReq > | readRequests () |
Provides a loaned iterator to access the existing requests. More... | |
Sample.Iterator< TReq > | readRequests (int maxCount) |
Provides a loaned iterator to access the existing requests. More... | |
List< Sample< TReq > > | readRequests (List< Sample< TReq >> requests, int maxCount) |
Copies existing requests into a list. More... | |
boolean | waitForRequests (Duration_t maxWait) |
Waits for requests. More... | |
boolean | waitForRequests (int minCount, Duration_t maxWait) |
Waits for requests. More... | |
DataWriter | getReplyDataWriter () |
Retrieves the underlying com.rti.dds.publication.DataWriter. More... | |
DataReader | getRequestDataReader () |
Retrieves the underlying com.rti.dds.subscription.DataReader. More... | |
WriteSample< TRep > | createReplySample () |
Creates a WriteSample for sending replies. More... | |
WriteSample< TRep > | createReplySample (TRep data) |
Creates a WriteSample for sending replies. More... | |
Sample< TReq > | createRequestSample () |
Creates a Sample for receiving replies. More... | |
Sample< TReq > | createRequestSample (TReq data) |
Creates a Sample for receiving replies. More... | |
Allows receiving requests and sending replies.
A Replier is an entity with two associated topics: a request topic and a reply topic. It can receive requests by subscribing to the request topic and can send replies to those requests by publishing 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 com.rti.dds.dynamicdata.DynamicData. See Creating a Replier.
A Replier has four main types of operations:
For multi-reply scenarios in which a com.rti.connext.requestreply.Replier<TReq,TRep> generates more than one reply for a request, the com.rti.connext.requestreply.Replier<TReq,TRep> should mark all the intermediate replies (all but the last) using the com.rti.dds.infrastructure.SampleFlagBits.INTERMEDIATE_REPLY_SEQUENCE_SAMPLE flag in com.rti.dds.infrastructure.WriteParams_t.flag.
Much like a Requester, a Replier has an associated com.rti.dds.domain.DomainParticipant, which can be shared with other Repliers or RTI Connext routines. All the other entities required for the request-reply interaction, including a com.rti.dds.publication.DataWriter for writing replies and a com.rti.dds.subscription.DataReader for reading requests, are automatically created when the Replier 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 com.rti.dds.infrastructure.ReliabilityQosPolicyKind.RELIABLE_RELIABILITY_QOS. The exact default configuration is described here: Configuring Request-Reply QoS profiles
There are several ways to use a Replier:
TReq | The data type for the request topic |
TRep | The data type for the reply topic |
Replier | ( | ReplierParams< TReq, TRep > | params | ) |
Creates a Replier with parameters.
params | All the parameters that configure this Replier |
One | of the Standard Return Codes |
Replier | ( | DomainParticipant | participant, |
String | serviceName, | ||
TypeSupport | requestTypeSupport, | ||
TypeSupport | replyTypeSupport | ||
) |
Creates a Replier with the minimum set of parameters.
participant | The DomainParticipant that this Replier uses to join a domain. |
serviceName | The service name. See com.rti.connext.requestreply.ReplierParams<TReq,TRep>.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 Replier.
Among other internal resources, it deletes the Replier's underlying DataReader and DataWriter.
Referenced by SimpleReplier< TReq, TRep >.close().
void sendReply | ( | TRep | reply, |
SampleIdentity_t | relatedRequestId | ||
) |
Sends a reply for a previous request.
The related request identity can be retrieved from an existing request sample (com.rti.connext.infrastructure.Sample<T>).
reply | The reply to be sent. |
relatedRequestId | The identity of a previously received request |
One | of the Standard Return Codes |
void sendReply | ( | WriteSample< TRep > | reply, |
SampleIdentity_t | relatedRequestId | ||
) |
Sends a reply for a previous request.
Allows you to set custom parameters for writing a reply.
Contrary to the com.rti.connext.requestreply.Requester<TReq,TRep>, where retrieving the sample identity for correlation is common, on the Replier side using a WriteSample is only necessary when the default write parameters need to be overridden, and sendReply(TRep, SampleIdentity_t) may be used if that is not necessary.
One reason to override the default write parameters is a multi-reply scenario in which a com.rti.connext.requestreply.Replier<TReq,TRep> generates more than one reply for a request. In this case, all the intermediate replies (all but the last) should be marked with the com.rti.dds.infrastructure.SampleFlagBits.INTERMEDIATE_REPLY_SEQUENCE_SAMPLE flag in com.rti.dds.infrastructure.WriteParams_t.flag within com.rti.connext.infrastructure.WriteSample<T>.getInfo().
A com.rti.connext.requestreply.Requester<TReq,TRep> can detect if a reply is the last reply of a sequence of replies by checking that the flag com.rti.dds.infrastructure.SampleFlagBits.INTERMEDIATE_REPLY_SEQUENCE_SAMPLE is not set in com.rti.dds.subscription.SampleInfo.flag within com.rti.connext.infrastructure.Sample<T>.getInfo().
References SampleData< T >.getData(), and WriteSample< T >.getInfo().
boolean receiveRequest | ( | Sample< TReq > | request, |
Duration_t | maxWait | ||
) |
Waits for a request and copies its contents into a Sample.
Equivalent to using waitForRequests(int,Duration_t) and takeRequest(Sample<TReq>)
List<Sample<TReq> > receiveRequests | ( | List< Sample< TReq >> | replies, |
int | maxCount, | ||
Duration_t | maxWait | ||
) |
Waits for multiple requests and copies them into a list.
Equivalent to receiveRequests(List<Sample<TReq>>,int,int,Duration_t) with min_count = 0
Referenced by Replier< TReq, TRep >.receiveRequests().
List<Sample<TReq> > receiveRequests | ( | List< Sample< TReq >> | replies, |
int | minCount, | ||
int | maxCount, | ||
Duration_t | maxWait | ||
) |
Waits for multiple requests and copies them into a list.
Equivalent to using waitForRequests(int,Duration_t) and takeRequests(List<Sample<TReq>>,int)
Sample.Iterator<TReq> receiveRequests | ( | Duration_t | maxWait | ) |
Waits for multiple requests and provides a loaned iterator to access them.
Equivalent to using receiveRequests(int,int,Duration_t) with min_count=1
and max_count=com.rti.dds.infrastructure.ResourceLimitsQosPolicy.LENGTH_UNLIMITED
References ResourceLimitsQosPolicy.LENGTH_UNLIMITED, and Replier< TReq, TRep >.receiveRequests().
Sample.Iterator<TReq> receiveRequests | ( | int | minCount, |
int | maxCount, | ||
Duration_t | maxWait | ||
) |
Waits for multiple requests and provides a loaned iterator to access them.
Equivalent to using waitForRequests(int,Duration_t) and takeRequests(int)
boolean takeRequest | ( | Sample< TReq > | request | ) |
Copies the contents of a request into a Sample.
Sample.Iterator<TReq> takeRequests | ( | ) |
Provides a loaned iterator to access the existing requests.
Equivalent to using takeRequests(int) with max_count=com.rti.dds.infrastructure.ResourceLimitsQosPolicy.LENGTH_UNLIMITED
References ResourceLimitsQosPolicy.LENGTH_UNLIMITED.
Sample.Iterator<TReq> takeRequests | ( | int | maxCount | ) |
Provides a loaned iterator to access the existing requests.
Copies existing requests into a list.
boolean readRequest | ( | Sample< TReq > | request | ) |
Copies the contents of a request into a Sample.
This operation is equivalent to com.rti.connext.requestreply.Replier<TReq,TRep>.takeRequest(Sample<TReq>) except the request remains in the Replier and can be read or taken again.
Sample.Iterator<TReq> readRequests | ( | ) |
Provides a loaned iterator to access the existing requests.
This operation is equivalent to com.rti.connext.requestreply.Replier<TReq,TRep>.takeRequests() except the requests remain in the Replier and can be read or taken again.
References ResourceLimitsQosPolicy.LENGTH_UNLIMITED.
Sample.Iterator<TReq> readRequests | ( | int | maxCount | ) |
Provides a loaned iterator to access the existing requests.
This operation is equivalent to com.rti.connext.requestreply.Replier<TReq,TRep>.takeRequests(int) except the requests remain in the Replier and can be read or taken again.
Copies existing requests into a list.
This operation is equivalent to com.rti.connext.requestreply.Replier<TReq,TRep>.takeRequests(List<Sample<TReq>>,int) except the requests remain in the Replier and can be read or taken again.
boolean waitForRequests | ( | Duration_t | maxWait | ) |
Waits for requests.
Equivalent to waitForRequests(int,Duration_t) with min_count=1
boolean waitForRequests | ( | int | minCount, |
Duration_t | maxWait | ||
) |
Waits for requests.
This operation waits for minCount requests to be available. It will wait up to maxWait .
This operation is similar to com.rti.connext.requestreply.Requester<TReq,TRep>.waitForReplies(int,Duration_t).
minCount | Minimum number of requests that need to be available for this operation to unblock. |
maxWait | Maximum waiting time after which this operation unblocks regardless of how many requests are available. |
DataWriter getReplyDataWriter | ( | ) |
Retrieves the underlying com.rti.dds.publication.DataWriter.
DataReader getRequestDataReader | ( | ) |
Retrieves the underlying com.rti.dds.subscription.DataReader.
WriteSample<TRep> createReplySample | ( | ) |
Creates a WriteSample for sending replies.
TReq
initialized with default values and default write parameters. WriteSample<TRep> createReplySample | ( | TRep | data | ) |
Creates a WriteSample for sending replies.
Sample<TReq> createRequestSample | ( | ) |
Creates a Sample for receiving replies.
TReq
and invalid SampleInfo. Sample<TReq> createRequestSample | ( | TReq | data | ) |
Creates a Sample for receiving replies.
TReq
and invalid SampleInfo. References SequenceNumber_t.AUTO_SEQUENCE_NUMBER, GUID_t.GUID_AUTO, GUID_t.GUID_UNKNOWN, WriteParams_t.related_sample_identity, SampleIdentity_t.sequence_number, SequenceNumber_t.SEQUENCE_NUMBER_MAX, SequenceNumber_t.SEQUENCE_NUMBER_UNKNOWN, SequenceNumber_t.SEQUENCE_NUMBER_ZERO, and SampleIdentity_t.writer_guid.