我想使用Solace JMS API订阅一个持久性主题。但是,当我启动我的应用程序时,它抛出以下错误:
[Context_3_ReactorThread]信息com.solacesystems.jcsmp.impl.flow.BindRequestTask-错误响应(503)-持久主题端点超出了最大客户端数
我在centos 7上使用了最新的solace docker镜像。该镜像版本为solace-pubsub-standard(9.1.0.201)。
下面是我的代码:
@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());
}
我尝试将主题终结点的最大绑定数设置为1024,这也会引发上述错误。
任何人都可以提供一些帮助。预先谢谢你!
答案 0 :(得分:0)
阅读文档https://docs.solace.com/Solace-JMS-API/Creating-Durable-Topic-S.htm后,问题已解决。 我有2个订阅,但是我想在注释中添加一个订阅。如果缺少订阅名称,spring将使用默认名称“ org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter”作为订阅名称。根据该文档,一个会话不能预订同一主题端点两次。因此引发了错误。
我的最终消费者代码如下:
@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()));
}
}