java - Spring REST template accept headers -
during load testing of 1 of our rest services, start seeing these kind of logs spring's rest template when load increases:
under concurrent load , after 3-4 hours, take header of http request becomes
debug: org.springframework.web.client.resttemplate - setting request take header [text/plain, application/json, application/*+json, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain, text/plain,<and on>, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, <and on>]
eventually calls service using resttemplate start failing 400 error (bad request)
the rest service beingness called accepts string input , has next signature
@requestmapping(value = "/findrecordbyid", method = {requestmethod.post, requestmethod.get }) @responsebody public string findrecordbyid(@requestbody string id) {//method body}
we sending post type of requests service request content of form "someid", e.g. "123"
under lite load, there no issues in calling service.
whats puzzling text/plain, */* maintain getting added list of take headers rest template. why happen?
the rest template bean declaration this:
<bean id="resttemplate" class="org.springframework.web.client.resttemplate"> <constructor-arg> <bean class="org.springframework.http.client.httpcomponentsclienthttprequestfactory"> <property name="readtimeout"> <value>90000</value> </property> <property name="httpclient" ref="resthttpclient" /> </bean> </constructor-arg> </bean> <bean id="resthttpclient" class="org.apache.http.impl.client.defaulthttpclient"> <constructor-arg> <bean class="org.apache.http.impl.conn.poolingclientconnectionmanager"> <property name="defaultmaxperroute"> <value>100000</value> </property> <property name="maxtotal"> <value>100000</value> </property> </bean> </constructor-arg> </bean>
how request beingness created:
string postparams = "\"" + id + "\""; string postresp = resttemplate.postforobject("findrecordbyid",postparams, string.class);
could please seek this:
resttemplate.getmessageconverters().add(new stringhttpmessageconverter()); string postparams = "\"" + id + "\""; string postresp = resttemplate.postforobject("findrecordbyid",postparams, string.class);
java spring rest spring-mvc resttemplate
No comments:
Post a Comment