Interface IRequester<T extends IdBean>
- Type Parameters:
T- You must override the merge(...) method in your type. This puts the reponder's information into your bean. In the case where there are multiple reponders (like a list of detectors) you must be additive in the merge method.
- All Superinterfaces:
AutoCloseable,IConnection,IRequestResponseConnection,IURIConnection
A poster broadcasts a request of an object with a unique id. The server then fills in information about this object
and broadcasts it back. The UUID must be set to determine which response belongs with whcih request.
This mimics web server functionality but uses the existing messaging system without requiring a web server configuration. An alternative to this might be to start a jetty server on the acquisition server and response to requests directly.
A use case for this is where a client would like to get a list of detectors. NOTE: Unlike a web server this paradigm allows multiple responders to reply on a topic. Therefore for instance if many malcolm devices are available on different ports, a post will be made asking for those devices and the response from many listeners of the post topic collated.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IRequester.ResponseTypestatic final TimeUnitstatic final long -
Method Summary
Modifier and TypeMethodDescriptionRequests a response from the request and returns it.Aspost(IdBean), but allowing the caller to specify a timeout to apply to this request only.post(T request, IResponseWaiter waiter) Same aspost(IdBean)with an optionalIResponseWaiter(may be null) which provides the ability to return true if the post should carry on waiting.post(T request, IResponseWaiter waiter, long timeout, TimeUnit timeUnit) Aspost(IdBean, IResponseWaiter), but allowing the caller to specify a timeout to apply to this request only.voidsetResponseType(IRequester.ResponseType responseType) Set theIRequester.ResponseTyperequired (see above)voidsetTimeout(long time, TimeUnit unit) Set the timeout for the requestMethods inherited from interface org.eclipse.scanning.api.event.core.IConnection
close, disconnect, isConnectedMethods inherited from interface org.eclipse.scanning.api.event.core.IRequestResponseConnection
getRequestTopic, getResponseTopic, setRequestTopic, setResponseTopicMethods inherited from interface org.eclipse.scanning.api.event.core.IURIConnection
getConnectorService, getUri
-
Field Details
-
DEFAULT_RESPONSE_TYPE
-
DEFAULT_TIMEOUT
static final long DEFAULT_TIMEOUT- See Also:
-
DEFAULT_TIME_UNIT
-
-
Method Details
-
setResponseType
Set theIRequester.ResponseTyperequired (see above) -
setTimeout
Set the timeout for the request -
post
Requests a response from the request and returns it. This method blocks until the response has been retrieved with the correctUUID.Calls post and waits for the timeout until one or more reponses have come in (depending on the response configuration) then returns.
- Parameters:
request- the request to be sent- Returns:
- the response to the request
- Throws:
EventExceptionInterruptedException
-
post
Aspost(IdBean), but allowing the caller to specify a timeout to apply to this request only.- Throws:
EventExceptionInterruptedException
-
post
Same aspost(IdBean)with an optionalIResponseWaiter(may be null) which provides the ability to return true if the post should carry on waiting. This is useful for instance in the case where a scannable is setting position. It will have notified position recently and if the waiter thinks it is still alive there is not reason to timeout. This is useful in setPosition(...) calls for scannables that can take an indeterminate time but should still timeout if they go inactive.- Parameters:
request- the request to be sentwaiter- IResponseWaiter (can be null) which determines if the post should carry on waiting after an initial timeout- Returns:
- the response to the request
- Throws:
EventExceptionInterruptedException
-
post
T post(T request, IResponseWaiter waiter, long timeout, TimeUnit timeUnit) throws EventException, InterruptedException Aspost(IdBean, IResponseWaiter), but allowing the caller to specify a timeout to apply to this request only.- Throws:
EventExceptionInterruptedException
-