Limit number of messages sent by BizTalk using WCF-Nettcp adapter RRS feed

  • Question

  • Hi,

    I have a BizTalk application using WCF-Nettcp send adapter that is sending thousand of messages to a service. The requirement is to limit\control this number. Is there any way to configure this value at the Adapter/Host/Host instance level?

    Any information around this will really help.

    Thank you.



    Wednesday, January 15, 2020 12:46 PM

All replies

  • Are you talking about simultaneous connections, or just a limit of messages per time period?

    See this article Tip#3: Use NetTcpBinding instead of bindings that rely on http(s) for high performance in intranet scenario.  

    And on that same page Tip#4 Slow down sending requests to external services using host throttling 

    A quick and dirty way to throttle the messages being sent is to set ordered delivery on the send port, but this has drawbacks as it can cause a backlog of messages and timeout issues.

    If it is limit of messages per time period, then unfortunately you have to code it yourself in your solution.

    Wednesday, January 15, 2020 8:40 PM
  • Hi,

    Thanks for your message.

    My requirement is just to limit the number of messages being sent through WCF-Nettcp Send adapter.



    Thursday, January 16, 2020 2:45 PM
  • Hi Biranchi,

    Some people have recommended using a singleton pattern, but kind of defeats the reason of have a multi threading architecture of BizTalk.

    You can limit the number of messages sent by adjusting the throttling settings on host properties (under Resource Based Throttling tab).

    I would create a sperate host instance for this.

    Hope this helps.

    Samad Khan



    Thursday, January 16, 2020 7:58 PM
  • Another unorthodox approach to concretely control the number of instances for the send port would be to add a "slotting" value to the message context going to the send port.

    1. Create a message context property (just calling it "slot" here)

    2. Upstream of the send port assign the value of "slot" in a receive pipeline pipeline component or orchestration using a value outputted from DateTime.UtcNow.Ticks % maxNumberOfInstances where maxNumberOfInstances is the number you wish to constrain it to. For example DateTime.UtcNow.Ticks % 5 will give an even distribution of of values between 0-4 (5 slots). 

    3. Add any number of WCF-Nettcp send ports identical with the exception of the value of  of "Slot" in the subscription.

    As messages come through they will file to 1 of the 5 send ports.

    This is manageable at low cardinality of ports.

    If the number of instances is high or needs to change based on other conditions use an orchestration that has the "slot" property in a correlation set used in it's activating and following receives. In this case the orchestration would be bound to the send and gets a delivery notification before proceeding. This way you can have an explicit number of instances with the ability to step them up and down at run time by just modifying the value on the receive port config. Just watch that the spool doesn't climb beyond your limits.

    Good luck!

    • Edited by T.Stevens Monday, January 20, 2020 11:09 PM
    Monday, January 20, 2020 11:08 PM