An NSQ .NET client library filled with async
happiness.
Do the normal thing:
PM> Install-Package Turbocharged.NSQ
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;
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();
}
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 |
The MIT License. See LICENSE.md
.