1
votes

I have an application based on Apache Mina 2.0.4 in which I am using ExecutorFilter to create a thread on message_received event.

I found that in production environment, at some point of time ExecutorFilter is not creating threads. Instead it blocks the request message.

Can any one guide on how to properly use ExecutorFilter? I am expecting up to 100 simultaneously connections to my application.

This is my class which override ExecutorFilter class-

public class OneIExecutorFilter extends ExecutorFilter {

    public OneIExecutorFilter(IoEventType...eventTypes){
        super(eventTypes);
    }

    @Override
    public void sessionCreated(NextFilter nextFilter, IoSession session)
            throws Exception {      
        super.sessionCreated(nextFilter, session);
    }   

    @Override
    protected void fireEvent(IoFilterEvent event) {             
        super.fireEvent(event);     
    }   
}
2

2 Answers

0
votes

You're probably running out of threads. Try using the ExecutorFilter(int maximumPoolSize, IoEventType... eventTypes) constructor with maximumPoolSize set to more than 100.

0
votes

You don't have to override ExecutorFilter that way. Try this instead:

final int min = 1;
final int max = Integer.MAX_VALUE;

// RE: java.util.concurrent.Executors.newCachedThreadPool()
Executor executor = new ThreadPoolExecutor(min, max, 60, TimeUnit.SECONDS, 
    new SynchronousQueue<Runnable>())

ExecutorFilter ef = new ExecutorFilter(executor);