Solace JMS issue
We are facing session issue when publishing first message to topic after re-connect and it works fine from 2nd message onwards. PFB the steps we followed
step 1. When application starts, Publish a message to topic , success and received message ID.
step 2. Bring down solace server for 5-10 sec
step 3. Application re-connects , but when trying to publish message to topic again , we get error "Exception occurred while trying to create a Session". This error occurs only for the first message after re-connect and it works fine for subsequent messages.
Issue we observed is that message ID received in step1 and step3 are same which is in-correct. We have tested the same scenario with sol-AMQP/activeMQ-JMS and we do not face any error as we get different message ID after re-connect. There is no issue when receiving the messages in the same scenario.
Solace server version we are using : 9.1.1.12
Solace jms client version: 10.7.0
Could anyone please help us to find the issue here ???
Comments
-
Hi @Havgi,
I tested this out locally and was not able to reproduce the error. Are you setting the Reconnect Retry Attempts + Wait time on the Connection factory or handling the reconnecting manually?Also can you elaborate on what message id you're checking?
If it helps this is the code I used locally that properly reconnected:
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Solace JMS 1.1 Examples: TopicPublisher */ package com.solace.samples; import javax.jms.BytesMessage; import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.Message; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.Topic; import com.solacesystems.jms.SolConnectionFactory; import com.solacesystems.jms.SolJmsUtility; /** * Publishes a messages to a topic using Solace JMS 1.1 API implementation. * * This is the Publisher in the Publish/Subscribe messaging pattern. */ public class TopicPublisher { final String TOPIC_NAME = "pub/sub/plus"; public void run(String... args) throws Exception { String[] split = args[1].split("@"); String host = args[0]; String vpnName = split[1]; String username = split[0]; String password = args[2]; System.out.printf("TopicPublisher is connecting to Solace messaging at %s...%n", host); // Programmatically create the connection factory using default settings SolConnectionFactory connectionFactory = SolJmsUtility.createConnectionFactory(); connectionFactory.setHost(host); connectionFactory.setVPN(vpnName); connectionFactory.setUsername(username); connectionFactory.setPassword(password); connectionFactory.setReconnectRetries(100); // Create connection to the Solace router Connection connection = connectionFactory.createConnection(); // Create a non-transacted, auto ACK session. Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); System.out.printf("Connected to the Solace Message VPN '%s' with client username '%s'.%n", vpnName, username); // Create the publishing topic programmatically Topic topic = session.createTopic(TOPIC_NAME); // Create the message producer for the created topic MessageProducer messageProducer = session.createProducer(topic); // Create the message BytesMessage message = session.createBytesMessage(); message.writeUTF("Hello World BytesMessage"); System.out.printf("Sending message '%s' to topic '%s'...%n", message, topic.toString()); // Send the message // NOTE: JMS Message Priority is not supported by the Solace Message Bus for(int i=0; i<5000; i++) { messageProducer.send(topic, message, DeliveryMode.NON_PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE); System.out.println("Sent successfully. ID " + message.getJMSMessageID()); Thread.sleep(1000); } // Close everything in the order reversed from the opening order // NOTE: as the interfaces below extend AutoCloseable, // with them it's possible to use the "try-with-resources" Java statement // see details at https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html messageProducer.close(); session.close(); connection.close(); } public static void main(String... args) throws Exception { // Check command line arguments if (args.length != 3 || args[1].split("@").length != 2) { System.out.println("Usage: TopicPublisher <host:port> <client-username@message-vpn> <client-password>"); System.out.println(); System.exit(-1); } if (args[1].split("@")[0].isEmpty()) { System.out.println("No client-username entered"); System.out.println(); System.exit(-1); } if (args[1].split("@")[1].isEmpty()) { System.out.println("No message-vpn entered"); System.out.println(); System.exit(-1); } new TopicPublisher().run(args); } }
0 -
Thank you @marc . We are using JNDI and we are setting reconnect retries+wait properties on connection factory as well as Solace_JMS_JNDI_ReconnectRetries property at client side. But it is taking server value when trying to re-connect. Solace_JMS_JNDI_ConnectRetries is working as expected ( it is taking client side value and trying to connect ). But we are not able to understand why client's ReconnectRetries is not overriding server's value.
we are using below JNDI properties at client side
Solace_JMS_JNDI_ReconnectRetryWait
Solace_JMS_JNDI_ConnectRetriesPerHost
Solace_JMS_JNDI_ConnectTimeout
Solace_JMS_JNDI_ConnectRetries
Solace_JMS_JNDI_ReconnectRetriesand all properties are set at connection factory level too. While connecting for the first time , logs shows client side values but when re-connecting , it shows server's value. Expectation is to make re-connect attempt as per the value used in client side. Could you please help us to understand the issue ?? ( Please let me know if you want any other details )
0 -
The application will use the Solace_JMS_JNDI_* properties set on the client side to do the initial connection and JNDI lookup of the Connection Factory object on the Solace broker side. It will then retrieve the properties set in the Connection Factory to create a data connection. On reconnect of the data connection, the reconnect retries property from the Connection Factory are used. More information about the various JMS properties and how they can be configured is available here:
https://docs.solace.com/Solace-JMS-API/Data-Connection-Properti.htm#jms_properties_39190069_3031891 -
thanks for the info @alexmasse!
0