2

I have this code to refactor which contains multiple flows all doing the same tasks. Planning to modify it as a generic flow executed in an iterative way with different start parameters. How can i achieve this in mule.

ex:
<flow name="flow1">
    <db:select/>//some specific query for retrieval from  database
    <expression-component/> Exceutes some specific method of spring bean
</flow>

Similar to flow 1 there are numerous flow which does the same logic retrieves data from some table and execute a bean method on basis of query . How can i refactor this code to a generic flow so that it executes iteratively with initialized parameters(table name , method to execute).

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
NAZAR REHMAN
  • 179
  • 3
  • 19

2 Answers2

0

1.There is no need of making it generic you'll end up with same number of nodes which share same db connection

2.for making it generic 2.1 create a flow variable with same name before calling this flow(where ever yo are calling) 2.2 flow variable value has the query 2.3 access the flow variable value in

0

What you can do is, you can create a subflow that will have the DB component, and this subflow will be invoked from different Mule flow and execute the DB component which will use a flow variable that contain dynamic SQL queries .. something like the following :-

<db:select config-ref="Generic_Database_Configuration">
  <db:dynamic-query>#[flowVars.selectQuery]</db:dynamic-query>
  </db:select>

Here #[flowVars.selectQuery] will be filled with different SQL queries from different flows

Anirban Sen Chowdhary
  • 8,233
  • 6
  • 39
  • 81