by BehindJava

An Introduction to Apache Mina Server

Home » java » An Introduction to Apache Mina Server

In this tutorial we are going to understand Apache Mina Server briefly.

Apache MINA (Multipurpose Infrastructure for Network Application) is an open source Java network application framework. MINA can be used to create scalable, high performance network applications. MINA provides unified APIs for various transports like TCP (Connected Protocol), UDP (Connectionless Protocol), serial communication. It also makes it easy to make an implementation of custom transport type. MINA provides both high-level and low-level network APIs.

MINA is a network framework that has been specifically designed to work either on the client side and on teh server side. Writing a server make it critical to have a scalable system, which is tunnable to fit the server needs, in term of performance and memory usage : this is what MINA is good for, still making it easy to devlop you server.

MINA is a network framework that has been specifically designed to work either on the client side and on the server side. Writing a server make it critical to have a scalable system, which is tunnable to fit the server needs, in term of performance and memory usage : this is what MINA is good for, still making it easy to devlop you server.

Blocking IO and Non-Blocking IO

In BIO, you send a request, and you wait until you get the response. On the server side, it means one thread wil be associated with any incoming connection, so you won’t have to deal with the complexity of multiplexing the connections. In NIO, you don’t call and wait for a result, you send a command and you are informed when the result is ready.

When to use MINA?

MINA is probably a good choice as it allows you to develop a server or a client easily, without having to deal with the various parameters and use cases to handle when writing the same application on top of BIO (Blocking IO) or NIO(Non-Blocking IO)

The BIO is faster than NIO when the number of users (connections) are low. but if the number of connections increases, BIO not able to handle all the requests because BIO not able to handle so much number of threads. At that point NIO is the best. Now, one other aspect is that the time spent in the MINA part of your code is probably non significant, compared to whatever your application will consumme. At some point, it’s probably not worthful to spend many times more energy writing a faster network layer on your own for a gain which will be barely noticable.

MINA comes with various implemented existing protocols : HTTP, XML, TCP, LDAP, DHCP, NTP, DNS, XMPP, SSH, FTP… At some point, MINA can be seen not only as a NIO framework, but as a network layer with some protocol implementation.

Features

  • Unified APIs for various transports (TCP/UDP etc.)
  • Provides high/low level APIs
  • Customizable Thread Model
  • Easy Unit Testing using Mock Objects
  • Integration with DI frameworks like Spring, Google Guice, picocontainer
  • JMX Manageability