[
https://issues.apache.org/jira/browse/CXF-8547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17356060#comment-17356060
]
Andriy Redko commented on CXF-8547:
-----------------------------------
[~thanhj] the documentation is correct, by default `client.getRequestContext()`
is set PER INSTANCE and sharing `client` instance between threads is, in
general, not thread-safe. The documentation suggests creating the pool of
clients, fe using `org.apache.commons.pool2.ObjectPool` from [1]. Having the
pool of clients, it is possible to borrow one per thread / context in case of
Spring Reactor [2]. I hope it is helpful.
[1]
[https://commons.apache.org/proper/commons-pool/apidocs/org/apache/commons/pool2/ObjectPool.html]
[2] https://projectreactor.io/docs/core/release/reference/#context
> How to use org.apache.cxf.endpoint.Client->requestContext thread-safe
> ---------------------------------------------------------------------
>
> Key: CXF-8547
> URL: https://issues.apache.org/jira/browse/CXF-8547
> Project: CXF
> Issue Type: Wish
> Reporter: Thanh Nguyen
> Priority: Major
>
> From the official CXF Q&A
> [https://cxf.apache.org/faq.html#FAQ-AreJAX-WSclientproxiesthreadsafe?] about
> WSClientProxythreadsafe, I understand that thread-safe is not possible to
> `org.apache.cxf.endpoint.Client->requestContext`.
> That being said, I cannot override ListHeader to the RequestContext and use
> them concurrently especially in the Spring Reactor manner.
> Example:
> {code:java}
> // code placeholder
> Client client = ClientProxy.getClient(...);
> client.getRequestContext().put(Header.HEADER_LIST, List.of(identityHeader));
> {code}
> So my question is, do you have any suggestions on how to overcome it? The
> document suggested using a "pool of instances" but do we have a better way?
> If not, do we have any example case using of "pool of instances".
--
This message was sent by Atlassian Jira
(v8.3.4#803005)