none
Transport SDK -- Documentation and Threading questions regarding Private class AgentAsyncContext and IExecutionControl RRS feed

  • Question

  • I'm studying the Transport SDK and it seems that the internal classes work something like this:

    FACTORY OPERATIONS

    1. Create a session object with a working session and therefore a working AgentAsyncContext. IExecutionControl.GetAgentAsyncCallback()

    a.  How is this done?

    1.        Create an Agent and populate session object

    SMTPServer

    1.        Create a SMTPServer object or use an existing one.
    2.        Ensure the Addressbook is populated  (required for the Invoke method)

    AGENT CREATION

    1.        Create something that derives from factory and return something that derives from agent.
      1.         Implement CreateAgent and Close
    2.        Host calls override RoutingFactory.Agent CreateAgent(string typeName, object state)
      1.        This code calls AgentFactory(RoutingAgent xxx)
    3.        Client agent runs CTOR code from factory implementation
    4.        Set RoutingAgent.HostState  to SMTPServer
      1.        Agent.HostStateInternal autofilled
      2.       Agent.HostStateInternal.AssociatedAgent autofilled to this
    5.        Set Agent.Session (type IExecutionControl)
    6.    Call Agent.AddHandler(string eventTopic, Delegate handler) as needed
      1.        Adds handlers to dictionary for a topic.  Topic is a key for the HybridDictionary, which associates to a Multicast delegate that can be called.
    7.    Call Agent.GetAgentAsyncContext()
      1.        Automatically calls threading ops CTOR with this
    8.    When is AsyncComplete called?

    THREADING OPS

    1.    AgentAsyncContext loads Agent in ctor.
      1.        Depends on Agent.Session being populated. 
      2.       Session must have GetAgentAsyncCallback working.
      3.        Allows for functions: Complete, Resume
      4.       Creates multicast delegate AgentAsyncCallback

           ON INVOKE

    1.     Requires ((SmtpServer)this.HostState).AddressBook to be set on RoutingAgent
      1.        This is called when SetRecipientCached is set
    2.    Prepare RecipientCache
      1.        QueuedMessageEventArgs contains MailItem.RecipientCache { get; }
    3.    Call method
    4.    Find the method to invoke by string name.  Return handlers
    5.    Invoke Handlers

    QUESTIONS

    * What is the master (MSFT internal) process that calls Factory.CreateAgent?  How often does it get called?

    * With regard to the Agent class

    -- How does AgentAsyncContext work?

    -- When and how often is Agent.AsyncComplete called?

    -- When does the class go into Synchronous mode?

    -- How does IExecutionControl work?






    Tuesday, May 8, 2012 1:48 AM

Answers

  • Hi Chris,

    Seriously, 2 million per second ?? That's an order of magnitude (or two) higher than any Exchange server I've ever heard of (LOL). You only get so many asynchronous handles to play with BTW (at least on a routing agent, I've never checked on an SMTP agent but it's probably the same / similar), it's 6 per core, so for example 4 cores = 24 handles = 24 threads that can be completing asynchronously.

    The problem with posting here Chris is I think you really need the help of a Microsoft insider / someone from the Exchange development team and nobody with that level of knowledge of transport agent knowledge follows this forum any more that I'm aware of (and even if they do, they're very unlikely to answer for commercial / confidentially reasons). You may need to look at buying some support time from Microsoft and even then (from personal experience I can tell you) it's hard / can take time to actually get to the people with the knowledge you're after.

    Regards,


    Scott Quinn | C# developer & messaging specialist (for hire). Contact me at http://au.linkedin.com/in/scottquinn

    • Marked as answer by ChrisLaMont Thursday, May 10, 2012 1:42 PM
    Wednesday, May 9, 2012 12:01 PM

All replies

  • Hi Chris,

    The Exchange Transport Service calls your DLLs CreateAgent and it's called a lot (but really you don't need to know how or how often it's called to write an agent).

    Chris, you're obviously starting from scratch and as you've probably noticed the documentation on agents is almost non existent (and what there is, is very terse), but the sample code provided with the Transport SDK is actually not too bad. Check out the asynchronous edge / hub samples first and if that doesn't answer your questions for a more detailed example have a look at the AV sample code.

    Regards,


    Scott Quinn | C# developer & messaging specialist (for hire). Contact me at http://au.linkedin.com/in/scottquinn

    Tuesday, May 8, 2012 3:54 AM
  • My situation isn't typical... I'm an Exchange Admin/C# dev who needs to process 2 million 100K messages per second  and need better insight into the threading aspects of this API

     
    Tuesday, May 8, 2012 1:31 PM
  • Hi Chris,

    Seriously, 2 million per second ?? That's an order of magnitude (or two) higher than any Exchange server I've ever heard of (LOL). You only get so many asynchronous handles to play with BTW (at least on a routing agent, I've never checked on an SMTP agent but it's probably the same / similar), it's 6 per core, so for example 4 cores = 24 handles = 24 threads that can be completing asynchronously.

    The problem with posting here Chris is I think you really need the help of a Microsoft insider / someone from the Exchange development team and nobody with that level of knowledge of transport agent knowledge follows this forum any more that I'm aware of (and even if they do, they're very unlikely to answer for commercial / confidentially reasons). You may need to look at buying some support time from Microsoft and even then (from personal experience I can tell you) it's hard / can take time to actually get to the people with the knowledge you're after.

    Regards,


    Scott Quinn | C# developer & messaging specialist (for hire). Contact me at http://au.linkedin.com/in/scottquinn

    • Marked as answer by ChrisLaMont Thursday, May 10, 2012 1:42 PM
    Wednesday, May 9, 2012 12:01 PM