我正在使用Apache activeMQ 5.15.13和Spring Boot 2.3.1.RELEASE。我正在尝试配置持久性订户,但我不能这样做。我的运行时应用程序给我一个错误,
Cause: setClientID call not supported on proxy for shared Connection. Set the 'clientId' property on the SingleConnectionFactory instead.
下面是通过Spring Boot进行的完整activeMQ设置。
JMSConfiguration
public class JMSConfiguration
{
@Bean
public JmsListenerContainerFactory<?> connectionFactory(ConnectionFactory connectionFactory,DefaultJmsListenerContainerFactoryConfigurer configurer)
{
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
// This provides all boot's default to this factory,including the message converter
configurer.configure(factory,connectionFactory);
// You could still override some of Boot's default if necessary.
factory.setPubSubDomain(true);
/* below config to set durable subscriber */
factory.setClientId("brokerClientId");
factory.setSubscriptionDurable(true);
// factory.setSubscriptionShared(true);
return factory;
}
@Bean
public MessageConverter jacksonJmsMessageConverter()
{
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setTargetType(MessageType.TEXT);
converter.setTypeIdPropertyName("_type");
return converter;
}
}
接收器类
public class Receiver {
private static final String MESSAGE_TOPIC = "message_topic";
private Logger logger = LoggerFactory.getLogger(Receiver.class);
private static AtomicInteger id = new AtomicInteger();
@Autowired
ConfirmationReceiver confirmationReceiver;
@JmsListener(destination = MESSAGE_TOPIC,id = "comercial",subscription = MESSAGE_TOPIC,containerFactory = "connectionFactory")
public void receiveMessage(Product product,Message message)
{
logger.info(" >> Original received message: " + message);
logger.info(" >> Received product: " + product);
System.out.println("Received " + product);
confirmationReceiver.sendConfirmation(new Confirmation(id.incrementAndGet(),"User " +
product.getName() + " received."));
}
}
application.properties
spring.jms.pub-sub-domain=true
spring.jms.listener.concurrency=1
spring.jms.listener.max-concurrency=2
spring.jms.listener.acknowledge-mode=auto
spring.jms.listener.auto-startup=true
spring.jms.template.delivery-mode:persistent
spring.jms.template.priority: 100
spring.jms.template.qos-enabled: true
spring.jms.template.receive-timeout: 1000
spring.jms.template.time-to-live: 36000
当我尝试运行应用程序时,出现以下错误
Could not refresh JMS Connection for destination 'message_topic' - retrying using FixedBackOff{interval=5000,currentAttempts=1,maxAttempts=unlimited}. Cause: setClientID call not supported on proxy for shared Connection. Set the 'clientId' property on the SingleConnectionFactory instead.
我的应用程序具有独立的生产者和消费者。我确实尝试了Google的错误,但没有任何帮助。