将启用会话的消息发送到高级服务总线不起作用

问题描述 投票:0回答:1

我使用 com.azure.spring:spring-cloud-azure-starter-servicebus-jms:4.7.0 将消息发送到 Azure 服务总线中的队列,使用 Spring JmsTemplate、Spring Boot 版本 2.6.8。正如此处所讨论的,您需要在消息上设置 JMSXGroupID 属性,以便将其发送到启用了会话的队列。

我正是这样做的,当我将消息发送到标准层服务总线中的队列时,它工作得很好。

当使用相同的代码向高级服务总线发送请求时,我收到以下错误消息:

Caused by: org.apache.qpid.jms.provider.ProviderException: The SessionId was not set on a message, and it cannot be sent to the entity. Entities that have session support enabled can only receive messages that have the SessionId set to a valid value. Reference:b555fb0f-abef-4c8e-a1e3-16f3040ef2a0, TrackingId:ae38db690000043a00056bc2647dfc26_G5S1_B22S1, SystemTracker:queuenamehere, Timestamp:2023-06-05T15:15:50 [condition = amqp:not-allowed] at org.apache.qpid.jms.provider.amqp.AmqpSupport.convertToNonFatalException(AmqpSupport.java:181) ~[qpid-jms-client-0.53.0.jar:na] at org.apache.qpid.jms.provider.amqp.AmqpFixedProducer.applyDeliveryStateUpdate(AmqpFixedProducer.java:252) ~[qpid-jms-client-0.53.0.jar:na] at org.apache.qpid.jms.provider.amqp.AmqpFixedProducer.processDeliveryUpdates(AmqpFixedProducer.java:223) ~[qpid-jms-client-0.53.0.jar:na]

队列和服务总线资源是通过 terraform 脚本创建的,以确保一切都完全相同。

我期望我的应用程序能够将消息发送到高级服务总线上启用会话的队列。我还做了一些调试,并确保该属性实际上是在传出消息上设置的。

我有一个消息生成器 bean,它具有以下方法(jmsTemplate 是自动装配的):

private void sendMessageToQueue(Queue queue, Object payload, boolean setGroupId)
{
    jmsTemplate.convertAndSend(queue, payload, (Message message) ->
    {
        if (setGroupId)
        {
            setGroupId(message);
        }
        return message;
    });
}

setGroupId 方法如下所示:

void setGroupId(Message message)
{
    try
    {
        message.setStringProperty("JMSXGroupID","0");
    }
    catch (JMSException e)
    {
        LOG.error("Setting of JMSXGroupID failed with exception: {}", e.getMessage());
    }
}
java azure servicebus
1个回答
0
投票

这是SDK的问题。将 yml 文件中的定价层参数设置为“标准”而不是“高级”“修复”了该问题。

© www.soinside.com 2019 - 2024. All rights reserved.