Hi,
my question is how i can reuse (or not) the WebTarget of a JaxRs Client
with CXF 3.0.2.
My scenario is roughly like this:
Init:
Client client = ClientBuilder.newBuilder().
register(JacksonJsonProvider.class).
build();
WebTarget target = client.target(baseUrl).path("lights/{lightNum}/{state}");
Then i issue several (thousands) requests like this:
Invocation.Builder builder = target.
resolveTemplate("lightNum", lightNum).
resolveTemplate("state", state).
request();
Response response = builder.put(null);
response.close();
What i see is, that for every request a new WebClient-Object is created and
added to
ClientImpl.baseClients-HashMap.
And finally i can run into OOM-issues.
My question:
- is it ok to reuse the WebTarget for several requests?
- if i close the client and create a new one, this solves this issue. Is
this the intended live-cycle of Client/WebTarget?
Thanks,
Hartmut