Skip to content

jennings/Turbocharged.NSQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turbocharged.NSQ

NuGet

An NSQ .NET client library filled with async happiness.

Usage

Do the normal thing:

PM> Install-Package Turbocharged.NSQ

Producing Messages

var prod = new NsqProducer("nsqd=localhost:4161");
await prod.PublishAsync("my-topic", new byte[] { 1, 2, 3 });

A connection string looks like this:

nsqd=localhost:4150:4151;

Consuming Messages

var cons = NsqConsumer.Create("nsqd=server1:4150; topic=my-topic; channel=my-channel");
await cons.ConnectAndWaitAsync(Handler);

static async Task Handler(Message message, IMessageFinalizer finalizer)
{
    Console.WriteLine("Received: Topic={0}, Channel={1}, MsgLength={2}",
        message.Topic, message.Channel, Message.Data.Length));
    await finalizer.Finish();
}

Connection string values

A connection string looks like this:

nsqd=localhost:4150;

Or, to use nsqlookupd:

lookup1:4161; lookup2:4161;

A connection string must specify either an nsqd endpoint or nsqlookupd endpoints, but not both.

Setting Description
lookupd={endpoints} List of nsqlookupd servers in the form hostname:httpport, e.g., lookup1:4161;lookup2:4161
nsqd={endpoints} A single nsqd servers in the form hostname:tcpport, e.g., nsqd=server1:4150;nsqd=server2:4150
clientId={string} A string identifying this client to the nsqd server
hostname={string} The hostname to identify as (defaults to Environment.MachineName)
maxInFlight={int} The maximum number of messages this client wants to receive without completion

License

The MIT License. See LICENSE.md.

About

An NSQ library for .NET

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages