Messaging is a better alternative to Service Topics for sending point-to-point requests.
@Deprecated public interface ServiceTopicData extends CommandTopicData, TopicDataWithMetadata
topic
data
provides the mechanism for routing and executing user written
request/response services.
Each service request comprises a 'request type', a 'request id' and optional user header values and/or data.
The 'request id' is a unique identifier assigned by the client and used to correlate responses and requests.
The service request is passed to a ServiceHandler
which may choose to
process the request and return a response synchronously or delegate the
request processing and allow the response to be returned asynchronously at
some later point (via the serviceResponse(ServiceResponse)
method).
An instance of this type of data can be created using
TopicDataFactory.newServiceData(String, ServiceHandler)
.
Modifier and Type | Method and Description |
---|---|
TopicMessage |
createDeltaMessage(String... headers)
Deprecated.
Convenience method to create a delta message for the parent topic which
has the
default capacity from the owning Topic and the
delta encoding pre-applied. |
List<ServiceHeader> |
getHeaderOptions()
Deprecated.
Returns the current header options.
|
long |
getRequestTimeout()
Deprecated.
Returns the current request timeout value.
|
TopicMessage |
getServiceData()
Deprecated.
Returns service data (if there is any).
|
ServiceHandler |
getServiceHandler()
Deprecated.
Returns the handler of service requests.
|
String |
getServiceType()
Deprecated.
This returns the service type.
|
String |
getTargetTopicName()
Deprecated.
Returns target topic name (if set).
|
boolean |
serviceError(ServiceRequest request,
String errorMessage,
Throwable exception)
Deprecated.
As
serviceError(String, String, String, Throwable) but the
client and request identifiers are obtained from a request. |
boolean |
serviceError(String clientId,
String requestId,
String errorMessage,
Throwable exception)
Deprecated.
This may be used to asynchronously report a failure of a service
execution.
|
boolean |
serviceResponse(ServiceResponse response)
Deprecated.
This may be used to asynchronously return a response to a request issued
to a
ServiceHandler . |
void |
setHeaderOptions(ServiceHeader... headers)
Deprecated.
Sets a list of additional headers to be included in any request message
that is generated within a
ServiceRequest . |
void |
setRequestTimeout(long millis)
Deprecated.
Sets the amount of time before an asynchronous request which has not had
a reply will be timed out.
|
void |
setServiceData(TopicMessage data)
Deprecated.
Sets data that will be returned to any client that subscribed to a
service topic in it's load message.
|
void |
setTargetTopicName(String topicName)
Deprecated.
Sets the target topic name.
|
getDeltaEncoding, getLoadEncoding, getLoadMessage, getLoadMessage, getTopic, getType, hasSubscribers, isCommand, isLockedByCurrentThread, isPaged, isPublishing, isRouting, isService, lock, setDeltaEncoding, setLoadEncoding, unlock
getMetadataNode, isMetadataMandatory, setMetadataNode
String getServiceType()
This type is the way in which the service is identified to the client so that the client is able to understand the type of service it is interacting with.
ServiceHandler getServiceHandler()
void setTargetTopicName(String topicName) throws APIException
By default the request message that is generated within a
ServiceRequest
will have the same topic name as the topic owning
the topic data. However, this allows a different topic name to be used.
This topic name does not even need to be known in the current topic tree.
This must be called before the topic data is attached to a topic.
topicName
- the topic nameAPIException
- if unable to set the target topic nameString getTargetTopicName()
This will return target topic name if one has been set using
setTargetTopicName(String)
.
void setHeaderOptions(ServiceHeader... headers)
ServiceRequest
.
These additional headers will be added to the message before any user defined headers.
By default, if this is not called, then no additional header values will be inserted into Messages
headers
- list of headers required. These values of the specified
headers will be inserted into each Message in the order specified.List<ServiceHeader> getHeaderOptions()
void setRequestTimeout(long millis)
millis
- time in milliseconds - non positive values ignoredlong getRequestTimeout()
setRequestTimeout(long)
void setServiceData(TopicMessage data) throws TimeoutException
The data is set in the form of a message which may have headers and/or data and this will be used to form the load message for any newly subscribing client.
This data is optional as a client will be sent an empty load message anyway on subscription to identify the topic as a service but any data specified here is sent along with the load messages. This may be set before the data is attached to the topic or even after in which case any clients that subscribe subsequently would get the new data.
data
- a message encapsulating the headers and/or data to be sent
with the load message. Null can be specified to clear out any
existing data.TimeoutException
- if unable to acquire a lock on the data within
the timeout period specified for the topicTopicMessage getServiceData()
setServiceData(TopicMessage)
boolean serviceResponse(ServiceResponse response) throws APIException
ServiceHandler
.
This may only be used if the service handler initially returned a null response indicating asynchronous execution.
response
- the response to the service callAPIException
- if the response object is invalidboolean serviceError(String clientId, String requestId, String errorMessage, Throwable exception)
clientId
- the client identifierrequestId
- the request identifiererrorMessage
- an error messageexception
- an optional exception - may be nullboolean serviceError(ServiceRequest request, String errorMessage, Throwable exception)
serviceError(String, String, String, Throwable)
but the
client and request identifiers are obtained from a request.request
- the requesterrorMessage
- the error messageexception
- an optional exceptionTopicMessage createDeltaMessage(String... headers) throws APIException
default capacity
from the owning Topic and the
delta encoding
pre-applied.
Such a delta message could be used in a service
response
.
This can only be called after the data has been attached to a topic.
headers
- optional user headersAPIException
- if unable to create the messageCopyright © 2016 Push Technology Ltd. All Rights Reserved.