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);
}
}