|
| Copyright © Cloud Software Group, Inc. All Rights Reserved |
For example, consider the situation in Figure 14. Mobile employees use laptop computers, connecting to the network whenever time and communications access permit. They run programs that communicate using certified message delivery. Relay agents collect messages on behalf of disconnected client programs, and deliver them when the programs reconnect. Relay agents also store certified delivery protocol state on behalf of their client programs, and resynchronize that state whenever the client reconnects.In Figure 14, solid lines represent continuous connections, while broken lines represent intermittent connections.Figure 14 Relay AgentsOnce a CM transport designates a relay agent, all its communications flow through that relay agent.Relay agents mirror the protocol state associated with certified delivery—including registration state and message confirmation state. When the client is disconnected from the relay agent, their protocol states can diverge; they resynchronize when the client reconnects. The client CM transport is always the master of the protocol state, and the relay agent is the mirror.Relay agents are transparent; that is, the semantics of certified delivery, confirmation, discovery, and registration remain the same, whether or not relay agents are operating. Confirmation indicates that the certified listener has actually received the certified message (relay agents do not generate confirmations on behalf of listening clients).As another example, consider an ephemeral process (such as a UNIX cron job). Each time it starts, it creates a new CM transport object, even though each instance embodies the same persistent correspondent.
− Table 33 summarizes the calls that control relay agent connections—implicitly and explicitly.
• The CM transport receives a RELAY.CONNECTED advisory, informing it of successful contact with the relay agent.(When a CM transport cannot locate its relay agent, it presents a DELIVERY.NO_RESPONSE advisory; however, do not design programs to rely on this side effect.)
• If the client transport is a CM listener, the relay agent ensures that it is listening to the same set of subjects on behalf of the client. The relay agent also updates its confirmation state to reflect the state of the program transport.
• If the client transport is a CM sender, the relay agent updates its acceptance state to reflect the state of the program. The sending client updates its confirmation state to reflect the state of the relay agent.
• If the client transport is a CM listener, the relay agent attempts to synchronize its listening state with the transport (to assure that the relay agent adequately represents the CM listeners of the client).The CM transport stores subsequent outbound events—including data messages and protocol state changes. If the CM transport is a certified sender, it stops requesting delivery confirmation for outstanding unconfirmed messages. (See also, Requesting Confirmation.)
• A CM transport that explicitly disconnects (and is not destroyed) presents a RELAY.DISCONNECTED advisory, informing the program that it is safe to sever the physical network connection. (A CM transport that implicitly disconnects during its destruction sequence will never present this advisory; instead, it is safe to sever the physical connection when the destroy call returns.)To understand the possible sources of delays, consider this worst-case situation. Figure 15 depicts the network arrangement; Figure 16 illustrates the narrative:
1. The CM transport on laptop D listens to the subject foo. When the listener transport connects to its relay agent (RAC), RAC begins listening on its behalf. The listener transport then disconnects from RAC.Figure 15 Relay Agents and Delays: NetworkFigure 16 Relay Agents and Delays: Timing
• Although the listener transport begins listening at step 1, the sender transport does not receive a request for certified delivery until step 4. Messages sent before establishing the certified delivery agreement are not certified for that listener.
• Although the sender transport begins sending certified messages at step 4, it does not receive confirmation until step 6. The message time limit must be longer than this delay, otherwise the message expires before confirmation arrives, and the sender transport presents a DELIVERY.FAILED advisory.Consider the intermittently connected program (A) in Figure 17. A sends a certified request message (for example, a query) and expects a reply message by listening to an inbox name (the reply can be certified or an ordinary message). When A disconnects, it becomes unavailable to receive the reply message.To ensure that the reply arrives properly, the relay agent (RAB) establishes a surrogate inbox name, and substitutes that name as the reply name on the outbound message. When the reply arrives, RAB receives it, and substitutes the original reply inbox name before transferring the reply to A. Figure 17 illustrates this sequence.To see why reply name substitution is important, consider the result without substitution. Suppose instead that A places the reply inbox name in a field of the request message, and sends it without a proper reply name. In this erroneous situation, the relay agent cannot intercept the reply message—so if A is disconnected when the reply is sent, A does not receive the reply.Figure 17 Relay Agents: Reply Name Substitution
|
| Copyright © Cloud Software Group, Inc. All Rights Reserved |