我正试图建立一个通用的服务器,以便始终以相关客户为服务。
结构由4个主要组成部分组成。
- Stateful App Servers
- Stateless Gateway Servers
- Clients
- Queueing Systems and brokers
流程流量
- Client connects to a gateway
- Gateway accepts as sends a session id back to client
- Client sends a message to gateway
- The Gateway writes the request to a Message / Task Queue
- A daemon reads the messages on the Queue and forwards them to the App Server(s) s listening socket
- The App Servers runs the message through its business logic
- The App Server then at a later point sends a related message to the client into the gateway queue
- A thread on the gateway reads the messages in its inbound queue and then sends messages back to clients as identified in the message.
- The gateway maintains a map of Client Session Id to the Client Socket object to forward incoming messages to the Client Sockets
我正在使用 Java网关。 上诉服务器也设在 Java。
我倾向于说,设计像Mongrel2,但我并不完全相信。 我要说的是,这更符合城市航空业中海ium前沿服务器设计(http://urbanairship.com/blog/ 201008/24/c500k-in-action-at-urban-airship/)
My question is: - Is using a thread for reading messages from the inbound queue and then forwarding them to clients a good idea? Is there a better way to handle this?