0

描述错误

我只是按照这篇文章https://docs.steeltoe.io/guides/messaging/rabbitmq.html?tabs=cli但不是将数据作为 传递string,而是创建一个custom object 并将其传递到队列中。当我转到MonitorRabbitMQ project并在侦听器上放置一个断点时,它没有命中并且我遇到了一些异常。

重现步骤

重现行为的步骤:

  1. 关注这篇文章https://docs.steeltoe.io/guides/messaging/rabbitmq.html?tabs=cli
  2. 只需创建一个自定义类CustomQueue并在队列中传递它,例如
[Serializable]
    public class CustomQueue
    {
        public string Name { get; set; }
    }
  1. 现在MonitorRabbitMQ project,更改参数类型,例如
[RabbitListener(RECEIVE_AND_CONVERT_QUEUE)]
      public void ListenForAMessage(CustomQueue msg)
      {
          _logger.LogInformation($"Received the message '{msg}' from the queue.");
      }
  1. MonitorRabbitMQ project,我CustomQueue 从 WriteToRabbitMQ 复制并放入MonitorRabbitMQ project
  2. 问题是当我们传递自定义对象时它没有命中,当我们将字符串作为参数传递时它成功命中

预期行为

它应该接收自定义对象

环境(请填写以下信息):

  • 消息传递
  • 视窗
  • 网络核心 3.1
  • Steeltoe.Messaging.RabbitMQ 版本=3.1.2

截图

如果适用,请添加屏幕截图以帮助解释您的问题。

其他上下文或链接

有这个异常

Steeltoe.Messaging.RabbitMQ.Listener.Exceptions.ListenerExecutionFailedException: Listener threw exception
 ---> Steeltoe.Messaging.Converter.MessageConversionException: failed to convert serialized Message content
 ---> System.Runtime.Serialization.SerializationException: Unable to find assembly 'WriteToRabbitMQ, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
   at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
   at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
   at System.Runtime.Serialization.Formatters.Binary.BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
   at System.Runtime.Serialization.Formatters.Binary.BinaryParser.Run()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(BinaryParser serParser, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, Boolean check)
   at Steeltoe.Messaging.RabbitMQ.Support.Converter.SimpleMessageConverter.FromMessage(IMessage from, Type targetType, Object convertionsHint)
   --- End of inner exception stack trace ---
   at Steeltoe.Messaging.RabbitMQ.Support.Converter.SimpleMessageConverter.FromMessage(IMessage from, Type targetType, Object convertionsHint)
   at Steeltoe.Messaging.RabbitMQ.Listener.Adapters.MessagingMessageListenerAdapter.OnMessage(IMessage amqpMessage, IModel channel)
   at Steeltoe.Messaging.RabbitMQ.Listener.AbstractMessageListenerContainer.DoInvokeListener(IChannelAwareMessageListener listener, IModel channel, IMessage message)
   --- End of inner exception stack trace ---
4

0 回答 0