From 1e26dac222964dc075d743cdc11de7a502f8071f Mon Sep 17 00:00:00 2001 From: Sergey Nepochatov Date: Tue, 15 Jun 2021 10:24:35 +0300 Subject: [PATCH] Update clj-camel.core : add new opts to recipient-list and multicast macros (#34) --- src/main/clj/clj_camel/core.clj | 21 +++++++++++++------ .../clj/clj_camel/recipient_list_test.clj | 3 ++- src/test/resources/recipient-list.xml | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/clj/clj_camel/core.clj b/src/main/clj/clj_camel/core.clj index 76b472f..29b038b 100644 --- a/src/main/clj/clj_camel/core.clj +++ b/src/main/clj/clj_camel/core.clj @@ -568,9 +568,10 @@ 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) @@ -578,6 +579,8 @@ ~@(core-when (some? agg-strategy) `((.aggregationStrategy ~agg-strategy))) ~@(core-when parallel-processing `((.parallelProcessing))) + ~@(core-when ignore-invalid-endpoints + `((.ignoreInvalidEndpoints))) ~@(concat body `((.end)))))) (defn endpoint @@ -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)))))) diff --git a/src/test/clj/clj_camel/recipient_list_test.clj b/src/test/clj/clj_camel/recipient_list_test.clj index 0eaafdb..c03ee7b 100644 --- a/src/test/clj/clj_camel/recipient_list_test.clj +++ b/src/test/clj/clj_camel/recipient_list_test.clj @@ -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}") diff --git a/src/test/resources/recipient-list.xml b/src/test/resources/recipient-list.xml index cfee9d9..604880b 100644 --- a/src/test/resources/recipient-list.xml +++ b/src/test/resources/recipient-list.xml @@ -6,7 +6,7 @@ x-token - + $.data.*