cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to send data to multiple targets based on condition?

dineshhome1361_7
Participant
0 Kudos

Hello Team,

I have a scenario where the data of Four APIs are merged and sent by the source in a single file. Based on the existence of certain node, I need to decide whether I can to send to the particular target or not.

Below is the sample file:

input.xml

Below are the criteria:

If Element1 exist then send to Target1 else do not send to Target1

If Element2 exist then send to Target2 else do not send to Target2

If Element3 exist then send to Target3 else do not send to Target3

If Element4 exist then send to Target4 else do not send to Target4

Is there any way to send to multiple targets based on condition in CPI?

If this can be achieved in groovy, please share the sample code on how to call HTTP URL

Thanks,

Dinesh

dineshhome1361_7
Participant
0 Kudos

Hi Barath,

Since all the nodes are unbounded , splitter will complicate the solution even more.

I want to send the data as a whole if the node exist else no need to send

(For E.g.) If I have 2 Element1 and 2 Element2 nodes from the source then send data to Target1 and Target2 alone and leave the target 3 &4

Thanks for your inputs. Will hear from others if there are any options without splitting

Thanks,

Dinesh

maik_bosch
Contributor
dinesh.95

And what about using a cascade of Routers (or only one if sufficient)?

So check e.g. via XPATH if a node exists and then forward via Sequental or parallel multicast to Target 1 and Target 2.

Or put a second router behind the first router to decide if Target 1 and 2 are needed or only Target 1

dineshhome1361_7
Participant
0 Kudos

Hi Maik,

Thanks a lot, this works.

Could you please add this as seperate answer so that I can accept and close the thread

Thanks,

Dinesh

Accepted Solutions (1)

Accepted Solutions (1)

maik_bosch
Contributor
0 Kudos

dinesh.95

And what about using a cascade of Routers (or only one if sufficient)?

So check e.g. via XPATH if a node exists and then forward via Sequental or parallel multicast to Target 1 and Target 2.

Or put a second router behind the first router to decide if Target 1 and 2 are needed or only Target 1

maik_bosch
Contributor

Happy to hear it works 🙂

Answers (0)