`
lym6520
  • 浏览: 695941 次
  • 性别: Icon_minigender_1
  • 来自: 福建
社区版块
存档分类
最新评论

what's MINA?

    博客分类:
  • JAVA
阅读更多
what's MINA?

Apache MINA is a network application framework which helps users develop high performance and high scalability network applications easily. It provides an abstract ·event-driven · asynchronous API over various transports such as TCP/IP and UDP/IP via Java NIO.

Apache MINA is often called:

    * NIO framework · library,
    * client · server framework · library, or
    * a networking · socket library.

the architecture of MINA based application


a deeper dive into the details


Broadly, MINA based applications are divided into 3 layers
    * I/O Service - Performs actual I/O
    * I/O Filter Chain - Filters/Transforms bytes into desired Data Structures and vice-versa
    * I/O Handler - Here resides the actual business logic

So, how to create a MINA based Application
   1. Create I/O service - Choose from already available Services (*Acceptor) or create your own
   2. Create Filter Chain - Choose from already existing Filters or create a custom Filter for transforming request/response
   3. Create I/O Handler - Write business logic, on handling different messages


Server Architecture

We have seen, MINA based Application Architecture in previous section. Lets focus on Server Architecture. A Server listens on a port for incoming requests, process them and send replies.


    * IOAcceptor listens on the network for incoming connections/packets
    * For a new connection, a new session is created and all subsequent request from IP Address/Port combination are handled in that Session
    * All packets received for a Session, traverses the Filter Chain as specified in the diagram. Filters can be used to modify the content of packets (like converting to Objects, adding/removing information etc). For converting to/from raw bytes to High Level Objects, PacketEncoder/Decoder are particularly useful
    * Finally the packet or converted object lands in IOHandler. IOHandlers can be used to full fill business needs.


Client Architecture


We had a brief look at MINA based Server Architecture, lets see how Client looks like. Clients need to connect to a Server, send message and process the responses.


    * Client first creates an IOConnector (MINA Construct for connecting to Socket), initiates a bind with Server
    * Upon Connection creation, a Session is created and is associated with Connection
    * Application/Client writes to the Session, resulting in data being sent to Server, after traversing the Filter Chain
    * All the responses/messages received from Server are traverses the Filter Chain and lands at IOHandler, for processing

link to user-guide

  • 大小: 27.8 KB
  • 大小: 26.9 KB
  • 大小: 32.6 KB
  • 大小: 24.7 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics