Skip to content

Instantly share code, notes, and snippets.

@bleroy
Last active January 16, 2016 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bleroy/8935596f8518e41281d2 to your computer and use it in GitHub Desktop.
Save bleroy/8935596f8518e41281d2 to your computer and use it in GitHub Desktop.
Tips for the Week in .NET

Please comment below...

Package of the week: NATS client

Microservices and IoT both require distributed architectures where a large number of endpoints communicate fast and reliably. NATS is a popular high-performance cloud-based messaging system that is an excellent fit for such scenarios. The .NET client for NATS can publish over 3 million messages per second (and that's in a VM, on a developer laptop).

Here's how you'd send a simple object on the message bus, with a subject “foo”:

using (var cnx = new ConnectionFactory().CreateEncodedConnection())
{
    cnx.Publish("foo", new Company
    {
        Name = "Apcera",
        Address = "140 New Montgomery St."
    });
}

Other actors can asynchronously subscribe to the same subject and process objects:

using (var cnx = new ConnectionFactory().CreateEncodedConnection()) {
    using (cnx.SubscribeAsync("foo", (sender, args) => {
        var company = (Company)args.ReceivedObject;
        Console.WriteLine($"Name: {company.Name}, Address: {company.Address}");
    })) {
        System.Console.WriteLine("Waiting for a message...");
        Thread.Sleep(5000);
    }
}

You can read more about the NATS .NET client in NATS In Microsoft .NET.

.NET

ASP.NET

@zihotki
Copy link

zihotki commented Jan 13, 2016

https://github.com/zihotki/LFEG - a library to export data to Excel, comparing to existing libraries it's many times faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment