spring ws configuring thread count for each endpoint

Viewed 185

We have a spring web application that is responsible for 2 services with different endpoints. One is for query and one is for notification((like localhost:8080/query and localhost:8080/notification)).

The problem is, when QUERY web service received too many requests, the system slows down, which also affects the notifications web service. It also slows down.

Is there a way to separate their thread pools in order to prevent them from affecting one another by configuring spring?

Query web service

@Endpoint
@Service
public class RnQueryServiceEndpoint{

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "RNQueryRequest")
    @ResponsePayload
    RNQueryServiceResponse rNQueryServiceRequest(@RequestPayload ProttonRNQueryRequest rNQueryRequest, MessageContext messageContext){
        ... some business logic here
    }
}

Notification Web Service

@Endpoint
@Service
public class NotificationServiceEndpoint {

    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "NotificationRequest")
    @ResponsePayload
    NotificationResponse serveNotificationRequest(@RequestPayload NotificationRequest notificationRequest) {
        .... some business logic here
    }
}
1 Answers

Depending on your underlying server(tomcat,undertow etc...) you can configure the server connections accepted. By default tomcat accepts 200 connections.

) You can create 2 different ThreadPoolTaskExecutors to execute the business logic under each endpoint.

Keep in mind that on a 64bit OS java assigns a 1MB stack for each thread, so make sure that the max threads don't exhaust your jvm memory.

Related