百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
N

NsqSharp

> 编程语言
开源

用于 NSQ 的 .NET 库,这是一个实时分布式消息传递平台

178 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于 NSQ 的 .NET 库,这是一个实时分布式消息传递平台

NsqSharp

      

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:

bash
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

cs
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

…

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:

  • StructureMap (any dependency injection container will work)
  • Newtonsoft.Json (any serialization method can be chosen)
  • NLog (any logger can be used)
  • SQL Server for auditing (See MessageAuditor.cs and TransportAuditHandler.cs in the PointOfSale example)

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.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#messagingnsqservice-bus

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言