question

Upvotes
Accepted
3 2 3 1

Is UPA library threadsafe?

Hi,


I am using UPA 3.5.1.0 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?

Thanks,
Satish

elektronrefinitiv-realtimeelektron-sdkrrteta-apielektron-transport-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
45.2k 103 43 60

@Satish.Pawar

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.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
3 2 3 1

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.

Satish

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.