MINA based Application Architecture

It's the question most asked : 'How does a MINA based application look like'? In this article lets see what's the architecture of MINA based application. Have tried to gather the information from presentations based on MINA.

在这个文章中让我们来年nima的应用架构是怎么样的。

下面是一个大概的视图。

A Bird's Eye View :

MINA based Application Architecture_nima

Here, we can see that MINA is the glue between your application (be it a client or a server) and the underlying network layer, which can be based on TCP, UDP, in-VM comunication or even a RS-232C serial protocol for a client.

从图中我们可以看到mina 是介于你的应用层和网络层中的。mina可以被用于tcp,upd,虚拟通信,甚至rs-232c的串型协议客户端开发

You just have to design your application on top of MINA without having to handle all the complexity of the newtork layer.

你只设计你的应用基于nima不用处理复杂的网络层。

Lets take a deeper dive into the details now. The following p_w_picpath shows a bit more the internal of MINA, and what are each of theMINA components doing :

让我更深入的了解mina,下面这个图向我们展示了mina的内部结构和各个组件作用。

MINA based Application Architecture_nima_02

Remote peer--远程访问

 performs I/O 每一个io 访问。ioservice

session 会话

filters incoming and outgoing messages --过滤传入传出的信息。 iofilterchain

application layer ----应用层 iohanlder

 

 

(The p_w_picpath is from Emmanuel Lécharny presentation MINA in real life (ApacheCon EU 2009))

Broadly, MINA based applications are divided into 3 layers

mina大概分为3层

  • I/O Service - Performs actual I/O --处理io
  • I/O Filter Chain - Filters/Transforms bytes into desired Data Structures and vice-versa过滤传入传出的信息。
  • I/O Handler - Here resides the actual business logic --业务逻辑

So, in order to create a MINA based Application, you have to :

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

This is pretty much it.

所以创建一个mina的应用你要做的是:  

 1 创建一个ioservice --接受io访问或者发起io

  2创建过滤器链,过虑请求或者响应

 3.创建一个iohanlder 处理业务处理不同的消息。

 

想要更深入的了解可访问下面两个页面:

You can get a bit deeper by reading those two pages :

Of course, MINA offers more than just that, and you will robably have to take care of many oher aspects, like the messages encoding/decoding, the network configuration how to scale up, etc... We will have a further look at those aspects in the next chapters.

当然mina不仅仅如些,比如消息的编码和解码,网络配置,我们将会在下面的章节中介绍。