
Prioritization of Transport Agents
Exchange 2007 lets you specify the priority of transport agents that are included with Exchange and that are added by custom applications. If you specify the priority of a transport agent, you can control which agents act on a message first. Transport agents can be assigned a priority of 1 or higher. Transport agents with a priority closer to 1 are applied to messages first. However, the priority that you assign to a transport agent is only one factor that is used to determine the order in which transport agents are applied to messages. The second factor that is used to determine the priority of transport agents is where the SMTP event that has a registered transport agent fits within the sequence of SMTP events.
As shown in Table 1 earlier in this topic, SMTP events have a specific sequence in which they are applied to messages that flow through the transport pipeline. For example, the OnConnectEvent SMTP event always occurs before the OnHeloCommand or OnEhloCommand SMTP events. Because transport agents are registered to specific SMTP events, this means that regardless of the priority that is assigned to a transport agent on the OnEhloCommand SMTP event, transport agents registered on the OnConnectEvent SMTP event will always be applied to messages first.
For example, you may have transport agents configured as follows:
-
Transport agent
AgentA with a priority of 1 registered to the OnEndofHeaders SMTP event
-
Transport agent
AgentB with a priority of 4 registered to the OnMailCommand SMTP event
When you view your list of registered agents by using the Get-TransportAgent cmdlet, transport agent AgentA is listed with a higher priority than transport agent AgentB. However, when a message flows through the transport pipeline, transport agent AgentB will be applied to the message before transport agent AgentA because the OnMailCommand SMTP event encounters the message before the OnEndOfHeaders SMTP event.
The priority that you assign a transport agent becomes relevant when two or more transport agents are registered on the same SMTP event. If transport agent AgentA and transport agent AgentB are both registered on the OnEndofHeaders SMTP event, when a message encounters that event, transport agent AgentA is applied to the message before transport agent AgentB. If transport agent AgentB is registered on both the OnEndOfHeaders and OnMailCommand SMTP events, it will be applied to the message two times. Transport agent AgentB will be applied first, because it is registered to the OnMailCommand SMTP event. Then, when the message encounters the OnEndOfHeaders SMTP event where both transport agent AgentA and transport agent AgentB are registered, transport agent AgentA will be applied because it has a higher priority than transport agent AgentB. Finally, transport agent AgentB will be applied for the second time.