All Projects → judwhite → Nsqsharp

judwhite / Nsqsharp

Licence: mit
A .NET library for NSQ, a realtime distributed messaging platform

Projects that are alternatives of or similar to Nsqsharp

azure-service-bus-java
☁️ Java client library for Azure Service Bus
Stars: ✭ 61 (-59.33%)
Mutual labels:  messaging, service-bus
Rebus
🚌 Simple and lean service bus implementation for .NET
Stars: ✭ 1,733 (+1055.33%)
Mutual labels:  service-bus, messaging
Service Bus
PHP Lightweight Message Bus supporting CQRS.
Stars: ✭ 431 (+187.33%)
Mutual labels:  service-bus, messaging
Azure Service Bus Dotnet
☁️ .NET Standard client library for Azure Service Bus
Stars: ✭ 237 (+58%)
Mutual labels:  service-bus, messaging
azure-service-bus-dotnet-plugins
☁️ Plugins for the .NET Standard client library for Azure Service Bus
Stars: ✭ 15 (-90%)
Mutual labels:  messaging, service-bus
Servicebus
Simple service bus for sending events between processes using amqp.
Stars: ✭ 415 (+176.67%)
Mutual labels:  service-bus, messaging
Azure Service Bus
☁️ Azure Service Bus service issue tracking and samples
Stars: ✭ 472 (+214.67%)
Mutual labels:  service-bus, messaging
Im service
golang im server
Stars: ✭ 1,694 (+1029.33%)
Mutual labels:  messaging
Temporal
Temporal service
Stars: ✭ 3,212 (+2041.33%)
Mutual labels:  service-bus
Slimmessagebus
Lightweight message bus interface for .NET (pub/sub and request-response) with transport plugins for popular message brokers.
Stars: ✭ 120 (-20%)
Mutual labels:  messaging
Android yichat lite
android client
Stars: ✭ 118 (-21.33%)
Mutual labels:  messaging
Azure Event Hubs For Kafka
Azure Event Hubs for Apache Kafka Ecosystems
Stars: ✭ 124 (-17.33%)
Mutual labels:  messaging
Vonage Python Sdk
Vonage Server SDK for Python. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Stars: ✭ 134 (-10.67%)
Mutual labels:  messaging
Jsqmessagesviewcontroller
An elegant messages UI library for iOS
Stars: ✭ 11,240 (+7393.33%)
Mutual labels:  messaging
Dontclickshit
Як не стати кібер-жертвою
Stars: ✭ 149 (-0.67%)
Mutual labels:  messaging
Nservicebus
The most popular service bus for .NET
Stars: ✭ 1,816 (+1110.67%)
Mutual labels:  messaging
Messaging Apis
Messaging APIs for multi-platform
Stars: ✭ 1,754 (+1069.33%)
Mutual labels:  messaging
Sandglass
Sandglass is a distributed, horizontally scalable, persistent, time sorted message queue.
Stars: ✭ 1,531 (+920.67%)
Mutual labels:  messaging
Timy Messenger
Timy - open source mobile app for groups to communicate and organize themselves. Built with flutter.
Stars: ✭ 1,745 (+1063.33%)
Mutual labels:  messaging
Magma
The magma server daemon, is an encrypted email system with support for SMTP, POP, IMAP, HTTP and MOLTEN,. Additional support for DMTP and DMAP is currently in active development.
Stars: ✭ 1,740 (+1060%)
Mutual labels:  messaging

NsqSharp

Build status  License  NuGet version  Nuget

A .NET client library for NSQ, a realtime distributed messaging platform.

Check out this slide deck for a quick intro to NSQ.

Watch Spray Some NSQ On It by co-author Matt Reiferson for an under 30-minute intro to NSQ as a messaging platform.

Project Status

  • Used in Production.
  • Maintained. Issues and Pull Requests will be responded to.

Quick Install

NsqSharp is a client library that talks to the nsqd (message queue) and nsqlookupd (topic discovery service). See the slides above for more information about their roles.

Download nsqd.exe and nsqlookupd.exe and run them from the command line:

