project-husky / husky

Health Usability Key
https://project-husky.github.io/husky/
Eclipse Public License 1.0
15 stars 8 forks source link

Are ConvenienceCommunication and ConvenienceCommunicationCh thread safe? #94

Closed tmorin closed 4 months ago

tmorin commented 7 months ago

Hi,

We are using ConvenienceCommunicationCh to submit document to a Document Registry.

We have concerns about the field ConvenienceCommunication#txnData.

As far we understood, the instance of the field should work only for a single interaction with the Document Registry/Repository.

However, the Spring Bean Scope of ConvenienceCommunicationCh is Singleton.

Therefore, in multi threaded environment, i.e. basic Spring Boot App with REST services, the instance of the txnData field will be shared among many concurrent requests.

This will lead to unexpected changes of the ConvenienceCommunication#txnData from REST request point of view, and therefore failures.

Is my understanding correct?

Shouldn't we prevent concurrent access setting the Prototype Spring Bean Scope for ConvenienceCommunication and ConvenienceCommunicationCh?

Best regards

ch-fuchs commented 7 months ago

We are just experiencing a similar issue with the affinityDomain. This one is also shared in the ConvenienceCommunication class. We faced an error which occured as we wanted to write while another transaction was reading leading to the write operation utilising the read endpoint.

I would however not recommend your proposal to set the scope to prototype. While this solution might work, it will heavily impact the memory as the convenience communication is a heavy weighted bean due to extending the CamelService.

We are in contact with eHS and will keep you updated on a suitable solution.

project-husky-owner commented 4 months ago

solved