I have a Spring Boot app with an embedded queue. I'm using the spring-boot-starter-artemis
dependency and trying to upgrade my Java app.
I could not find any guide, and a few things are not clear, e.g.:
Checking if a queue exist
EmbeddedJMS:
jmsServer.getJMSServerManager().getBindingsOnQueue(queueName).length > 0
Can it be:
jmsServer.getActiveMQServer().isAddressBound(queueName)
or maybe:
jmsServer.getActiveMQServer().bindingQuery(SimpleString.toSimpleString(queueName)).isExists()
Creation of queue:
jmsServer.getJMSServerManager().createQueue(true, queueName, null, true, queueName)
with params (boolean storeConfig, String queueName, String selectorString, boolean durable, String... bindings)
Is it the same like:
QueueConfiguration queueConfiguration = new QueueConfiguration(queueName);
queueConfiguration.setDurable(true);
return jmsServer.getActiveMQServer().createQueue(queueConfiguration, true).isEnabled();
(added) Getting address:
jmsServer.getJMSServerManager().getAddressSettings(address);
is the same like:
jmsServer.getActiveMQServer().getAddressSettingsRepository().getMatch(address);
Not sure how migration Connection Factory settings
final Configuration jmsConfiguration = new ConfigurationImpl();
jmsConfiguration.getConnectionFactoryConfigurations()
.add(new ConnectionFactoryConfigurationImpl()
.setName("cf")
.setConnectorNames(Collections.singletonList("connector"))
.setBindings("cf"));
embeddedActiveMQ.setConfiguration(jmsConfiguration);
To check if a queue exists I think the simplest equivalent solution would be:
server.locateQueue("myQueue") != null
To create a queue the simplest equivalent solution would be:
server.createQueue(new QueueConfiguration("myQueue")) != null
The queue will be durable by default so there's no reason use setDurable(true)
.
To get address settings you use this (as you suspect):
server.getAddressSettingsRepository().getMatch(address);
Regarding connection factories, you don't actually need to configure connection factories on the broker. You simply need to configure the properties for the InitialContext
for your JNDI lookup. See this documentation for more details on that.