handler and consumer handler objects that run in separate threads and route messages from one or more remote suppliers to one or more remote consumers, respectively. When a supplier handler thread receives a message from a remote supplier, it uses an address field in the message to determine the corresponding consumer handler, whose thread then delivers the message to its remote consumer. When suppliers and consumers reside on separate hosts, the Gateway uses the connection-oriented TCP [1] protocol to provide reliable message delivery and end-to-end flow control. TCP’s flow control algorithm blocks fast senders when they produce messages more rapidly than slower receivers can process the messages. The entire Gateway should not block, however, while waiting for flow control to abate on outgoing TCP connections. To minimize blocking, therefore, each consumer handler can contain a thread-safe message queue that buffers new routing messages it receives from its supplier handler threads. One way to implement a thread-safe Message Queue is to use the Active Object pattern [2], which decouples the thread used to invoke a method from the thread used to execute the method. As shown in Figure 2, each message queue active object contains a bounded buffer and its own thread of control that maintains a queue of pending messages. Using
更多
查看译文
关键词
active object,object behavioral pattern,concurrent programming