1

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"
    
Sunil Chauraha
  • 525
  • 1
  • 7
  • 21

2 Answers2

1

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.

Sabby Anandan
  • 5,636
  • 2
  • 12
  • 21
  • Thank you very much Anandan. But when I deploy the stream I am seeing it's un-deployed. Here are the steps I did. 1. app register --name triggertask --type source --uri maven://org.springframework.cloud.task.app:timestamp-task:jar:1.0.1.RELEASE 2. app register --name task-launcher-local --type sink --uri maven://org.springframework.cloud.stream.app:task-launcher-local-sink-kafka:jar:1.0.0.BUILD-SNAPSHOT 3. stream create mytasklaunchertest --definition "triggertask --triggertask.uri=file:///scdf-task2-helloworld-0.0.1-SNAPSHOT.jar --trigger.fixed-delay=5 | task-launcher-local" --deploy – Sunil Chauraha Sep 20 '16 at 07:10
  • Here I see runtime state is unknown and sometimes i see tasklauncher app is deployed but triggertask is never deployed thus stream is also not deployed. – Sunil Chauraha Sep 20 '16 at 07:14
  • Here is the log: o.s.c.t.a.t.TimestampTaskApplication : Starting TimestampTaskApplication v1.0.0.BUILD-SNAPSHOT on intintdev07 with PID 6860 (/path/timestamp-task-1.0.0.BUILD-SNAPSHOT.jar started by sid1adm in /path/foo-1474374281890/foo.triggertask) s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@1f088fd4: startup date o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown o.s.c.t.a.t.TimestampTaskApplication : Started TimestampTaskApplication in 3.189 seconds – Sunil Chauraha Sep 20 '16 at 12:26
  • But still on the dashboard I see status as unknown. not able to find what am I missing. – Sunil Chauraha Sep 20 '16 at 12:30
  • Which runtime platform are you running this stream/task combination? – Sabby Anandan Sep 20 '16 at 16:43
  • I am using below runtime: spring-cloud-dataflow-server-local-1.0.0.RELEASE.jar, java version "1.8.0_91", Linux 2.6.18-409.el5 x86_64 and redis-3.2.0. – Sunil Chauraha Sep 20 '16 at 17:20
  • In the given example: stream create foo --definition "triggertask --triggertask.uri=maven://org.springframework.cloud.task.app:timestamp-task:jar:1.0.0.BUILD-SNAPSHOT --trigger.fixed-delay=5 | task-launcher-local" --deploy. I created two apps "triggertask" and "task-launcher-local" then created the stream with the given definition and in --triggertask.uri={task app} here I am giving my task jar path. – Sunil Chauraha Sep 20 '16 at 17:39
  • A million thanks Sabby. I am successfully able to deploy my task based on time interval. The issue was with compiled code which I was using. Now as suggested I registered apps from bit.ly and created the stream and it worked. :) – Sunil Chauraha Sep 21 '16 at 18:19
  • Glad it worked! :) Please consider sharing the final solution to general audience and perhaps also resolve this open thread. – Sabby Anandan Sep 22 '16 at 14:01
0

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"
    
Sunil Chauraha
  • 525
  • 1
  • 7
  • 21