Package com.github.workerframework.api
Interface WorkerCallback
public interface WorkerCallback
The callback interface for a task to report it is complete or that it must be subject to some further action, e.g. forwarding.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
abandon
(TaskInformation taskInformation, Exception e) Indicates the Worker wishes to abandon this task, but return it to the queue so that it can be retried by this or another Worker instance.void
complete
(TaskInformation taskInformation, String queue, TaskMessage responseMessage) Indicate a task was completed.void
discard
(TaskInformation taskInformation) Indicates the Worker wishes to discard this task without returning it to the queue for retry.void
forward
(TaskInformation taskInformation, String queue, TaskMessage forwardedMessage, Map<String, Object> headers) Indicates the Worker wishes to forward this task to the specified queue without processing it.void
pause
(TaskInformation taskInformation, String pausedQueue, TaskMessage taskMessage, Map<String, Object> headers) Indicates the Worker wishes to forward this task to the specified paused queue without processing it.void
reportUpdate
(TaskInformation taskInformation, TaskMessage reportUpdateMessage) Used to send a report update message.void
send
(TaskInformation taskInformation, TaskMessage responseMessage) Used to send responses prior to the final response (when complete should be used instead).
-
Method Details
-
send
Used to send responses prior to the final response (when complete should be used instead).- Parameters:
taskInformation
- a queue-specific reference for the incoming message that generated the responseresponseMessage
- the message to put on the queue (target specified by theto
property)
-
complete
Indicate a task was completed.- Parameters:
taskInformation
- a queue-specific reference for the incoming message that generated the responsequeue
- the queue to hold the messageresponseMessage
- the message to put on the queue
-
abandon
Indicates the Worker wishes to abandon this task, but return it to the queue so that it can be retried by this or another Worker instance.- Parameters:
taskInformation
- the id of the task's queue message to rejecte
- the Exception causing the task's queue message to be rejected
-
forward
void forward(TaskInformation taskInformation, String queue, TaskMessage forwardedMessage, Map<String, Object> headers) Indicates the Worker wishes to forward this task to the specified queue without processing it.- Parameters:
taskInformation
- a queue-specific reference for the incoming message to be forwardedqueue
- the queue to hold the forwarded messageforwardedMessage
- the message to put on the queueheaders
- the map of key/value paired headers to be stamped on the message
-
pause
void pause(TaskInformation taskInformation, String pausedQueue, TaskMessage taskMessage, Map<String, Object> headers) Indicates the Worker wishes to forward this task to the specified paused queue without processing it.- Parameters:
taskInformation
- a queue-specific reference for the incoming message to be forwarded to the paused queuepausedQueue
- the queue to hold the forwarded messagetaskMessage
- the message to put on the paused queueheaders
- the map of key/value paired headers to be stamped on the message
-
discard
Indicates the Worker wishes to discard this task without returning it to the queue for retry.- Parameters:
taskInformation
- the id of the task's queue message to discard
-
reportUpdate
Used to send a report update message.- Parameters:
taskInformation
- a queue-specific reference for the incoming messagereportUpdateMessage
- the report update message to put on the queue
-