I am using UPA 22.214.171.124 Java library for interacting with Elektron and wondering whether this library is thread safe - can client application trying to send requests simultaneously?
I am trying to send MarketDataRequest (DomainType=MARKET_PRICE) from two different threads and getting sporadic exception inside library - like Null Pointer & Index out of bound etc. So would like to know whether library is thread-safe or whether application should synchronize code and allow only one message to send at a time?
ETA (the rebranded name of UPA) is thread-safe and thread-aware. The behavior depends on the locking model that the application is using.
For more information, please refer to 9.2.3 Transport Locking Models in the ETA Java Developers Guide.
From the usage description, it should have at least Channel locking.
Hi @jirapongse.phuriphanvichai ,
Thanks for pointing to Developer Guide section for locking related details.
After going over details I got to know that library itself is not threadsafe but provided certain configuration option to lock the library. By threadsafe library/API is refer when multiple thread can access API & application dont have to acquire any lock because API is stateless. I see that there are class level buffers are used which maintain state causing multiple threads not to access API without locking.
I tried enabling glocalLocking(True) and channelReadLocking & channelWriteLocking but was still facing issue of data getting overwritten as multiple threads were trying to send subscription request at same time. For now I synchronized subscribe & unsubscribe (MarketPriceHandler) methods to make sure only single thread is accessing API.
Thanks for your help.