Hi!
I have a master slave Artemis configuration with shared file system, and
when I try to simulate a shut down failure a get the following WARN in my
log:
WARN [client.fail] AMQ212037: Connection failure has been detected:
AMQ119815: The connection was disconnected because of server shutdown
[code=DISCONNECTED]
The problem is that I don't receive any Exception in my client, so I can not
failover to the slave broker. I have implemented MessageListener and
ExceptionListener in my client. Is there a way to realize this WARN?? This
is my client code:
@Service
public class TopicMessageConsumer implements
MessageListener,ExceptionListener, InitializingBean, DisposableBean {
@Value("${activemq.broker-url}")
private String activeMqBrokerUri;
@Value("${activemq.user}")
private String username;
@Value("${activemq.password}")
private String password;
@Value("${activemq.topic}")
private String topicDestination;
private Connection connection;
private Session session;
private long ms=0;
private String[] urlConnections = null;
MessageConsumer consumer = null;
private void createConnection() {
boolean connectionCreated = false;
int i = 0;
while(!connectionCreated) {
try {
System.out.println(String.format("Connecting
to: %s",
urlConnections[i]));
if(session!=null) {
session.close();
}
if(connection!=null) {
connection.close();
}
ActiveMQConnectionFactory factory = new
ActiveMQConnectionFactory(urlConnections[i],username, password);
connection = factory.createConnection();
connection.setClientID("clientID2");
connection.setExceptionListener(this);
connection.start();
session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
Topic destination =
session.createTopic(topicDestination);
consumer =
session.createDurableSubscriber(destination,"subsname");
consumer.setMessageListener(this);
connectionCreated=true;
System.out.println(String.format("Connected to:
%s",
urlConnections[i]));
}catch(Exception e){
System.err.println(String.format("Error
connecting to: %s",
urlConnections[i]));
if(i< urlConnections.length-1) {
i++;
}else {
i=0;
}
}
}
}
@Override
public void onMessage(Message message) {
String msg;
try {
msg = ((TextMessage) message).getText().replaceAll("#",
"");
System.out.println(new Date()+ " ["+ms+"] "+ msg);
ms++;
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void destroy() throws Exception {
if(session!=null) {
session.close();
}
if(connection!=null) {
connection.close();
}
}
@Override
public void afterPropertiesSet() throws Exception {
urlConnections = activeMqBrokerUri.split(",");
createConnection();
}
@Override
public void onException(JMSException exception) {
System.out.println("EXCEPCION");
createConnection();
}
}
Thanks in advance!
--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html