当我将新用户添加到
IdentiyServerService
以下内容
MassTransit
调用代码:
var newUserCreated = new UserCreated
{
UserId = userId.ToString(),
Name = user.Name
};
await _bus.Publish(newUserCreated);
我的目的地是我的
ProfileService
接收此事件的方式
RabbitMq
。
我的
RabbitMq
my中的配置
Startup.cs
(IdentiyServerService)
private static void ConfigureBus(ContainerBuilder builder)
{
builder.Register(context =>
{
return Bus.Factory.CreateUsingRabbitMq(config =>
{
var host = config.Host(new Uri("rabbitmq://localhost"), h =>
{
h.Username("guest");
h.Password("guest");
});
});
}).As<IBus, IBusControl, IPublishEndpoint>().SingleInstance();
}
我这样启动公共汽车
//Startup.cs IdentityServerService
var container = containerBuilder.Build();
var busControl = container.Resolve<IBusControl>();
busControl.Start();
my中的配置
配置文件服务
看起来几乎一样。区别在于,我在
启动。cs公司
(ProfileService)
config.ReceiveEndpoint(host, "user_queue", ep =>
{
ep.Consumer<UserCreatedConsumer>(); // The consumer is registered explicitly this time.
});
我添加一个
IConsumer
也
public class UserCreatedConsumer : IConsumer<UserCreated>
{
public Task Consume(ConsumeContext<UserCreated> context)
{
var user = context.Message;
Debug.WriteLine("My debug string here");
return TaskUtil.Completed;
}
}
创建新用户时,消息将接收
RabbitMq
(发布速率增加)。但是什么都没发生。中的消息总数
Queued messages
不会改变。
我有两个连接(我希望
IdentityServerService
和
配置文件服务
)我有不同的队列(我只希望有一个:
user_queue
)
当我实施
I消费者
在我的内部
IdentityServer服务
我收到消息。
我没有错误日志、警告或其他内容。
无论如何1) 为什么
配置文件服务
没有收到消息?2) 为什么我要排这么多队?
如果您需要更多信息。。。请告诉我
编辑
当我在rabbitMq管理中发送消息时
配置文件服务
收到一条消息,但现在我发现以下错误
MassTransit.Messages Error: 0 : R-FAULT
rabbitmq://localhost/user_queue_new Value cannot be null.
Parameter name: source,
System.Runtime.Serialization.SerializationException: An exception occurred while deserializing the message envelope ---> System.ArgumentNullException: Value cannot be null.
Parameter name: source