Skip to content

[Experimental] Improve conversion functionality for events #1372

@fjtirado

Description

@fjtirado

Currently users are forced to add an outputAs method to access the first element of the collection

 listen(
                          "waitHumanReview",
                          to().one(
                                  consumed("org.acme.newsletter.review.done")
                                      .extensionByInstanceId("instanceid")))
                      .outputAs((Collection<?> events) -> events.iterator().next()),
                  // The engine sees the incoming JsonNode, sees this task expects
                  // HumanReview.class,
                  // and natively deserializes it for you before executing the lambda!
                  switchWhenOrElse(
                      h -> HumanReview.NEEDS_REVISION.equals(h.status()),
                      "humanEditorAgent",
                      "sendNewsletter",
                      HumanReview.class)

It would be nice if they can just write

   listen(
                      "waitHumanReview",
                      to().one(
                              consumed("org.acme.newsletter.review.done")
                                  .extensionByInstanceId("instanceid"))),
                  // The engine sees the incoming JsonNode, sees this task expects
                  // HumanReview.class,
                  // and natively deserializes it for you before executing the lambda!
                  switchWhenOrElse(
                      h -> HumanReview.NEEDS_REVISION.equals(h.status()),
                      "humanEditorAgent",
                      "sendNewsletter",
                      HumanReview.class),

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions