RabbitMQ.Extension
2.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package RabbitMQ.Extension --version 2.0.1
NuGet\Install-Package RabbitMQ.Extension -Version 2.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RabbitMQ.Extension" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RabbitMQ.Extension --version 2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RabbitMQ.Extension, 2.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RabbitMQ.Extension as a Cake Addin #addin nuget:?package=RabbitMQ.Extension&version=2.0.1 // Install RabbitMQ.Extension as a Cake Tool #tool nuget:?package=RabbitMQ.Extension&version=2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
https://gitee.com/znyet/rabbitmq.extension
static void Main(string[] args)
{
var factory = new ConnectionFactory//创建连接工厂对象
{
HostName = "192.168.238.129",//IP地址
Port = 5672,//端口号
UserName = "admin",//用户账号
Password = "123",//用户密码
AutomaticRecoveryEnabled = true,
TopologyRecoveryEnabled = true,
RequestedConnectionTimeout = TimeSpan.FromSeconds(2),
NetworkRecoveryInterval = TimeSpan.FromSeconds(5)
};
//var hosts = new string[] { "192.168.1.1", "192.168.1.2" }; //集群
var conn = new RabbitConnection(factory);
conn.OnError(ex =>
{
Console.WriteLine(ex.Message);
});
conn.OnConnect(() =>
{
Console.WriteLine("连接成功");
});
conn.OnClose(() =>
{
Console.WriteLine("连接断开");
});
conn.Open();
TestWork(conn);
TestPubSub(conn);
TestRouting(conn);
TestTopic(conn);
Console.ReadKey();
}
private static void TestWork(RabbitConnection conn)
{
var producer = conn.CreateProducer(RabbitType.Work);
producer.Bind("test");
Task.Run(() =>
{
while (true)
{
var data = Encoding.UTF8.GetBytes("Work");
producer.TryPublish(data);
Thread.Sleep(1000);
}
});
var consumer = conn.CreateConsumer(RabbitType.Work);
consumer.Bind("test");
consumer.OnReceived((data, id, key) =>
{
var d = Encoding.UTF8.GetString(data);
Console.WriteLine(d);
});
//get message by your
//var msg = consumer.GetMessage();
//var d = Encoding.UTF8.GetString(msg.Item1);
}
private static void TestPubSub(RabbitConnection conn)
{
var queue = "";
var producer = conn.CreateProducer(RabbitType.SubPub);
producer.Bind(queue, "exchange-1");
Task.Run(() =>
{
while (true)
{
var data = Encoding.UTF8.GetBytes("PubSub");
producer.TryPublish(data);
Thread.Sleep(1000);
}
});
var consumer = conn.CreateConsumer(RabbitType.SubPub);
consumer.Bind(queue, "exchange-1");
consumer.OnReceived((data, id, key) =>
{
var d = Encoding.UTF8.GetString(data);
Console.WriteLine(d);
});
}
private static void TestRouting(RabbitConnection conn)
{
var producer = conn.CreateProducer(RabbitType.Routing);
producer.Bind("", "exchange-2");
Task.Run(() =>
{
while (true)
{
var data = Encoding.UTF8.GetBytes("Routing-a");
producer.TryPublish(data, "a");
var data2 = Encoding.UTF8.GetBytes("Routing-b");
producer.TryPublish(data, "b");
Thread.Sleep(1000);
}
});
var consumer = conn.CreateConsumer(RabbitType.Routing);
consumer.Bind("", "exchange-2", new List<string> { "a", "b" });
consumer.OnReceived((data, id, key) =>
{
var d = Encoding.UTF8.GetString(data);
Console.WriteLine(d);
});
}
private static void TestTopic(RabbitConnection conn)
{
var producer = conn.CreateProducer(RabbitType.Topic);
producer.Bind("", "exchange-3");
Task.Run(() =>
{
while (true)
{
var data = Encoding.UTF8.GetBytes("主题a");
producer.TryPublish(data, "t.aa");
var data2 = Encoding.UTF8.GetBytes("主题b");
producer.TryPublish(data2, "t.bb");
Thread.Sleep(1000);
}
});
var consumer = conn.CreateConsumer(RabbitType.Topic);
consumer.Bind("", "exchange-3", new List<string> { "t.#" });
consumer.OnReceived((data, id, key) =>
{
var d = Encoding.UTF8.GetString(data);
Console.WriteLine(d);
});
}
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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. 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 | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- RabbitMQ.Client (>= 6.2.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.