I am using spring boot to connect to solace queue. I have used below tutorial to connect to the solace JMS queue. https://www.devglan.com/spring-boot/spring-jms-solace-example It is able to make connection to the solace queue. We faced one issue when application is started and connection with solace queue is working fine but after some time solace queue went down then spring boot application should reconnect to solace queue instead of restarting application to connect. To reconnect with solace queue I have added
connectionFactory.setReconnectRetries(-1);
connectionFactory.setReconnectRetryWaitInMillis(3000);
connectionFactory.setConnectRetries(-1);
connectionFactory.setConnectRetriesPerHost(5);
so code will look like below
@Bean
public SolConnectionFactory solConnectionFactory() throws Exception {
SolConnectionFactory connectionFactory = SolJmsUtility.createConnectionFactory();
connectionFactory.setHost(environment.getProperty("solace.java.host"));
connectionFactory.setVPN(environment.getProperty("solace.java.msgVpn"));
connectionFactory.setUsername(environment.getProperty("solace.java.clientUsername"));
connectionFactory.setPassword(environment.getProperty("solace.java.clientPassword"));
connectionFactory.setClientID(environment.getProperty("solace.java.clientName"));
connectionFactory.setReconnectRetries(-1);
connectionFactory.setReconnectRetryWaitInMillis(3000);
connectionFactory.setConnectRetries(-1);
connectionFactory.setConnectRetriesPerHost(5);
return connectionFactory;
}
@Bean
public JmsMessageListener jmsMessageListener() {
return new JmsMessageListener();
}
@Bean(destroyMethod = "close")
public Connection connection() {
Connection connection = null;
javax.jms.Session session;
try {
connection = solConnectionFactory().createConnection();
session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(environment.getProperty("solace.message.consumer.queue"));
MessageConsumer messageConsumer = session.createConsumer(queue);
messageConsumer.setMessageListener(jmsMessageListener());
connection.setExceptionListener(exceptionListener);
connection.start();
logger.info("Connected. Awaiting message...");
} catch (Exception e) {
logger.info("JMS connection failed with Solace." + e.getMessage());
e.printStackTrace();
}
return connection;
}
pom.xml
<dependency>
<groupId>com.solacesystems</groupId>
<artifactId>sol-jms</artifactId>
<version>10.4.0</version>
</dependency>
<dependency>
<groupId>com.solacesystems</groupId>
<artifactId>sol-jcsmp</artifactId>
<version>10.4.0</version>
</dependency>
Here it does not go into exception listener if solace queue connection is interupted and by adding reconnect properties also it does not show in log whether application is reconnecting to solace queue or not. How to reconnect to solace queue if solace queue is up after some time
Kindly help
I recommend checking your log levels. You're configuring the right thing with reconnectRetries, etc.
You should see something like below. I get those logs when running this app: https://github.com/SolaceSamples/solace-samples-spring/blob/master/spring-boot-autoconfig-receiver/src/main/java/com/solace/samples/spring/boot/SpringBootReceiver.java