【发布时间】:2018-05-12 01:43:50
【问题描述】:
我想在我的队列上生成内容类型为 application/json 的响应,因为有效负载包含 json 对象。
但是……
不知道为什么我的 spring-stream(基于 RabbitMQ)总是生成带有以下标头的消息(有效负载是正确的并且具有 JSON 格式)。
(view from rabbit ui)
properties:
delivery_mode: 2
headers:
contentType: text/plain
originalContentType: application/json;charset=UTF-8
content_type: text/plain
所以 content_type 等于 text/plain 而不是 application/json;charset=UTF-8。
我尝试在以下配置中设置 content-type:
spring:
cloud:
stream:
default:
content-type: application/json
bindings:
my-channel:
content-type: application/json
destination: my-channel-rs
producer:
exchange-type: direct
max-length: 1000
但没有帮助。
我觉得在正确的响应中,单个标头内容类型应该存在值“application/json”。
但也许我错了?有人能够解释上述行为吗?
【问题讨论】:
标签: spring-cloud-stream spring-rabbit