nsqlookupd

nsqd -lookupd-tcp-address=127.0.0.1:4160

Or, to install as Windows Services:

mkdir c:\nsq\data

copy /y nsqd.exe c:\nsq
copy /y nsqlookupd.exe c:\nsq

sc create nsqlookupd binpath= "c:\nsq\nsqlookupd.exe" start= auto DisplayName= "nsqlookupd"
sc description nsqlookupd "nsqlookupd 0.3.2"
sc start nsqlookupd

sc create nsqd binpath= "c:\nsq\nsqd.exe -mem-queue-size=0 -lookupd-tcp-address=127.0.0.1:4160 -data-path=c:\nsq\data" start= auto DisplayName= "nsqd"
sc description nsqd "nsqd 0.3.2"
sc start nsqd

You can also build these files from source: https://github.com/nsqio/nsq (official), or https://github.com/judwhite/nsq (fork) to add the ability to run as a Windows Service.

C# Examples

PM> Install-Package NsqSharp

More examples are in the Examples folder.

Simple Producer

using System;
using NsqSharp;

class Program
{
    static void Main()  
    {
        var producer = new Producer("127.0.0.1:4150");
        producer.Publish("test-topic-name", "Hello!");

        Console.WriteLine("Enter your message (blank line to quit):");
        string line = Console.ReadLine();
        while (!string.IsNullOrEmpty(line))
        {
            producer.Publish("test-topic-name", line);
            line = Console.ReadLine();
        }

        producer.Stop();
    }
}

Simple Consumer

using System;
using System.Text;
using NsqSharp;

class Program
{
    static void Main()  
    {
        // Create a new Consumer for each topic/channel
        var consumer = new Consumer("test-topic-name", "channel-name");
        consumer.AddHandler(new MessageHandler());
        consumer.ConnectToNsqLookupd("127.0.0.1:4161");

        Console.WriteLine("Listening for messages. If this is the first execution, it " +
                          "could take up to 60s for topic producers to be discovered.");
        Console.WriteLine("Press enter to stop...");
        Console.ReadLine();

        consumer.Stop();
    }
}

public class MessageHandler : IHandler
{
    /// <summary>Handles a message.</summary>
    public void HandleMessage(IMessage message)
    {
        string msg = Encoding.UTF8.GetString(message.Body);
        Console.WriteLine(msg);
    }

    /// <summary>
    /// Called when a message has exceeded the specified <see cref="Config.MaxAttempts"/>.
    /// </summary>
    /// <param name="message">The failed message.</param>
    public void LogFailedMessage(IMessage message)
    {
        // Log failed messages
    }
}

NsqSharp.Bus

The classes in the NsqSharp.Bus namespace provide conveniences for large scale applications:

  • Interoperating with dependency injection containers.
  • Separation of concerns with regards to message routing, serialization, and error handling.
  • Abstracting the details of Producer and Consumer from message sending and handling.

The PingPong and PointOfSale examples highlight using:

Applications initiated with BusService.Start can be installed as a Windows Service using sc create. When in console mode the application will gracefully shutdown with Ctrl+C. When running as a Windows Service stopping the service or rebooting/shutting down the machine will do a graceful shutdown.

NsqSharp has no external dependencies. StructureMap, Autofac, and Newtonsoft.Json are supported through convenience classes which use reflection for the initial wire-up. Other containers and serializers can be used by implementing IObjectBuilder and IMessageSerializer wrappers in your code.

NsqSharp Project Goals

  • Structurally similar to the official go-nsq client.
  • Up to date with the latest stable release of go-nsq.
  • Provide similar behavior and semantics as the official package.
  • Unobtrusive. No external dependencies. Publishing message contracts does not require a reference to NsqSharp.

Pull Requests

Pull requests and issues are very welcome and appreciated.

When submitting a pull request please keep in mind we're trying to stay as close to go-nsq as possible. This sometimes means writing C# which looks more like Go and follows their file layout. Code in the NsqSharp.Bus namespace should follow C# conventions and more or less look like other code in this namespace.

License

This project is open source and released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].