1
votes

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"
    
2
Do you have a typo in streamcousumer? If so, please edit to correct - thanks.halfer

2 Answers

1
votes

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.

0
votes

Here is the complete explanation about my question's answer. Here Sabby has helped me a lot for resolving my issue.

Problem: I was not able to trigger my task using tasklauncher/task-sink. In the log also I was not getting correct details and I even did not know how to set to set log level correctly.

Solution: With the help of Sabby and documentations provided on SCT site I could resolve this and have moved ahead in my POC work. Below are the detailed steps I did.

  1. Started my SCDF with postgresql database by referring to the property file and setting log level change as

    --logging.level.org.springframework.cloud=DEBUG
    --spring.config.location=file://scdf.properties
    
  2. Imported apps from bitly.

    app import --uri [stream applications link][1]
    
  3. Registered task sink app

    app register --name task-sink --type sink --uri file://tasksink-1.1.0.BUILD-SNAPSHOT.jar
    
  4. Created stream as:

    stream create mytasklaunchertest --definition "triggertask --triggertask.uri=https://my-archiva/myproject-scdf-task1/0.0.1-SNAPSHOT/myproject-scdf-task1-0.0.1-20160916.143611-1.jar --trigger.fixed-delay=5 | task-sink"
    
  5. Deployed Stream:

    stream deploy foo --properties "app.triggertask.spring.rabbitmq.host=host,app.triggertask.spring.rabbitmq.username=user,app.triggertask.spring.rabbitmq.password=pass,app.triggertask.spring.rabbitmq.port=5672,app.triggertask.spring.rabbitmq.virtual-host=xxx"