Durante alcuni test di carico di uno dei nostri servizi REST, si comincia a vedere questo tipo di registri per modello REST di primavera, quando il carico aumenta:modello Primavera RESTO accettare intestazioni
Sotto un carico concomitante e dopo 3-4 ore, l'intestazione Accept della richiesta http diventa
DEBUG: org.springframework.web.client.RestTemplate - Setting request Accept header to [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 so on>, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, */*, <and so on>]
alla fine tutti le chiamate a questo servizio utilizzando RestTemplate iniziare in mancanza con 400 errore (richiesta non valida)
il servizio REST chiamato accetta una stringa come input e ha la seguente firma
@RequestMapping(value = "/findRecordById", method = {RequestMethod.POST, RequestMethod.GET })
@ResponseBody
public String findRecordById(@RequestBody String id) {//method body}
Stiamo inviando tipo POST di richieste per questo servizio con richiesta di contenuto del modulo "QualcheID", per esempio "123"
Sotto carico leggero, non ci sono problemi nella chiamata del servizio.
Whats puzzling è il text/plain, */* che continua ad essere aggiunto all'elenco delle intestazioni di accettazione per il modello REST. Perché succede?
La dichiarazione modello chicco di REST è come questo:
<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>
Come si crea la richiesta:
String postParams = "\"" + id + "\"";
String postResp = restTemplate.postForObject("findRecordById",postParams, String.class);
prego ci mostra un esempio di una richiesta si effettua con il 'RestTemplate' .. –
curato la questione per mostrare come un richiesta effettuata –
Quindi ottieni 'restTemplate' direttamente da' ApplicationContext' senza ulteriori modifiche? E invii tonnellate di richieste come sopra? –