-
1. Re: Is 'ClientSession' only safe to use from the thread that creates it?
jbertram Jul 13, 2014 11:06 PM (in response to gkopff)My question is: does this mean that it can only be used by the thread that created it?
No.
Or, does it mean that it must only be used by a single thread at a time?
Yes.
By extension, does the same then apply to the consumer and/or producer created by the session?
Yes.
If I have a thread-pool of service handlers (think: servlet thread pool) and wish to publish a message, what would be the correct approach to take?
If you are in a Java EE application server (e.g. JBoss AS or WildFly) then the best option would be to use a <pooled-connection-factory> and "create" the connection, session, and producer each time you need to send a message (or batch of messages). This is because the pooled-connection-factory maintains a pool of connections behind the scenes so "creating" a connection just grabs one from the pool. Aside from this you can implement your own pooling strategy to avoid anti-patterns. You are certainly never obligated to employ an anti-pattern.
-
2. Re: Is 'ClientSession' only safe to use from the thread that creates it?
gkopff Jul 13, 2014 11:54 PM (in response to jbertram)Hi Justin.
Thank you for clearing that up.
Regarding your EE comment, I'm not running in a container - but now I understand the synchronisation requirements I'm good to proceed. Thank you again.
Off-topic: I believe you saw I sent a pull request to enhance some documentation a bit - if there's anything I should be doing differently in terms of submissions, please let me know.
Kindest regards,
--
Greg.