如何检索 Spring 云流消息的本机消息 ID?
How can I retrieve the native message ID of a Spring Cloud Stream Message?
我正在寻找通过 Spring Cloud Stream 从 GCP Pub/Sub 收到的 Message
的本地消息标识符。
我看到 Message
中有一个标识符 Spring Cloud Stream 设置:
/**
* The key for the Message ID. This is an automatically generated UUID and
* should never be explicitly set in the header map <b>except</b> in the
* case of Message deserialization where the serialized Message's generated
* UUID is being restored.
*/
public static final String ID = "id";
但是,我正在寻找 native 消息标识符——GCP Pub/Sub(或其他服务,例如)将设置的标识符。理想情况下,我希望能够使用相同的方法,而不管我的消息要去哪里,并且保持不可知。哪里有合适的地方看,如果有的话?
我不确定您能否有一个完全不可知的解决方案——例如,kafka 没有本地消息 ID 的概念。
id
已保留(spring-messaging)。
看起来 pub/sub 适配器有一个 header 映射器,默认映射所有入站 header。
如果本机 header 不是 id
,它将被映射。
入站通道适配器支持使用自定义映射器(可以将本机 id
映射到其他东西),但活页夹目前似乎不支持将自定义映射器配置到适配器中。
我正在寻找通过 Spring Cloud Stream 从 GCP Pub/Sub 收到的 Message
的本地消息标识符。
我看到 Message
中有一个标识符 Spring Cloud Stream 设置:
/**
* The key for the Message ID. This is an automatically generated UUID and
* should never be explicitly set in the header map <b>except</b> in the
* case of Message deserialization where the serialized Message's generated
* UUID is being restored.
*/
public static final String ID = "id";
但是,我正在寻找 native 消息标识符——GCP Pub/Sub(或其他服务,例如)将设置的标识符。理想情况下,我希望能够使用相同的方法,而不管我的消息要去哪里,并且保持不可知。哪里有合适的地方看,如果有的话?
我不确定您能否有一个完全不可知的解决方案——例如,kafka 没有本地消息 ID 的概念。
id
已保留(spring-messaging)。
看起来 pub/sub 适配器有一个 header 映射器,默认映射所有入站 header。
如果本机 header 不是 id
,它将被映射。
入站通道适配器支持使用自定义映射器(可以将本机 id
映射到其他东西),但活页夹目前似乎不支持将自定义映射器配置到适配器中。