只是在 GitHub 上阅读 RawRabbit 的源代码。看起来有一个 WithSubscriberId(stringsubscriberId) 可供您使用。该subscriberId 设置附加到您设置的队列名称末尾的名称后缀。
队列是使用 QueueConfiguration 类中的 FullQueueName 属性创建的
public string FullQueueName
{
get
{
var fullQueueName = string.IsNullOrEmpty(NameSuffix)
? QueueName
: $"{QueueName}_{NameSuffix}";
return fullQueueName.Length > 254
? string.Concat("...", fullQueueName.Substring(fullQueueName.Length - 250))
: fullQueueName;
}
}
所以只需将subscriberId 设置为一个空字符串。
client.SubscribeAsync<string>(async (msg, context) =>
{
Console.WriteLine("Recieved: {0}", msg);
}, cfg=>cfg.WithQueue(q=>q.WithName("ha.test")).WithSubscriberId(""));
类似的东西。我的 PC 上没有 .NET Core,所以我无法验证它,所以请随时告诉我它不起作用。
UPDATED
Fixed the code as suggested by NewToSO's comment