简体   繁体   中英

Execute different lambdas based on input

I need SWF workflow to trigger one of three lambda functions. SWF workflow should accept some input and determine and trigger the appropriate lambda. How can I accomplish this?

If you are using AWS Flow Framework then it is going to look something like:

@Execute
public void myWorkflow(Whatever input) {
   if (match1(input)) {
      lambdaClient.schedleLambdaFunction(name1, input1);
   } else if (match2(input)) {
      lambdaClient.schedleLambdaFunction(name2, input2);
   } else if (match3(input)) {
      lambdaClient.schedleLambdaFunction(name3, input3);
   }
}

For more info see AWS Flow Framework for Java Programming Guide ,
AWS Flow Framework samples for Amazon SWF and AWS Flow Framework Recipes .

You can build a stream by parts as long as you add only intermediate operations. Only when you use terminal operations the stream is actually being executed. See for example Processing Data with Java SE 8 Streams, Part 1 , section "Stream Operations: Exploiting Streams to Process Data":

Stream operations that can be connected are called intermediate operations. They can be connected together because their return type is a Stream. Operations that close a stream pipeline are called terminal operations. They produce a result from a pipeline such as a List, an Integer, or even void (any non-Stream type).

You might be wondering why the distinction is important. Well, intermediate operations do not perform any processing until a terminal operation is invoked on the stream pipeline; they are “lazy.” This is because intermediate operations can usually be “merged” and processed into a single pass by the terminal operation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM