Search code examples
springtaskspring-cloud-streamspring-cloud-dataflowspring-cloud-task

Executing spring cloud task based on event into messaging source (i.e. RabbitMQ, Kafka)


I am new in Learning of Spring cloud Task and SCDF so asking this.

I wand to execute my SCT based on an event (say a message is posted into Rabbit MQ), so I am think it can be done in two ways:

  1. Create a source which polls message from RabbitMQ and sends the data to stream, now create a sink which reads data from stream and as soon as data comes to sink (from source stream) Task will be launched.

    create steam producer --definition "rabbitproducer | streamconsumer (This is @TaskEnabled)"
    

    Not sure if this is possible?

  2. Other way could be to use task launcher. Here task launcher will be configured with a stream and a listener will be polling message from rabbitMQ. so when a message is received then trigger will initiate the process and tasklauncher will launch the task. But here not sure how will i get the message data into my task? Do I have to add the data into TaskLaunchRequest?

    create stream mystream --definition "rabbitmsgtrigger --uri:my task | joblauncher"
    

Solution

  • Launching a Task by an upstream event is already supported and there are few approaches to it - please review the reference guide (and the sample) for more details.