0
votes

I have a spring batch application which populates records into Table A. The next step of the requirement is to group the data in Table A and run a whole bunch of business validation and discrepancy rules on each group. based on the output of the validation rules, data may/may not be written to Table B. This process will be a nightly batch job.

3 approaches I can think of :

  1. Use spring batch and integrate a rule engine into the Itemprocessor.
  2. Use spring batch and implement the validation logic in multiple item
    processors and chain them.
  3. Write a regular spring application, with a rule engine and implement the functionality to manage the process.

Questions : 1. Will spring batch support rule engine ? 2. Which is a better approach ? Or is there another alternative approach ?

All suggestions will be greatly appreciated.

1
Do you have a particular rules engine in mind? Also, how many rules/what are the complexity of them?Michael Minella
I have about 12 rules and some of them are really complex. I need to group the records based on 4 columns, run the validation rule taking each group in its entirety. For example 1 group can have 1000 records, another maybe 50 records.Radhika
So in first group, the rule has to have the 1000 records in hand. <br/> I do not have any rules engine in mind. Was reading up on Drools but not sure if it can be integrated into spring batch. </br> I would like to go with the simplest approach, considering my timelines.Radhika

1 Answers

0
votes

We had a similar situation so, we explored Drools. As per the general guidelines, one will not prefer a rule engine if,

  • the business logic is well-defined and static.
  • the rules are simple and self-contained.
  • the rules are less than 20.
  • the performance is a primary concern.

So, it didn't suit our case. Instead, we written our validation logic in a class and added it along with the Item Processor as a CompositeItemProcessor. e.g

<bean id="compItemProcessor" class="org.springframework.batch.item.support.CompositeItemProcessor"> <property name="delegates"> <list> <ref bean="validatorProcessor"/> <ref bean="ourDataProcessor"/> </list> </property> </bean>