MassTransit:get 错误不等价 arg 'type' 用于交换,已收到 'fanout' 但当前为 'topic''
MassTransit:get error inequivalent arg 'type' for exchange, received 'fanout' but current is 'topic''
我有 exchange(topic)->(with routing key)exchange(direct)->queue
我的交流主题有名称,例如 "command-exchange"
所以我想向我的交换(主题)指定名称“command-exchange”发送请求
但是我收到错误 "for exchange "command-exchange" fanout but current is topic"
生产者代码:
var endPoint = _mobileServiceBus.Bus.CreateRequestClient<IRequestCommandSocket,IResponseCommandSocket>
(new Uri($"exchange:command-exchange"),TimeSpan.FromSeconds(10));
var response = await endPoint.Request(new
{
Type = "A",
TopicKey = "A.B.C.D"
});
配置代码:
sbc.Message<IRequestCommandSocket>(e => e.SetEntityName(WebSocketMQConst.ExchangeName.SocketCommandExchange));
sbc.Publish<IRequestCommandSocket>(e =>
{
e.ExchangeType = ExchangeType.Topic;
});
sbc.Send<IRequestCommandSocket>(e =>
{
e.UseRoutingKeyFormatter(context => context.Message.TopicKey.ToString());
});
sbc.ReceiveEndpoint("command-queue", e =>
{
e.BindMessageExchanges = false;
e.Bind<IRequestCommandSocket>(a =>
{
a.RoutingKey = "A.B.C.#";
});
e.Consumer<CommandConsumer>(provider);
});
我们需要在 Uri 的末尾添加 ?type=topic
。
我有 exchange(topic)->(with routing key)exchange(direct)->queue 我的交流主题有名称,例如 "command-exchange" 所以我想向我的交换(主题)指定名称“command-exchange”发送请求 但是我收到错误 "for exchange "command-exchange" fanout but current is topic"
生产者代码:
var endPoint = _mobileServiceBus.Bus.CreateRequestClient<IRequestCommandSocket,IResponseCommandSocket>
(new Uri($"exchange:command-exchange"),TimeSpan.FromSeconds(10));
var response = await endPoint.Request(new
{
Type = "A",
TopicKey = "A.B.C.D"
});
配置代码:
sbc.Message<IRequestCommandSocket>(e => e.SetEntityName(WebSocketMQConst.ExchangeName.SocketCommandExchange));
sbc.Publish<IRequestCommandSocket>(e =>
{
e.ExchangeType = ExchangeType.Topic;
});
sbc.Send<IRequestCommandSocket>(e =>
{
e.UseRoutingKeyFormatter(context => context.Message.TopicKey.ToString());
});
sbc.ReceiveEndpoint("command-queue", e =>
{
e.BindMessageExchanges = false;
e.Bind<IRequestCommandSocket>(a =>
{
a.RoutingKey = "A.B.C.#";
});
e.Consumer<CommandConsumer>(provider);
});
我们需要在 Uri 的末尾添加 ?type=topic
。