I have two services Regular and Adhoc and they both can be invoked concurrently, later it will process method will get the corresponding objects for DB and Kafka using mapstruct mapper and save them to DB/push to kafka.
AdhocService{
@Autowired
ProcessPayload processPayload;
processPayload.process(payload);
}
RegularService{
@Autowired
ProcessPayload processPayload;
processPayload.process(payload);
}
ProcessPayload{
process(Payload payload){
dbObject = payload -> dbObjectMapper
DBopertion(dbObject);
kafkaObject = payload -> kafkaObjectMapper
KAFKAopertion(kafkaObject);
}
}
Can Springboot's singleton bean support this concurrent execution without any issue? If not then what is the alternative? - creating two beans of ProcessPayload and inject them using @Qualifier? I checked this but not able to interpret it specifically.