UDP Broadcast using BizTalk Server 2010

Recently we had talked about developing an adapter to broadcast data over UDP.  The idea was to develop such an adapter that can be used in private equity firms to receive price data over multicast.

Yesterday I had a chance to try out Dot Net 4.5 (currently in beta) which natively supports UDPBindings.  I never realized broadcasting data over UDP would be such a simple task that I could implemented a send port in a matter of minutes with 0 coding. Well 0 coding to set the port up but may be a few lines of code for the UDP receiver.

Setting up a UDP Send port

In your BizTalk application, create a send port of WCF-Custom Type.  In the General tab, set the End Point Address URI to be

soap.udp://<multicast_address>:<port>

Image

On the Binding Tab, Select the Binding Type to be “udpBinding”.  Leave the defaults as is

Image

Set the other required files and maps on your port and that’s it.  You can now broadcast messages over UDP.

Client Code

Here is the client code that I used to test my UDP Transmission.

            const int GROUP_PORT = 15000;
            //const string IP_ADDRESS = "192.168.56.1";
            const string IP_ADDRESS = "192.168.0.110";
            Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse(IP_ADDRESS), GROUP_PORT);
            listener.Bind(localEndPoint);
            EndPoint ep = (EndPoint)localEndPoint;
            Console.WriteLine("Ready to receive…");
            byte[] data = new byte[1024];
            int recv = listener.ReceiveFrom(data, ref ep);
            string stringData = Encoding.ASCII.GetString(data, 0, recv);
            Console.WriteLine("received: {0} from: {1}", stringData, ep.ToString());
            Console.ReadLine();
            listener.Close();

Its a pure socket based connection and works like a charm.

In my BizTalk application, my UDP Broadcast port was subscribing to a file receive port.  For both ports the pipeline was simple pass through.  I dropped in a simple xml file with data:

<?xml version="1.0" encoding="utf-8"?>
<data>WORKING PARTY</data>

And this is what I received on my client console application:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:MessageID>urn:uuid:9552802b-0168-431f-b694-eff5fed86a47</a:MessageID><a:To s:mustUnderstand="1">soap.udp://192.168.0.110:15000/</a:To></s:Header><s:Body><data>WORKING PARTY</data></s:Body></s:Envelope>
Advertisements
  1. AWESOME!!!

  2. Thanks for this!

  3. Thanks!

  4. nice stuff. Thanks.

  5. I installed Biztalk 2013 Beta on Windows 2008 R2. I also installed .Net Framework 4.5.

    My problem is that when i select WCF_Custom, the UDP Binding is not present in the drop-down combo box on the Bindings tab.

    Any suggestions on how to resolve this?

    • Maarten
    • February 19th, 2013

    After installing, I get a udpAdapterBinding, not a udpBinding binding type, and have to use udp:// instead of soap.udp:// in the address (didn’t seem like a problem).

    However, when trying to send your sample xml, I get following Error: ”

    The adapter failed to transmit message going to send port “UDP_Test” with URL “udp://192.168.201.199:15000/”. It will be retransmitted after the retry interval specified for this Send Port. Details:”System.ArgumentNullException: Value cannot be null.
    Parameter name: key
    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
    at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.CreateChannelFactory[TChannel](IBaseMessage bizTalkMessage)
    at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.InitializeValues(IBaseMessage message)
    at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2..ctor(IBaseMessage message, WcfTransmitter`2 transmitter)
    at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfTransmitter`2.GetClientFromCache(String spid, IBaseMessage message)
    at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfAsyncBatch`2.BatchWorker(List`1 messages)”.”

    • If you are using Net 4.5 then you dont need to install the binding. UDP is native to .NET 4.5.

      I have 2 posts for UDP. One is with Native .Net while the other one is Raw UDP. You need to use soap:udp:// for the native code.

    • Israel
    • May 7th, 2013

    Is anyone having a performance issues while enabling receive location on UDP port.
    every port I’ve tried my CPU jump to 96%.
    Any suggestions?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: