22. Subscribing to Task/Batch Events
Prev | Part IV. Tasks | Next

## 22. Subscribing to Task/Batch Events

You can also tap into various task/batch events when the task is launched. If the task is enabled to generate task and/or batch events (with the additional dependencies `spring-cloud-task-stream` and `spring-cloud-stream-binder-kafka`, in the case of Kafka as the binder), those events are published during the task lifecycle. By default, the destination names for those published events on the broker (rabbit, kafka etc.,) are the event names themselves (for instance: `task-events`, `job-execution-events` etc.,).

    dataflow:>task create myTask --definition “myBatchJob"
    dataflow:>task launch myTask
    dataflow:>stream create task-event-subscriber1 --definition ":task-events > log" --deploy

You can control the destination name for those events by specifying explicit names when launching the task such as:

    dataflow:>task launch myTask --properties "spring.cloud.stream.bindings.task-events.destination=myTaskEvents"
    dataflow:>stream create task-event-subscriber2 --definition ":myTaskEvents > log" --deploy

The default Task/Batch event and destination names on the broker are enumerated below:

Table 22.1. Task/Batch Event Destinations

Event | Destination
Task events | `task-events`
Job Execution events | `job-execution-events`
Step Execution events | `step-execution-events`
Item Read events | `item-read-events`
Item Process events | `item-process-events`
Item Write events | `item-write-events`
Skip events | `skip-events`

Prev | Up | Next
21. Task Repository | Home | Part V. Dashboard