java - Share RestTemplate's MessageConverters across multiple instances -
benchmarks made showed 70% of time creating new resttamplate()
messageconverters
, wondered if it's safe create 1 set of converters , use across multiple instances, different threads.
edit: motivation logging "on wire" traffic. thought implementing using clienthttprequestinterceptor
. since each request should logged different file, thought create new resttemplate each set of requests, different interceptor.
this javadoc of httpmessageconverter
doesn't explicitly require it, intention implementations thread safe. if thread safe, safe use across multiple resttemplate
instances.
resttemplate
other http client use. shouldn't typically need more 1 instance per application. (some exceptions exist proxies, ssl configurations, etc.)
Comments
Post a Comment