This particular Java application uses the following dependency and service versions.
- Java 7
- Tomcat 7
- Spring 4.3.6
It has the following method.
public void submitSms(final SmppMoSMS smppMoSMS) {
logger.info("** SMS received from SMSC [{}]", smppMoSMS.toString());
int i = Thread.activeCount();
logger.info("Point 1: Active thread count : [{}]", i);
taskExecutor.execute(new Runnable() {
@Override
public void run() {
try {
logger.info("Thread start ");
logger.debug("SMS routing to URL [{}] [{}]", smppMoSMS.getOperator(), smppMoSMS.getApplicationUrl());
logger.info("SMS routing to URL [{}] [{}]", smppMoSMS.getOperator(), smppMoSMS.getApplicationUrl());
if (smppMoSMS.getApplicationUrl() == null) {
return;
}
HttpEntity<SmppMoSMS> entity = new HttpEntity<>(smppMoSMS, headers);
ResponseEntity<String> response = restTemplate.exchange(smppMoSMS.getApplicationUrl(), HttpMethod.POST, entity, String.class);
if (HttpStatus.OK == response.getStatusCode()) {
logger.info("SMS sending success [{}] [{}] [{}]", smppMoSMS.getOperator(), smppMoSMS.getApplicationUrl(), 200);
} else {
logger.info("SMS sending fail [{}] [{}] [{}]", smppMoSMS.getOperator(), smppMoSMS.getApplicationUrl(), response.getStatusCode());
}
} catch (Throwable e) {
logger.error("SMS sending fail [{}] [{}]", smppMoSMS.getOperator(), smppMoSMS.getApplicationUrl());
logger.error("SMS ROUTING FAIL", e);
}
logger.info("Thread stop ");
}
});
logger.info("Point 2: Active thread count : [{}]", i);
MDC.clear();
}
Related to the TaskExecutor following bean configuration is available:
<bean id="threadPool" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"
destroy-method="destroy">
<property name="corePoolSize" value="5"/>
<property name="maxPoolSize" value="200"/>
<property name="queueCapacity" value="10000"/>
<property name="allowCoreThreadTimeOut" value="true"/>
<property name="waitForTasksToCompleteOnShutdown" value="true"/>
</bean>
Related to the RestTemplate the following bean configurations are available.
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<constructor-arg>
<bean class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory">
<property name="readTimeout" value="30000"/>
<property name="connectTimeout" value="30000"/>
</bean>
</constructor-arg>
</bean>
The high-level issue observation is described below.
Let's say the application is started
Application is functioning as expected including the following operations
- HTTP calls are generated by the restTemplate according to the Tcpdumps and the REST API server logs
- All logs are printed on log files
After 2-3 hours suddenly we can observe the following behaviours of the application.
- HTTP calls are not generated by the restTemplate according to the TcpDumps and the REST API server logs
- Only the following logs are available
2022:10:01 07:17:10.623 INFO [correlationId=1664588830622, sequence=2244] ** SMS received from SMSC [SmppMoSMS{message='Test by developer ', senderAddress='94XXXXXXX', recipientAddress='94XXXXX', encoding='0', operator='XXXXXXXX', ncsType='null', correlationId='1664588830622'}]
2022:10:01 07:17:10.623 INFO [correlationId=1664588830622, sequence=2244] Active thread count : [114]
2022:10:01 07:17:10.623 INFO [correlationId=1664588830622, sequence=2244] Thread stop
2022:10:01 07:17:10.623 INFO [correlationId=1664588830622, sequence=2244] Active thread count : [114]
This "Active thread count" doesn't increase after this.
All the things are getting fine by just an application restart or the whole tomcat server restart. NOTE: This application was in production for several years and we get this issue from the last 2 months only without any code or configuration changes.
I assume new threads are not created even though the configuration allows up to 200 threads.
- What can be the reasons for the above assumptions or the observations?
- Any other assumptions?
- How can I further investigate the issue?
- Any suggestions to fix the issue?