public abstract class AbstractStreamClient<C extends StreamClientConfiguration,REQUEST> extends Object implements StreamClient<C>
Constructor and Description |
---|
AbstractStreamClient() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
abort(REQUEST request)
Cancel and abort the request immediately, with the proprietary API.
|
protected abstract Callable<StreamResponseMessage> |
createCallable(StreamRequestMessage requestMessage,
REQUEST request)
Create a callable procedure that will execute the request.
|
protected abstract REQUEST |
createRequest(StreamRequestMessage requestMessage)
Create a proprietary representation of this request, log warnings and
return
null if creation fails. |
protected abstract boolean |
logExecutionException(Throwable t) |
protected void |
onFinally(REQUEST request) |
StreamResponseMessage |
sendRequest(StreamRequestMessage requestMessage)
Sends the given request via TCP (HTTP) and returns the response.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConfiguration, stop
public StreamResponseMessage sendRequest(StreamRequestMessage requestMessage) throws InterruptedException
StreamClient
This method must implement expiration of timed out requests using the
StreamClientConfiguration
settings. When a request expires, a
null
response will be returned.
This method will always try to complete execution without throwing an exception. It will
return null
if an error occurs, and optionally log any exception messages.
The rules for logging are:
FINE
.INFO
level.WARNING
level
This method is required to add a Host
HTTP header to the
outgoing HTTP request, even if the given
StreamRequestMessage
does not contain such a header.
This method will add the User-Agent
HTTP header to the outgoing HTTP request if
the given message did not already contain such a header. You can set this default value in your
StreamClientConfiguration
.
sendRequest
in interface StreamClient<C extends StreamClientConfiguration>
requestMessage
- The message to send.null
if no response has been received or an error occurred.InterruptedException
- if you interrupt the calling thread.protected abstract REQUEST createRequest(StreamRequestMessage requestMessage)
null
if creation fails.protected abstract Callable<StreamResponseMessage> createCallable(StreamRequestMessage requestMessage, REQUEST request)
protected abstract void abort(REQUEST request)
protected abstract boolean logExecutionException(Throwable t)
true
if no more logging of this exception should be done.protected void onFinally(REQUEST request)
Copyright © 2016 4th Line GmbH, Switzerland. All rights reserved.