You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add a new foreach property to both listen task and asyncapi call, used to configure the iterator used to process consumed events/messages
- Add a new `read` property to the `listen` task, used to configure how to read consumed events
Signed-off-by: Charles d'Avernas <charles.davernas@neuroglia.io>
@@ -311,7 +311,7 @@ The [AsyncAPI Call](#asyncapi-call) enables workflows to interact with external
311
311
| operation | `string` | `yes` | A reference to the AsyncAPI [operation](https://www.asyncapi.com/docs/reference/specification/v3.0.0#operationObject) to call.<br>*Used only in case the referenced document uses AsyncAPI `v3.0.0`.* |
312
312
| server | [`asyncApiServer`](#asyncapi-server) | `no` | An object used to configure to the [server](https://www.asyncapi.com/docs/reference/specification/v3.0.0#serverObject) to call the specified AsyncAPI [operation](https://www.asyncapi.com/docs/reference/specification/v3.0.0#operationObject) on.<br>If not set, default to the first [server](https://www.asyncapi.com/docs/reference/specification/v3.0.0#serverObject) matching the operation's channel. |
313
313
| protocol | `string` | `no` | The [protocol](https://www.asyncapi.com/docs/reference/specification/v3.0.0#definitionsProtocol) to use to select the target [server](https://www.asyncapi.com/docs/reference/specification/v3.0.0#serverObject). <br>Ignored if `server` has been set.<br>*Supported values are: `amqp`, `amqp1`, `anypointmq`, `googlepubsub`, `http`, `ibmmq`, `jms`, `kafka`, `mercure`, `mqtt`, `mqtt5`, `nats`, `pulsar`, `redis`, `sns`, `solace`, `sqs`, `stomp` and `ws`* |
314
-
| message | [`asyncApiMessage`](#asyncapi-message) | `no` | An object used to configure the message to publish using the target operation.<br>*Required if `subscription` has not been set.* |
314
+
| message | [`asyncApiMessage`](#asyncapi-outbound-message) | `no` | An object used to configure the message to publish using the target operation.<br>*Required if `subscription` has not been set.* |
315
315
| subscription | [`asyncApiSubscription`](#asyncapi-subscription) | `no` | An object used to configure the subscription to messages consumed using the target operation.<br>*Required if `message` has not been set.* |
316
316
| authentication | `string`<br>[`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the AsyncAPI operation. |
317
317
@@ -650,7 +650,15 @@ Provides a mechanism for workflows to await and react to external events, enabli
650
650
651
651
| Name | Type | Required | Description|
652
652
|:--|:---:|:---:|:---|
653
-
| listen.to | [`eventConsumptionStrategy`](#event-consumption-strategy) | `yes` | Configures the event(s) the workflow must listen to. |
653
+
| listen.to | [`eventConsumptionStrategy`](#event-consumption-strategy) | `yes` | Configures the [event(s)](https://cloudevents.io/) the workflow must listen to. |
654
+
| listen.read | `string` | `no` | Specifies how [events](https://cloudevents.io/) are read during the listen operation.<br>*Supported values are:*<br>*- `data`: Reads the [event's](https://cloudevents.io/) data.*<br>*- `envelope`: Reads the [event's](https://cloudevents.io/) envelope, including its [context attributes](https://github.com/cloudevents/spec/blob/main/cloudevents/spec.md#context-attributes).*<br>*- `raw`: Reads the [event's](https://cloudevents.io/) raw data.*<br>*Defaults to `data`.*|
655
+
| foreach | [`subscriptionIterator`](#subscription-iterator) | `no` | Configures the iterator, if any, for processing each consumed [event](https://cloudevents.io/). |
656
+
657
+
> [!NOTE]
658
+
> A `listen` task produces a sequentially ordered array of all the [events](https://cloudevents.io/) it has consumed, and potentially transformed using `foreach.output.as`.
659
+
660
+
> [!NOTE]
661
+
> When `foreach` is set, the configured operations for a [events](https://cloudevents.io/) must complete before moving on to the next one. As a result, consumed [events](https://cloudevents.io/) should be stored in a First-In-First-Out (FIFO) queue while awaiting iteration.
654
662
655
663
##### Examples
656
664
@@ -2038,7 +2046,7 @@ do:
2038
2046
bar: baz
2039
2047
```
2040
2048
2041
-
### AsyncAPI Message
2049
+
### AsyncAPI Outbound Message
2042
2050
2043
2051
Configures an AsyncAPI message to publish.
2044
2052
@@ -2073,6 +2081,29 @@ do:
2073
2081
bar: baz
2074
2082
```
2075
2083
2084
+
### AsyncAPI Inbound Message
2085
+
2086
+
Configures an AsyncAPI message consumed by a subscription.
2087
+
2088
+
#### Properties
2089
+
2090
+
| Name | Type | Required | Description |
2091
+
|:-------|:------:|:----------:|:--------------|
2092
+
| payload | `object` | `no` | The message's payload, if any. |
2093
+
| headers | `object` | `no` | The message's headers, if any. |
2094
+
| correlationId | `string` | `no` | The message's correlation id, if any. |
2095
+
2096
+
#### Examples
2097
+
2098
+
```yaml
2099
+
payload:
2100
+
greetings: Hello, World!
2101
+
headers:
2102
+
foo: bar
2103
+
bar: baz
2104
+
correlationid: '123456'
2105
+
```
2106
+
2076
2107
### AsyncAPI Subscription
2077
2108
2078
2109
Configures a subscription to an AsyncAPI operation.
@@ -2081,8 +2112,15 @@ Configures a subscription to an AsyncAPI operation.
2081
2112
2082
2113
| Name | Type | Required | Description |
2083
2114
|:-------|:------:|:----------:|:--------------|
2084
-
| filter | `string` | `no` | A [runtime expression](dsl.md#runtime-expressions), if any, used to filter consumed messages. |
2115
+
| filter | `string` | `no` | A [runtime expression](dsl.md#runtime-expressions), if any, used to filter consumed [messages](#asyncapi-inbound-message). |
2085
2116
| consume | [`subscriptionLifetime`](#asyncapi-subscription-lifetime) | `yes` | An object used to configure the subscription's lifetime. |
2117
+
| foreach | [`subscriptionIterator`](#subscription-iterator) | `no` | Configures the iterator, if any, for processing each consumed [message](#asyncapi-inbound-message). |
2118
+
2119
+
> [!NOTE]
2120
+
> An AsyncAPI subscribe operation call produces a sequentially ordered array of all the [messages](#asyncapi-inbound-message) it has consumed, and potentially transformed using `foreach.output.as`.
2121
+
2122
+
> [!NOTE]
2123
+
> When `foreach` is set, the configured operations for a [message](#asyncapi-inbound-message) must complete before moving on to the next one. As a result, consumed [messages](#asyncapi-inbound-message) should be stored in a First-In-First-Out (FIFO) queue while awaiting iteration.
2086
2124
2087
2125
#### Examples
2088
2126
@@ -2115,7 +2153,7 @@ Configures the lifetime of an AsyncAPI subscription
2115
2153
#### Properties
2116
2154
2117
2155
| Name | Type | Required | Description |
2118
-
|:-------|:------:|:----------:|:--------------|
2156
+
|:-----|:----:|:--------:|:------------|
2119
2157
| amount | `integer` | `no` | The amount of messages to consume.<br>*Required if `while` and `until` have not been set.* |
2120
2158
| for | [`duration`](#duration) | `no` | The [`duration`](#duration) that defines for how long to consume messages. |
2121
2159
| while | `string` | `no` | A [runtime expression](dsl.md#runtime-expressions), if any, used to determine whether or not to keep consuming messages.<br>*Required if `amount` and `until` have not been set.* |
@@ -2143,4 +2181,54 @@ do:
2143
2181
until: '${ ($context.messages | length) == 5 }'
2144
2182
for:
2145
2183
seconds: 10
2184
+
```
2185
+
2186
+
### Subscription Iterator
2187
+
2188
+
Configures the iteration over each item (event or message) consumed by a subscription. It encapsulates configuration for processing tasks, output formatting, and export behavior for every item encountered.
2189
+
2190
+
#### Properties
2191
+
2192
+
| Name | Type | Required | Description |
2193
+
|:-----|:----:|:--------:|:------------|
2194
+
| item | `string` | `no` | The name of the variable used to store the current item being enumerated.<br>*Defaults to `item`.* |
2195
+
| at | `string` | `no` | The name of the variable used to store the index of the current item being enumerated.<br>*Defaults to `index`.* |
2196
+
| do | [`map[string, task][]`](#task) | `no` | The tasks to perform for each consumed item. |
2197
+
| output | [`output`](#output) | `no` | An object, if any, used to customize the item's output and to document its schema. |
2198
+
| export | [`export`](#export) | `no` | An object, if any, used to customize the content of the workflow context. |
0 commit comments