Search in sources :

Example 1 with NioDatagramAcceptor

use of org.apache.mina.transport.socket.nio.NioDatagramAcceptor in project camel by apache.

the class Mina2Consumer method setupDatagramProtocol.

protected void setupDatagramProtocol(String uri, Mina2Configuration configuration) {
    boolean minaLogger = configuration.isMinaLogger();
    List<IoFilter> filters = configuration.getFilters();
    address = new InetSocketAddress(configuration.getHost(), configuration.getPort());
    acceptor = new NioDatagramAcceptor();
    // acceptor connectorConfig
    configureDataGramCodecFactory("Mina2Consumer", acceptor, configuration);
    acceptor.setCloseOnDeactivation(true);
    // reuse address is default true for datagram
    if (configuration.isOrderedThreadPoolExecutor()) {
        workerPool = new OrderedThreadPoolExecutor(configuration.getMaximumPoolSize());
    } else {
        workerPool = new UnorderedThreadPoolExecutor(configuration.getMaximumPoolSize());
    }
    acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter(workerPool));
    if (minaLogger) {
        acceptor.getFilterChain().addLast("logger", new LoggingFilter());
    }
    appendIoFiltersToChain(filters, acceptor.getFilterChain());
    if (configuration.getSslContextParameters() != null) {
        LOG.warn("Using datagram protocol, " + configuration.getProtocol() + ", but an SSLContextParameters instance was provided.  SSLContextParameters is only supported on the TCP protocol.");
    }
}
Also used : UnorderedThreadPoolExecutor(org.apache.mina.filter.executor.UnorderedThreadPoolExecutor) OrderedThreadPoolExecutor(org.apache.mina.filter.executor.OrderedThreadPoolExecutor) InetSocketAddress(java.net.InetSocketAddress) ExecutorFilter(org.apache.mina.filter.executor.ExecutorFilter) LoggingFilter(org.apache.mina.filter.logging.LoggingFilter) IoFilter(org.apache.mina.core.filterchain.IoFilter) NioDatagramAcceptor(org.apache.mina.transport.socket.nio.NioDatagramAcceptor)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 IoFilter (org.apache.mina.core.filterchain.IoFilter)1 ExecutorFilter (org.apache.mina.filter.executor.ExecutorFilter)1 OrderedThreadPoolExecutor (org.apache.mina.filter.executor.OrderedThreadPoolExecutor)1 UnorderedThreadPoolExecutor (org.apache.mina.filter.executor.UnorderedThreadPoolExecutor)1 LoggingFilter (org.apache.mina.filter.logging.LoggingFilter)1 NioDatagramAcceptor (org.apache.mina.transport.socket.nio.NioDatagramAcceptor)1