RTI Connext Java API  Version 5.1.0
Replier< TReq, TRep > Class Reference

Allows receiving requests and sending replies. More...

Inheritance diagram for Replier< TReq, TRep >:
CloseableFinalizer

Public Member Functions

 Replier (ReplierParams< TReq, TRep > params)
 Creates a Replier with parameters.
 
 Replier (DomainParticipant participant, String serviceName, TypeSupport requestTypeSupport, TypeSupport replyTypeSupport)
 Creates a Replier with the minimum set of parameters.
 
void close ()
 Releases the internal entities created by this Replier.
 
void sendReply (TRep reply, SampleIdentity_t relatedRequestId)
 Sends a reply for a previous request.
 
void sendReply (WriteSample< TRep > reply, SampleIdentity_t relatedRequestId)
 Sends a reply for a previous request.
 
boolean receiveRequest (Sample< TReq > request, Duration_t maxWait)
 Waits for a request and copies its contents into a Sample.
 
List< Sample< TReq > > receiveRequests (List< Sample< TReq >> replies, int maxCount, Duration_t maxWait)
 Waits for multiple requests and copies them into a list.
 
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.
 
Sample.Iterator< TReq > receiveRequests (Duration_t maxWait)
 Waits for multiple requests and provides a loaned iterator to access them.
 
Sample.Iterator< TReq > receiveRequests (int minCount, int maxCount, Duration_t maxWait)
 Waits for multiple requests and provides a loaned iterator to access them.
 
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.
 
Sample.Iterator< TReq > takeRequests (int maxCount)
 Provides a loaned iterator to access the existing requests.
 
List< Sample< TReq > > takeRequests (List< Sample< TReq >> requests, int maxCount)
 Copies existing requests into a list.
 
boolean readRequest (Sample< TReq > request)
 Copies the contents of a request into a Sample.
 
Sample.Iterator< TReq > readRequests ()
 Provides a loaned iterator to access the existing requests.
 
Sample.Iterator< TReq > readRequests (int maxCount)
 Provides a loaned iterator to access the existing requests.
 
List< Sample< TReq > > readRequests (List< Sample< TReq >> requests, int maxCount)
 Copies existing requests into a list.
 
boolean waitForRequests (Duration_t maxWait)
 Waits for requests.
 
boolean waitForRequests (int minCount, Duration_t maxWait)
 Waits for requests.
 
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.
 
WriteSample< TRep > createReplySample (TRep data)
 Creates a WriteSample for sending replies.
 
Sample< TReq > createRequestSample ()
 Creates a Sample for receiving replies.
 
Sample< TReq > createRequestSample (TReq data)
 Creates a Sample for receiving replies.
 

Detailed Description

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 DynamicData. See Creating a Replier.

A Replier has four main types of operations:

  • Waiting for requests to be received from the middleware
  • Getting those requests
  • Receiving requests (a convenience operation that is a combination of waiting and getting in a single operation)
  • Sending a reply for a previously received request (i.e., publishing a reply sample on the reply topic with special meta-data so that the orignal Requester can identify it)

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 reliable quality of service. The exact default configuration is described here: Configuring Request-Reply QoS profiles

There are several ways to use a Replier:

Template Parameters
TReqThe data type for the request topic
TRepThe data type for the reply topic
See Also
com.rti.connext.requestreply.Requester<TReq,TRep>
Request-Reply Examples
Basic Replier example

Constructor & Destructor Documentation

Replier ( ReplierParams< TReq, TRep >  params)

Creates a Replier with parameters.

Parameters
paramsAll the parameters that configure this Replier
Exceptions
Oneof the Standard Return Codes
See Also
com.rti.connext.requestreply.ReplierParams<TReq,TRep>
Creating a Replier
Replier ( DomainParticipant  participant,
String  serviceName,
TypeSupport  requestTypeSupport,
TypeSupport  replyTypeSupport 
)

Creates a Replier with the minimum set of parameters.

Parameters
participantThe DomainParticipant that this Replier uses to join a domain.
serviceNameThe service name. See com.rti.connext.requestreply.ReplierParams<TReq,TRep>.setServiceName(String)
requestTypeSupportThe type support for type TReq
replyTypeSupportThe type support for type TReq
Exceptions
Oneof the Standard Return Codes

