Reputation: 1358
I am developing a Spring Boot application using reactive programming. I need to apply Spring Expression Language Related logics inside that application. I will mostly use expression parser related approach as mention in this link.
Since my application is reactive, is it ok to put SpEl related code inside a map like below,
return Mono.just(Person("name", "age:12"))
.map { person ->
// SpEl expression parser related logics here
});
or do I need to execute SpEl related logics in a separate thread using an approach like this
Mono blockingWrapper = Mono.fromCallable(() -> {
return /* SpEl expression parser related logics here */
});
blockingWrapper = blockingWrapper.subscribeOn(Schedulers.boundedElastic());
Upvotes: 0
Views: 467
Reputation: 945
It is okay to put to the code for actual parsing in the code in map, however suggest to instantiate the Evaluation Context in the Bean which is calling it and pass it using Closure concepts of lambda method.
This is because SpEL does optimization which will be lost if it gets instantiated every time.
Upvotes: 1