public class HttpWorker
extends akka.actor.UntypedActor
Modifier and Type | Class and Description |
---|---|
(package private) static class |
HttpWorker.HttpAsyncHandler
Async HTTP Client handler wrapper.
|
Modifier and Type | Field and Description |
---|---|
private int |
actorMaxOperationTimeoutSec
The actor max operation timeout sec.
|
private java.lang.Throwable |
cause
The cause.
|
private com.ning.http.client.AsyncHttpClient |
client
The client.
|
private java.util.Map<java.lang.String,java.lang.String> |
httpHeaderMap
The http header map.
|
private HttpMethod |
httpMethod
The http method.
|
private static org.slf4j.Logger |
logger
The logger.
|
private java.lang.String |
postData
The post data.
|
private java.lang.String |
requestUrl
The request url.
|
(package private) com.ning.http.client.ListenableFuture<ResponseOnSingeRequest> |
responseFuture
The response future.
|
private ResponseHeaderMeta |
responseHeaderMeta
The response header meta: which keys are needed to get from response
header.
|
private akka.actor.ActorRef |
sender
The sender.
|
private boolean |
sentReply
The sent reply.
|
private scala.concurrent.duration.FiniteDuration |
timeoutDuration
The timeout duration.
|
private akka.actor.Cancellable |
timeoutMessageCancellable
The timeout message cancellable.
|
private int |
tryCount
The try count.
|
Constructor and Description |
---|
HttpWorker(int actorMaxOperationTimeoutSec,
com.ning.http.client.AsyncHttpClient client,
java.lang.String requestUrl,
HttpMethod httpMethod,
java.lang.String postData,
java.util.Map<java.lang.String,java.lang.String> httpHeaderMap,
ResponseHeaderMeta responseHeaderMeta)
Instantiates a new http worker.
|
Modifier and Type | Method and Description |
---|---|
void |
cancelCancellable()
Cancel cancellable.
|
com.ning.http.client.AsyncHttpClient.BoundRequestBuilder |
createRequest()
Creates the request.
|
static org.slf4j.Logger |
getLogger()
Gets the logger.
|
ResponseOnSingeRequest |
onComplete(com.ning.http.client.Response response)
On complete.
|
void |
onReceive(java.lang.Object message) |
void |
onThrowable(java.lang.Throwable cause)
On throwable.
|
private void |
reply(java.lang.String response,
boolean error,
java.lang.String errorMessage,
java.lang.String stackTrace,
java.lang.String statusCode,
int statusCodeInt,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> responseHeaders)
Reply.
|
static void |
setLogger(org.slf4j.Logger logger)
Sets the logger.
|
akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, getContext, getSelf, getSender, postRestart, postStop, preRestart, preStart, receive, self, sender, supervisorStrategy, unhandled
private int actorMaxOperationTimeoutSec
private final com.ning.http.client.AsyncHttpClient client
private final java.lang.String requestUrl
private final HttpMethod httpMethod
private final java.lang.String postData
private static org.slf4j.Logger logger
private final java.util.Map<java.lang.String,java.lang.String> httpHeaderMap
private final ResponseHeaderMeta responseHeaderMeta
private akka.actor.ActorRef sender
private java.lang.Throwable cause
private int tryCount
private akka.actor.Cancellable timeoutMessageCancellable
private scala.concurrent.duration.FiniteDuration timeoutDuration
private boolean sentReply
com.ning.http.client.ListenableFuture<ResponseOnSingeRequest> responseFuture
public HttpWorker(int actorMaxOperationTimeoutSec, com.ning.http.client.AsyncHttpClient client, java.lang.String requestUrl, HttpMethod httpMethod, java.lang.String postData, java.util.Map<java.lang.String,java.lang.String> httpHeaderMap, ResponseHeaderMeta responseHeaderMeta)
actorMaxOperationTimeoutSec
- the actor max operation timeout secclient
- the clientrequestUrl
- the request urlhttpMethod
- the http methodpostData
- the post datahttpHeaderMap
- the http header mapresponseHeaderMeta
- the response header metapublic com.ning.http.client.AsyncHttpClient.BoundRequestBuilder createRequest() throws HttpRequestCreateException
HttpRequestCreateException
- the http request create exceptionpublic void onReceive(java.lang.Object message) throws java.lang.Exception
onReceive
in class akka.actor.UntypedActor
java.lang.Exception
public void cancelCancellable()
private void reply(java.lang.String response, boolean error, java.lang.String errorMessage, java.lang.String stackTrace, java.lang.String statusCode, int statusCodeInt, java.util.Map<java.lang.String,java.util.List<java.lang.String>> responseHeaders)
response
- the responseerror
- the errorerrorMessage
- the error messagestackTrace
- the stack tracestatusCode
- the status codestatusCodeInt
- the status code intresponseHeaders
- the response headerspublic ResponseOnSingeRequest onComplete(com.ning.http.client.Response response)
response
- the responsepublic void onThrowable(java.lang.Throwable cause)
cause
- the causepublic static org.slf4j.Logger getLogger()
public static void setLogger(org.slf4j.Logger logger)
logger
- the new logger