0

In the documentation I see the following sentence:

A Session object can be used on only a single thread at any one time. (Source)

Does this mean that if my application is multi-threaded, and if my ISession objects are accessible for multiple threads, that I have to lock ISession objects whenever I use them so these objects are accessed synchronously?

I use ISession objects when Sending messages (here I'm in a multi-threaded context, so should I lock ISession objects here?)

Example code:

var textMessage = _session.CreateTextMessage(message);
producer.Send(textMessage);
Ozkan
  • 3,880
  • 9
  • 47
  • 78
  • You can always create new Session object in a different thread – subbaraoc Jul 03 '18 at 08:47
  • I don't want to create Session object whenever I have to send messages. These sessions are created during app init, and I re-use them. This because creation of Connection and Session objects are time consuming – Ozkan Jul 03 '18 at 08:58
  • Then you will have to synchronize the session object and lock is a way to do it – subbaraoc Jul 03 '18 at 10:18

0 Answers0