cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

multithreading in populators

Former Member
0 Likes
481

Hi, anyone having idea of implementation of multithreading (asynchronous calls) for populators in hybris.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Hi,

You will need to override the DefaultConverter and use parallelStream instead of stream.

But you have to be really cautious with that and make sure the order of your populator call can be in any order (that means a populator should not depend on the result of another) etc

and replace

 getPopulators() //
 .stream() //
 .filter(Objects::nonNull) //
 .forEach(populator -> populator.populate(s, t));

by

 getPopulators() //
 .parallelStream() //
 .filter(Objects::nonNull) //
 .forEach(populator -> populator.populate(s, t));


I haven't tried it, it can work but with parallelism it very easy to introduce a bug.

Answers (0)