简体   繁体   English

无法使用Solace JMS订阅持久主题

[英]Can't subscribe a durable topic with Solace JMS

I'd like to subscribe a durable topic using Solace JMS API. 我想使用Solace JMS API订阅一个持久性主题。 But when I start my application, it thrown below error: 但是,当我启动应用程序时,它抛出以下错误:

[Context_3_ReactorThread] INFO com.solacesystems.jcsmp.impl.flow.BindRequestTask - Error Response (503) - Max clients exceeded for durable topic endpoint [Context_3_ReactorThread] INFO com.solacesystems.jcsmp.impl.flow.BindRequestTask-错误响应(503)-持久主题端点超出了最大客户端数

I use the latest docker image of solace on centos 7. the image version is solace-pubsub-standard (9.1.0.201). 我在centos 7上使用了solace的最新docker镜像。该镜像版本为solace-pubsub-standard(9.1.0.201)。

Below is my code: 下面是我的代码:

@Bean
public SolConnectionFactory connectionFactory() {
    SolConnectionFactory connectionFactory = new SolConnectionFactoryImpl();
    connectionFactory.setHost("10.69.94.182");
    connectionFactory.setUsername("default");
    connectionFactory.setPassword("default");
    connectionFactory.setVPN("default");
    connectionFactory.setDynamicDurables(true);
    return connectionFactory;
}


@Bean
public DefaultJmsListenerContainerFactory pubSubContainerFactory(ConnectionFactory connectionFactory) {
    DefaultJmsListenerContainerFactory listenerContainerFactory = new DefaultJmsListenerContainerFactory();
    listenerContainerFactory.setConnectionFactory(connectionFactory);
    listenerContainerFactory.setPubSubDomain(true);
    listenerContainerFactory.setSubscriptionDurable(true);
    return listenerContainerFactory;
}



@JmsListener(destination = "com.schindler.ioee.gdcs.Callback", containerFactory = "pubSubContainerFactory")
public void processCallback(Message message) {
    /*message.getHeaders().entrySet().forEach(item -> log.info("{}:{}", item.getKey(), item.getValue()));*/
    log.info("[CONSUMER] topic={}, message={}", message.getHeaders().get("jms_destination"), message.getPayload());

}

I tried to set the max-bind-count for the topic endpoint to 1024, it also throw the above error. 我试图将主题终结点的最大绑定数设置为1024,这也会引发上述错误。

Can any one provide some help. 谁能提供一些帮助。 Thank you in advance! 先感谢您!

The problem was resolved after reading the document https://docs.solace.com/Solace-JMS-API/Creating-Durable-Topic-S.htm . 阅读文档https://docs.solace.com/Solace-JMS-API/Creating-Durable-Topic-S.htm后,该问题已解决。 I have 2 subscription, and I missed to add a subscription in the annotation. 我有2个订阅,但是我想在注释中添加一个订阅。 If the subscription name is missing, spring will use the default name "org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter" as the subscription name. 如果缺少订阅名称,spring将使用默认名称“ org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter”作为订阅名称。 According to the document, one session can't subscribe the same topic endpoint twice. 根据该文档,一个会话不能预订同一主题端点两次。 So an error was thrown. 因此引发了错误。

My finally consumer code looks like below: 我的最终使用者代码如下所示:

@Component
@Slf4j
public class MessageConsumer {

    @JmsListener(destination = "com.schindler.ioee.gdcs.Callback", containerFactory = "pubSubContainerFactory", subscription = "com.schindler.ioee.gdcs.Callback")
    public void processCallback(Message message) {
        // message.getHeaders().entrySet().forEach(item -> log.info("{}:{}", item.getKey(), item.getValue()));
        log.info("[CONSUMER] topic={}, message={}", message.getHeaders().get("jms_destination"), message.getPayload());

    }

    @JmsListener(destination = "com.schindler.ioee.gdcs.Symptom", containerFactory = "pubSubContainerFactory", subscription = "com.schindler.ioee.gdcs.Symptom")
    public void processSymptom(Message message) {
        // message.getHeaders().entrySet().forEach(item -> log.info("{}:{}", item.getKey(), item.getValue()));
        log.info("[CONSUMER] topic={}, message={}", message.getHeaders().get("jms_destination"), message.getPayload());

    }

    @JmsListener(destination = "com.schindler.ioee.gdcs.Equipment", containerFactory = "pubSubContainerFactory", subscription = "com.schindler.ioee.gdcs.Equipment")
    public void processEquipment(Message message) {
        // message.getHeaders().entrySet().forEach(item -> log.info("{}:{}", item.getKey(), item.getValue()));
        log.info("[CONSUMER] topic={}, message={}", message.getHeaders().get("jms_destination"), message.getPayload());

    }


    @JmsListener(destination = "t/cn/rtc/*/status", subscription = "sms_mqtt_subscription", containerFactory = "pubSubContainerFactory")
    public void processStatus(Message message) {
        // message.getHeaders().entrySet().forEach(item -> log.info("{}:{}", item.getKey(), item.getValue()));
        log.info("[CONSUMER] topic={}, message={}", message.getHeaders().get("jms_destination"), new String((byte[]) message.getPayload()));

    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM