After update from SpringBoot v.2.5.5 to v3.1.0 it was necessary to update also ConnectionFactory
from javax.jms.ConnectionFactory
to jakarta.jms.ConnectionFactory
.
I haven't changed anything else. Unfortunately now I'm getting an errors like this:
ERROR - Could not refresh JMS Connection for destination 'tServerEvent' - retrying using FixedBackOff{interval=5000, currentAttempts=0, maxAttempts=unlimited}. Cause: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: no further information
I investigated it and compared with the old javax.ConnectionFactory
and it seems that default brokerUrl
for them is different
for javax.jms.ConnectionFactory
it was : vm://localhost?broker.persistent=false
for jakarta.jms.ConnectionFactory
it is : tcp://localhost:61616
Even if I manually set broker url, like this:
spring:
activemq:
broker-url: vm://localhost?broker.persistent=false
it is not working still and the error is: Cause: Could not create Transport. Reason: java.io.IOException: Transport scheme NOT recognized: [vm]
I don't know why the default brokerUrl is different for jakarta.ConnectionFactory and old javax.ConnectionFactory and don't know how can I run my application succesfullt. I would appreciate if you have some tips for me.
And here is code with JmsListenerContainerFacroty
Bean with ConnectionFactory:
import jakarta.jms.ConnectionFactory;
import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerContainerFactory;
@Configuration
@EnableJms
public class JmsConfig {
@Bean
public JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
configurer.configure(factory, connectionFactory);
return factory;
}
}
Support for ActiveMQ was removed in Spring Boot 3.0 as is did not support JMS 3.0 (the jakarta.jms.*
APIs). Spring Boot 3.1 restored support for auto-configuring an ActiveMQ client. Embedded broker support has not been restored as ActiveMQ's broker does not yet support JMS 3.0.
To use ActiveMQ will Spring Boot 3.1, you will have to use an external broker as Spring Boot's ActiveMQ smoke test does.