JN.RabbitMQClient
1.0.1
See the version list below for details.
dotnet add package JN.RabbitMQClient --version 1.0.1
NuGet\Install-Package JN.RabbitMQClient -Version 1.0.1
<PackageReference Include="JN.RabbitMQClient" Version="1.0.1" />
paket add JN.RabbitMQClient --version 1.0.1
#r "nuget: JN.RabbitMQClient, 1.0.1"
// Install JN.RabbitMQClient as a Cake Addin #addin nuget:?package=JN.RabbitMQClient&version=1.0.1 // Install JN.RabbitMQClient as a Cake Tool #tool nuget:?package=JN.RabbitMQClient&version=1.0.1
JN.RabbitMQClient
Simple implementation of RabbitMQ consumer and sender.
Install
Download the package from NuGet:
Install-Package JN.RabbitMQClient
Usage
First, you must create the consumer and then define delegates for onStopReceive
and onMessageReceived
. The consumer will start running when Start
is called and until Stop
is called.
static void Main(string[] args)
{
Consumer c = new Consumer
{
Host = "localhost",
Password = "123",
Username = "teste",
QueueName = "teste",
VirtualHost = "Testes",
Description = "test client",
PrefetchCount = 1
};
c.onStopReceive += StopReceive;
c.onMessageReceived += MessageReceived;
c.Start("test consumer....");
Console.WriteLine("Started...");
Console.ReadLine();
c.Stop();
Console.WriteLine("Stopped...");
Console.ReadLine();
}
private static Constants.MessageProcessInstruction MessageReceived(string message, string sourcequeuename, long firsterrortimestamp, string consumerdescription)
{
Console.WriteLine("Message received: " + message);
return Constants.MessageProcessInstruction.OK;
}
private static void StopReceive(string queuename, string lasterrordescription, string consumerdescription)
{
Console.WriteLine("Stop receiving on queue " + queuename + "; last error: " + lasterrordescription);
}
In MessageReceived
the returned Constants.MessageProcessInstruction
will define how the message will be processed (accept, requeue, ignore).
The Sender
can be used as in the following example.
public class ResponseProcessor
{
private readonly BrokerConfig _config;
public ResponseProcessor(BrokerConfig config)
{
_config = config;
}
public Result ProcessResponse(NotificationResponse response)
{
var res = new Result();
try
{
var sender = GetSender(_config);
var objStr = GetJSONFromObject(response);
sender.Send(objStr);
res.Success = true;
}
catch (Exception ex)
{
res.Success = false;
res.ErrorCode = -100;
res.ErrorDescription = ex.Message;
}
return res;
}
private ISender GetSender(BrokerConfig config)
{
var sender = new Sender
{
Host = config.Host,
Username = config.Username,
Password = config.Password,
VirtualHost = config.VirtualHost,
Port = config.Port,
QueueName = config.RoutingKeyOrQueueName,
ExchangeName = config.Exchange,
ShuffleHostList = config.ShuffleHostList
};
return sender;
}
private string GetJSONFromObject<T>(T objectToSerialize)
{
string json = JsonConvert.SerializeObject(objectToSerialize);
return json;
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.5 is compatible. netstandard1.6 was computed. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 1.5
- NETStandard.Library (>= 1.6.1)
- RabbitMQ.Client (>= 5.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.5.1 | 131 | 2/16/2024 |
2.5.0 | 139 | 2/14/2024 |
2.4.3.1 | 462 | 11/2/2022 |
2.4.3 | 500 | 7/19/2022 |
2.4.2 | 457 | 5/23/2022 |
2.4.1 | 441 | 4/20/2022 |
2.4.0 | 611 | 2/7/2022 |
2.3.4 | 309 | 12/28/2021 |
2.3.3 | 408 | 10/14/2021 |
2.3.2 | 334 | 3/17/2021 |
2.3.0 | 529 | 9/4/2020 |
2.2.1 | 545 | 6/6/2020 |
2.2.0-beta.1 | 311 | 5/24/2020 |
2.2.0-beta | 330 | 5/15/2020 |
2.1.1 | 478 | 4/14/2020 |
2.1.0 | 502 | 12/19/2019 |
2.0.0 | 503 | 11/16/2019 |
1.0.1 | 542 | 6/30/2019 |
1.0.0 | 616 | 4/23/2019 |
possibility to create the queue in the sender