私はここに何かがないと思います。メッセージタイプとしてカスタムオブジェクトを受け入れることができる簡単なウサギのリスナーを作成しようとしています。今度はドキュメントごとにウサギリスナーを使用したSpring AMQPコンバータの問題
1.6より前のバージョンでは、JSONを変換するための型情報がメッセージヘッダーで提供されなければならなかったし、カスタムClassMapperが必要でした。バージョン1.6より、型情報ヘッダーがない場合、型は、対象メソッド引数から推論できます。
私は私の設定がCaused by: org.springframework.messaging.converter.MessageConversionException: Cannot convert from [[B] to [com.example.Customer] for GenericMessage [payload=byte[21], headers={amqp_receivedDeliveryMode=NON_PERSISTENT, amqp_receivedRoutingKey=customer, amqp_deliveryTag=1, amqp_consumerQueue=customer, amqp_redelivered=false, id=81e8a562-71aa-b430-df03-f60e6a37c5dc, amqp_consumerTag=amq.ctag-LQARUDrR6sUcn7FqAKKVDA, timestamp=1485635555742}]
のように、ダッシュボードにウサギのMQ ADMを使用してキューに入れるために、手動での取得中にエラーがメッセージを入れています
:
@Bean
public ConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory("localhost");
connectionFactory.setUsername("test");
connectionFactory.setPassword("test1234");
connectionFactory.setVirtualHost("/");
return connectionFactory;
}
@Bean
RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
return rabbitTemplate;
}
@Bean
public AmqpAdmin amqpAdmin() {
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory());
return rabbitAdmin;
}
@Bean
public Jackson2JsonMessageConverter jackson2JsonMessageConverter() {
return new Jackson2JsonMessageConverter();
}
はまた、質問はこの例外メッセージが置かれていないされてキューに戻る。
私はamqp 1.6.1をもたらすスプリングブート1.4を使用しています。
Edit1:上記のようにjackson converterを追加しました(春の起動時にprobは必要ありません)。rmq adminにcontenty typeが与えられていますが、まだ下にあります。ブートを使用している場合(それが唯一のコンバータだ限り)
Caused by: org.springframework.messaging.converter.MessageConversionException: Cannot convert from [[B] to [com.example.Customer] for GenericMessage [payload=byte[21], headers={amqp_receivedDeliveryMode=NON_PERSISTENT, amqp_receivedRoutingKey=customer, content_type=application/json, amqp_deliveryTag=3, amqp_consumerQueue=customer, amqp_redelivered=false, id=7f84d49d-037a-9ea3-e936-ed5552d9f535, amqp_consumerTag=amq.ctag-YSemzbIW6Q8JGYUS70WWtA, timestamp=1485643437271}]
現在のブートバージョンは1.4.4です。 –
私は上記のように同じエラーを出しました。 – user3444718
非常に簡単なBootアプリケーションの例として、私の編集をご覧ください。 '>まだリスナーコンテナを設定していません.'それが本当であれば、変換例外をどのように得ることができるのかは不明です。 –