Skip to content

Commit

Permalink
Update clj-camel.core : add new opts to recipient-list and multicast …
Browse files Browse the repository at this point in the history
…macros (#34)
  • Loading branch information
Sergey Nepochatov authored Jun 15, 2021
1 parent f54fbab commit 1e26dac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
21 changes: 15 additions & 6 deletions src/main/clj/clj_camel/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -568,16 +568,19 @@
parallel-processing - if true exchanges processed in parallel
agg-strategy - aggregation strategy to use
delimiter – a custom delimiter to use
ignore-invalid-endpoints - if true ignores the invalidate endpoint exception when try to create a producer with that endpoint
Read more https://camel.apache.org/components/latest/eips/recipientList-eip.html"
[^ProcessorDefinition pd ^Expression expr opts & body]
(let [{:keys [delimiter agg-strategy parallel-processing]} opts]
(let [{:keys [delimiter agg-strategy parallel-processing ignore-invalid-endpoints]} opts]
`(->
~(if delimiter
`(.recipientList ~pd ~expr ~delimiter)
`(.recipientList ~pd ~expr))
~@(core-when (some? agg-strategy) `((.aggregationStrategy ~agg-strategy)))
~@(core-when parallel-processing
`((.parallelProcessing)))
~@(core-when ignore-invalid-endpoints
`((.ignoreInvalidEndpoints)))
~@(concat body `((.end))))))

(defn endpoint
Expand Down Expand Up @@ -618,9 +621,15 @@
(defmacro multicast
"Multicast EIP: Multicasts messages to all its child outputs;
so that each processor and destination gets a copy of the original message to avoid the processors
interfering with each other."
interfering with each other.
Options:
parallel-processing - if true exchanges processed in parallel
timeout - a total timeout specified in millis, when using parallel processing"
[^ProcessorDefinition pd opts & body]
`(-> (.multicast ~pd)
~@(core-when (:parallel-processing opts)
`((.parallelProcessing)))
~@(concat body `((.end)))))
(let [{:keys [parallel-processing timeout]} opts]
`(-> (.multicast ~pd)
~@(core-when parallel-processing
`((.parallelProcessing)))
~@(core-when (some? timeout)
`((.timeout ~timeout)))
~@(concat body `((.end))))))
3 changes: 2 additions & 1 deletion src/test/clj/clj_camel/recipient_list_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
(c/set-body (c/constant "x-token"))
(c/log "x-token requested: ${body}")
(c/recipient-list (c/json-path "$.data.*") {:parallel-processing true
:delimiter ";"}
:delimiter ";"
:ignore-invalid-endpoints true}
(c/set-body (c/constant "result2")))
(c/log "Populate cache with ${body}")
(c/log "x-token result: ${body}")
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/recipient-list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<constant>x-token</constant>
</setBody>
<log id="1" message="x-token requested: ${body}"/>
<recipientList delimiter=";" id="1" parallelProcessing="true">
<recipientList delimiter=";" id="1" parallelProcessing="true" ignoreInvalidEndpoints="true">
<jsonpath>$.data.*</jsonpath>
</recipientList>
<setBody id="1">
Expand Down

0 comments on commit 1e26dac

Please sign in to comment.