Member Function Documentation

void close ( )

Releases the internal entities created by this Replier.

Among other internal resources, it deletes the Replier's underlying DataReader and DataWriter.

See Also
com.rti.dds.subscription.Subscriber.delete_datareader
com.rti.dds.publication.Publisher.delete_datawriter
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>).

Parameters
replyThe reply to be sent.
relatedRequestIdThe identity of a previously received request
Exceptions
Oneof the Standard Return Codes
See Also
com.rti.connext.infrastructure.SampleData<T>.getIdentity()
receiveRequest(Sample<TReq>,Duration_t)
receiveRequests(int,int,Duration_t)
takeRequest(Sample<TReq>)
takeRequests(int)
Basic Replier example
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.

See Also
sendReply(TRep, SampleIdentity_t)
com.rti.connext.infrastructure.WriteSample<T>
boolean receiveRequest ( Sample< TReq >  request,
Duration_t  maxWait 
)
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

See Also
com.rti.connext.infrastructure.Sample<T>
receiveRequests(List<Sample<TReq>>,int,Duration_t)
List<Sample<TReq> > receiveRequests ( List< Sample< TReq >>  replies,
int  minCount,
int  maxCount,
Duration_t  maxWait 
)
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

See Also
com.rti.connext.infrastructure.Sample<T>.Iterator<T>
receiveRequests(int,int,Duration_t)
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)

See Also
com.rti.connext.infrastructure.Sample<T>.Iterator<T>
waitForRequests(int,Duration_t)
takeRequests(int)
boolean takeRequest ( Sample< TReq >  request)

Copies the contents of a request into a Sample.

See Also
com.rti.connext.requestreply.Requester<TReq,TRep>.takeReply(Sample<TRep>)
Sample.Iterator<TReq> takeRequests ( )
Sample.Iterator<TReq> takeRequests ( int  maxCount)

Provides a loaned iterator to access the existing requests.

See Also
com.rti.connext.requestreply.Requester<TReq,TRep>.takeReplies(int)
List<Sample<TReq> > takeRequests ( List< Sample< TReq >>  requests,
int  maxCount 
)
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.

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.

List<Sample<TReq> > readRequests ( List< Sample< TReq >>  requests,
int  maxCount 
)

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

See Also
waitForRequests(int,Duration_t)
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).

Parameters
minCountMinimum number of requests that need to be available for this operation to unblock.
maxWaitMaximum waiting time after which this operation unblocks regardless of how many requests are available.
Returns
true if at least minCount requests were available before maxWait elapsed, or false otherwise.
See Also
takeRequests(int)
com.rti.connext.requestreply.Requester<TReq,TRep>.waitForReplies(int,Duration_t)
WriteSample<TRep> createReplySample ( )

Creates a WriteSample for sending replies.

Returns
A new WriteSample with data of type TReq initialized with default values and default write parameters.
See Also
com.rti.connext.infrastructure.WriteSample<T>
sendReply(WriteSample<TRep>, SampleIdentity_t)
WriteSample<TRep> createReplySample ( TRep  data)

Creates a WriteSample for sending replies.

Returns
A new WriteSample with the specified data and default write parameters.
See Also
createReplySample()
Sample<TReq> createRequestSample ( )

Creates a Sample for receiving replies.

Returns
A new Sample with default data of type TReq and invalid SampleInfo.
See Also
com.rti.connext.infrastructure.Sample<T>
receiveRequest(Sample<TReq>,Duration_t)
takeRequest(Sample<TReq>)
Sample<TReq> createRequestSample ( TReq  data)

Creates a Sample for receiving replies.

Returns
A new Sample with default data of type TReq and invalid SampleInfo.
See Also
com.rti.connext.infrastructure.Sample<T>
receiveRequest(Sample<TReq>,Duration_t)
takeRequest(Sample<TReq>)

RTI Connext Java API Version 5.1.0 Copyright © Mon Feb 3 2014 Real-Time Innovations, Inc