使用 EasyNetQ 使用消息时出现异常

Exception in Consuming message with EasyNetQ

我正在使用 easyNetQ 从队列中发布和接收消息,但是..

从队列中获取消息时出现异常。

The server reported 0 messages 
Exchange    ErrorExchange_
type:   EasyNetQ.SystemMessages.Error, EasyNetQ

"RoutingKey":"", "Exchange":"SSO.Login", "Queue":"SSO.Login_SSOQueue.LoginQueue", "Exception":"System.IO.FileNotFoundException: Could not load file or assembly 'OAuth.Admin.Infrastructures.RabbitMQEventBus, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.\r\nFile name: 'OAuth.Admin.Infrastructures.RabbitMQEventBus, Culture=neutral, PublicKeyToken=null'\r\n at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)\r\n at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)\r\n at System.Reflection.Assembly.Load(AssemblyName assemblyRef)\r\n at EasyNetQ.DefaultTypeNameSerializer.GetTypeFromTypeNameKey(TypeNameKey typeNameKey)\r\n at EasyNetQ.DefaultTypeNameSerializer.<>c.b__3_0(String t)\r\n at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory)\r\n at EasyNetQ.DefaultMessageSerializationStrategy.DeserializeMessage(MessageProperties properties, Byte[] body)\r\n at EasyNetQ.RabbitAdvancedBus.<>c__DisplayClass17_0.b__0(Byte[] body, MessageProperties properties, MessageReceivedInfo messageReceivedInfo)\r\n at EasyNetQ.RabbitAdvancedBus.<>c__DisplayClass21_0.b__0(Byte[] body, MessageProperties properties, MessageReceivedInfo receivedInfo)\r\n at EasyNetQ.Consumer.HandlerRunner.InvokeUserMessageHandlerInternalAsync(ConsumerExecutionContext context)\r\n\r\n", "Message":"{\"PhoneNumber\":\"09---------\",\"ApplicationName\":\"somthing\",\"CampaignId\":2}", "DateTime":"2020-01-14T05:37:19.9778013Z",

此程序集在我的 发布者 中,即 单独的应用程序

"Exception":"System.IO.FileNotFoundException: Could not load file or assembly 'OAuth.Admin.Infrastructures.RabbitMQEventBus, Culture=neutral, PublicKeyToken=null'.

问题是我的消费者无法反序列化消息 我在我的消费者中使用此代码,我的问题已解决

protected override Task ExecuteAsync(CancellationToken stoppingToken)
    {
        stoppingToken.ThrowIfCancellationRequested();

        var consumer = new EventingBasicConsumer(_channel);

        consumer.Received += HandleMessageAsync; ;

        _channel.BasicConsume("BlaBlaBlaQueue", false, consumer);
        return Task.CompletedTask;
    }

    private async void HandleMessageAsync(object sender, BasicDeliverEventArgs e)
    {
        var content = System.Text.Encoding.UTF8.GetString(e.Body);
        ConfirmRequest confirmRequest  = JsonConvert.DeserializeObject<ConfirmRequest>(content);

        var result =await sendConfirmBlaBlaBlaResuest.ConfirmBlaBlaBlaAsync(new BlaBlaBlaDto {});
        var responce = new ConfirmBlaBlaBlaResponceEvent(confirmRequest);

        if (result.IsFailure)
        {
            responce.Message = result.Error;
            responce.IsSuccess = false;
        }
        else
        {
            responce.IsSuccess = true;
        }

        await bus.PublishBlaBlaBlaResponceEventAsync(responce);
        _channel.BasicAck(e.DeliveryTag, false);
    }

我的制作人是

public async Task PublishBlaBlaBlaEventAsync(BlaBlaBlaEvent myEvent)
    {
        var exchange = _bus.ExchangeDeclare(rabbitOptions.BlaBlaBlaExchangeName, ExchangeType.Topic);
        var queue = _bus.QueueDeclare(rabbitOptions.BlaBlaBlaQueueName);
        _bus.Bind(exchange, queue, "#");
        var message = new Message<BlaBlaBlaEvent>(myEvent);
        await _bus.PublishAsync(exchange, queue.Name, false, message);
    }