title: Processing french response taking time
body: <p>I have a stream as below .I am getting french response from http-api i see lot of time difference .I am using some message converter  for utf-8.</p>
  
  <p>If the response from http  is english I see that it process in 5 min for french its  20 min.Not sure if http-client  or json processor taking time or json creation taking time.</p>
  
  <p>file|xml-parser-processor|custom-http-client|json processor>queue</p>
  
  <p>queue>http-client|processor| >queue2</p>
  
  <p>My http client is like below</p>
  
  <pre><code>&lt;/beans:bean&gt;
  
   &lt;beans:bean  id="batchRestTemplate" class="test.batch.httpclient.BatchRestTemplate" &gt;
     &lt;beans:constructor-arg name="requestTimeOut" value="${requestTimeOut}"/&gt;
      &lt;beans:constructor-arg name="maxConnectionPerRoute" value="${maxConnectionPerRoute}"/&gt;
      &lt;beans:constructor-arg name="totalMaxConnections" ref="${totalMaxConnections}"/&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code> &lt;int-http:outbound-gateway id='batch-http'  header-mapper="headerMapper"
                                 request-channel='toHttp'
                                 rest-template="batchRestTemplate"
                                 url-expression="payload.contains('${filterAttribute}') ? '${url1}' : '${url2}'"  http-method="${httpMethod}"
                                 expected-response-type='java.lang.String' charset='${charset}'
                                 reply-timeout='${replyTimeout}' reply-channel='output'&gt;
      &lt;/int-http:outbound-gateway&gt;
  
  
  public BatchRestTemplate(Integer requestTimeOut,Integer totalMaxConnections,Integer maxConnectionPerRoute) throws NoSuchAlgorithmException  {
            super(createBatchHttpRequestFactory());
          List&lt;HttpMessageConverter&lt;?&gt;&gt; messageConverters= new ArrayList&lt;HttpMessageConverter&lt;?&gt;&gt;();
          messageConverters.addAll(getMessageConverters());
          messageConverters.add(0,new StringHttpMessageConverter(Charset.forName("UTF-8")));
          setMessageConverters(messageConverters);
  
  }
  </code></pre>
  
  <p>My processor</p>
  
  <pre><code>  JSONObject jsonData = new JSONObject(payload.getPayload());
              byte[] msgCont = convertMsgContToBytes(jsonData);
  
  
  String emailRequest = new JSONObject(
                                  generateEMailRequest(payload, actualRecord))
                                          .toString();
                          result = MessageBuilder.withPayload(emailRequest)
                                  .copyHeaders(payload.getHeaders())
                                  .setHeader(MESSAGE_TEXT, msgCont).build();
  
  
  
  
      private byte[] convertMsgContToBytes(JSONObject jsonData)
              throws EmailSMSProcessorException {
          byte[] msgCont = null;
          if (null != jsonData) {
              try {
                  msgCont = jsonData.getJSONObject(MSG_CONTENT).toString()
                          .getBytes(UTF_8);
              } catch (UnsupportedEncodingException e) {
                  LOGGER.error("Error in converting Msg Content to Byte[]", e);
                  throw new EmailSMSProcessorException(e);
              } catch (JSONException e) {
                  LOGGER.error("Error in converting Msg Content to Byte[]", e);
                  throw new EmailSMSProcessorException(e);
              }
          }
          return msgCont;
      }
  
  
  
  private void validatePayload(Message&lt;String&gt; payload, String actualRecord)
              throws EmailSMSProcessorException {
          if (null != actualRecord) {
              JSONObject jsonData = null;
              try{
                  jsonData = new JSONObject(payload.getPayload());
              }catch(Exception e){
                  throw new EmailSMSProcessorException(
                                                       "payload/mandatory data is missing",CONST_SYS_EXPTN);
              }
              validateErrorIdText(jsonData);
          } else {
              throw new EmailSMSProcessorException(
                      "payload/mandatory data is missing",CONST_SYS_EXPTN);
          }
      }
  
  
  private EmailRequest generateEMailRequest(Message&lt;String&gt; payload,
              String actualRecord) throws EmailSMSProcessorException {
          EmailRequest emailReq = null;
          if (null != actualRecord) {
              JSONObject jsonPayload = new JSONObject(payload.getPayload());
              JSONObject actualJSON = new JSONObject(actualRecord);
  
              emailReq = new EmailRequest();
              MessageRecipients messageRecipients = new MessageRecipients();
  
              if (jsonPayload.has(MSG_CONTENT)) {
                  JSONObject msgCntJson = jsonPayload.getJSONObject(MSG_CONTENT);
                  if (msgCntJson.has(SUBSTI_CONTENT)) {
                      String substitutionContent = jsonPayload
                              .getJSONObject(MSG_CONTENT).get(SUBSTI_CONTENT)
                              .toString();
                      JSONObject substitutionContentJSONObj = new JSONObject(
                              substitutionContent);
                      messageRecipients.setSubstitutionKeyValueData(
                              substitutionContentJSONObj);
                  }
              }
  
              Recipient recipient = new Recipient();
              recipient.setEmailAddress(isNullCheckMandatoryFields(
                      actualJSON.getString(CNTCT_PNT_ADR_TXT),
                      CNTCT_PNT_ADR_TXT));
              messageRecipients.setRecipient(recipient);
  
              MessageKeyValueData messageKeyValData = new MessageKeyValueData();
              messageKeyValData.setAlertType(isNullCheckMandatoryFields(
                      actualJSON.getString(ALRT_TYPE_CD), ALRT_TYPE_CD));
              messageKeyValData.setAlertTrackingId(isNullCheckMandatoryFields(
                      actualJSON.getString(DLVRY_ID), DLVRY_ID));
              messageKeyValData.setIsDraft((getMessageProperties()!=null &amp;&amp; getMessageProperties().getEnvironmentVar()!=null &amp;&amp; !getMessageProperties().getEnvironmentVar().equalsIgnoreCase(ENVIORNMENT_PROD))?true:false);
              messageRecipients.setMessageKeyValueData(messageKeyValData);
  
              MessageEml message = new MessageEml();
              String templId = actualJSON.getString(TMPL_ID);
              String chnlType = actualJSON.getString(CHNL_TYPE);
              String msgFormat = jsonPayload.getJSONObject(MSG_ATTRIBUTE)
                      .get(MSG_FORMAT).toString();
              message.setTemplateId(
                      templId + UNDER_SCORE + chnlType + UNDER_SCORE + msgFormat);
  
              message.setUseDraftTemplate((getMessageProperties()!=null &amp;&amp; getMessageProperties().getEnvironmentVar()!=null &amp;&amp; !getMessageProperties().getEnvironmentVar().equalsIgnoreCase(ENVIORNMENT_PROD))?true:false);
              MessageRecipients[] messageRecipientsAry = new MessageRecipients[1];
              messageRecipientsAry[0] = messageRecipients;
              String substitutionKeyValueData = jsonPayload
                      .getJSONObject(MSG_CONTENT).get(TMPL_CONTENT).toString();
              JSONObject substitutionKeyValueDataObj = new JSONObject(
                      substitutionKeyValueData);
  
              emailReq.setMessageRecipients(messageRecipientsAry);
              emailReq.setMessage(message);
              emailReq.setSubstitutionKeyValueData(substitutionKeyValueDataObj);
          }
          return emailReq;
      }
  </code></pre>
  
  <p>Update 2:</p>
  
  <p>This is not with any french or english.Its on msg size as my http-client  son output bigger payload this happens.For 2 kb its  fast  like 30k msg per min and 2k msg per min if msg size is 26 kb.Is it because of serilization? below is code where i construct  json and send to output channel as string.I am passing response again in header message header also has 26kb same from http1 response</p>
  
  <p>Update 3
  I was passing payload  header with my http response which is 26 kb.I removed it now i see very good performance almost matching as before.</p>
  
  <p>Should i compress my header and send using kyro+ deflate zip?</p>
  
  <p>Also CPU is high</p>