如何将 JWT 附加到 JMS 消息?

How to attach a JWT to a JMS message?

我们需要在每条 JMS 消息旁边发送一个 JWT 令牌。除了将其打包到有效负载本身之外,我不确定附件或 headers 是否可以在 JMS and/or ActiveMQ 消息结构中使用。

已查看 ActiveMQMessage 但未找到附件或 headers。

我建议您查看 JMS 文档,特别是 the documentation on messages 上面写着:

JMS messages are composed of the following parts:

  • Header - All messages support the same set of header fields. Header fields contain values used by both clients and providers to identify and route messages.
  • Properties - Each message contains a built-in facility for supporting application-defined property values. Properties provide an efficient mechanism for supporting application-defined message filtering.
  • Body - The JMS API defines several types of message body, which cover the majority of messaging styles currently in use.

简而言之,使用一个属性。 JMS 中不存在附件。

上述文档详细说明了必要的 API 调用以设置 属性。