Skip to content

Commit

Permalink
changed RA and xa recovery logging to only print once not every retry…
Browse files Browse the repository at this point in the history
… failure
  • Loading branch information
andytaylor committed Nov 16, 2012
1 parent d9d3a2e commit 55f6e60
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 10 deletions.
Expand Up @@ -165,6 +165,11 @@ public interface HornetQJMSServerLogger extends BasicLogger
format = Message.Format.MESSAGE_FORMAT)
void failedToCorrectHost(@Cause Exception e, String name);

@LogMessage(level = Logger.Level.WARN)
@Message(id = 122021, value = "Couldn't start recovery discovery on {0}, we will retry every recovery scan until the server is available" ,
format = Message.Format.MESSAGE_FORMAT)
void xaRecoveryStartError(XARecoveryConfig e);

@LogMessage(level = Logger.Level.ERROR)
@Message(id = 124001, value = "key attribute missing for JMS configuration {0}" , format = Message.Format.MESSAGE_FORMAT)
void jmsConfigMissingKey(Node e);
Expand Down
Expand Up @@ -104,7 +104,7 @@ public void register(final XARecoveryConfig resourceConfig)
if (discoveryRecord == null)
{
discoveryRecord = newInstance;
discoveryRecord.start();
discoveryRecord.start(false);
}
// you could have a configuration shared with multiple MDBs or RAs
discoveryRecord.incrementUsage();
Expand Down Expand Up @@ -201,7 +201,7 @@ public void run()
try
{
HornetQJMSServerLogger.LOGGER.debug("Retrying discovery " + discovery);
discovery.start();
discovery.start(true);
}
catch (Throwable e)
{
Expand Down
Expand Up @@ -50,7 +50,7 @@ public RecoveryDiscovery(XARecoveryConfig config)
this.config = config;
}

public synchronized void start()
public synchronized void start(boolean retry)
{
if (!started)
{
Expand All @@ -72,7 +72,10 @@ public synchronized void start()
}
catch (Exception startupError)
{
HornetQJMSServerLogger.LOGGER.warn("Couldn't start recovery discovery on " + config + ", we will retry this on the next recovery scan");
if (!retry)
{
HornetQJMSServerLogger.LOGGER.xaRecoveryStartError(config);
}
stop();
HornetQRecoveryRegistry.getInstance().failedDiscovery(this);
}
Expand Down
4 changes: 4 additions & 0 deletions hornetq-ra/src/main/java/org/hornetq/ra/HornetQRALogger.java
Expand Up @@ -85,6 +85,10 @@ public interface HornetQRALogger extends BasicLogger
@Message(id = 151007, value = "Instantiating {0} \"{1}\" directly since UseJNDI=false.", format = Message.Format.MESSAGE_FORMAT)
void instantiatingDestination(String destinationType, String destination);

@LogMessage(level = Logger.Level.INFO)
@Message(id = 151008, value = "awaiting HornetQ Server availability", format = Message.Format.MESSAGE_FORMAT)
void awaitingJMSServerCreation();

@LogMessage(level = Logger.Level.WARN)
@Message(id = 152001, value = "It wasn't possible to lookup for a Transaction Manager through the configured properties TransactionManagerLocatorClass and TransactionManagerLocatorMethod" +
"\nHornetQ Resource Adapter won't be able to set and verify transaction timeouts in certain cases.", format = Message.Format.MESSAGE_FORMAT)
Expand Down
Expand Up @@ -52,7 +52,7 @@ public class HornetQRAProperties extends ConnectionFactoryProperties implements
/** Method used to locate the TM */
private String transactionManagerLocatorMethod = "getTm;getTM";

private static final int DEFAULT_SETUP_ATTEMPTS = 10;
private static final int DEFAULT_SETUP_ATTEMPTS = -1;

private static final long DEFAULT_SETUP_INTERVAL = 2 * 1000;

Expand Down
Expand Up @@ -31,6 +31,8 @@

import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.HornetQExceptionType;
import org.hornetq.api.core.HornetQNonExistentQueueException;
import org.hornetq.api.core.HornetQNotConnectedException;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.client.ClientSession;
import org.hornetq.api.core.client.ClientSessionFactory;
Expand Down Expand Up @@ -482,7 +484,9 @@ protected void setupDestination() throws Exception

String calculatedDestinationName = destinationName.substring(destinationName.lastIndexOf('/') + 1);

HornetQRALogger.LOGGER.unableToRetrieveDestinationFromJNDI(destinationName, destinationType.getName(), calculatedDestinationName);
HornetQRALogger.LOGGER.debug("Unable to retrieve " + destinationName +
" from JNDI. Creating a new " + destinationType.getName() +
" named " + calculatedDestinationName + " to be used by the MDB.");

// If there is no binding on naming, we will just create a new instance
if (isTopic)
Expand Down Expand Up @@ -552,10 +556,14 @@ public String toString()
*/
public void handleFailure(Throwable failure)
{
if(failure instanceof HornetQException && ((HornetQException)failure).getType() == HornetQExceptionType.QUEUE_DOES_NOT_EXIST)
if(failure instanceof HornetQException && !(((HornetQException)failure).getType() == HornetQExceptionType.QUEUE_DOES_NOT_EXIST))
{
HornetQRALogger.LOGGER.awaitingTopicQueueCreation(getActivationSpec().getDestination());
}
else if(failure instanceof HornetQException && !(((HornetQException)failure).getType() == HornetQExceptionType.NOT_CONNECTED))
{
HornetQRALogger.LOGGER.awaitingJMSServerCreation();
}
else
{
HornetQRALogger.LOGGER.failureInActivation(failure, spec);
Expand All @@ -569,6 +577,7 @@ public void handleFailure(Throwable failure)
return;
try
{
Throwable lastException = failure;
while (deliveryActive.get() && (setupAttempts == -1 || reconnectCount < setupAttempts))
{
teardown();
Expand All @@ -583,7 +592,10 @@ public void handleFailure(Throwable failure)
break;
}

HornetQRALogger.LOGGER.attemptingReconnect(spec);
if (reconnectCount < 1)
{
HornetQRALogger.LOGGER.attemptingReconnect(spec);
}
try
{
setup();
Expand All @@ -592,9 +604,21 @@ public void handleFailure(Throwable failure)
}
catch (Throwable t)
{
if(failure instanceof HornetQException && ((HornetQException)failure).getType() == HornetQExceptionType.QUEUE_DOES_NOT_EXIST)
if(failure instanceof HornetQException && !(((HornetQException)failure).getType() == HornetQExceptionType.QUEUE_DOES_NOT_EXIST))
{
if (lastException == null && lastException instanceof HornetQNonExistentQueueException)
{
lastException = t;
HornetQRALogger.LOGGER.awaitingTopicQueueCreation(getActivationSpec().getDestination());
}
}
else if(failure instanceof HornetQException && !(((HornetQException)failure).getType() == HornetQExceptionType.NOT_CONNECTED))
{
HornetQRALogger.LOGGER.awaitingTopicQueueCreation(getActivationSpec().getDestination());
if (lastException == null && lastException instanceof HornetQNotConnectedException)
{
lastException = t;
HornetQRALogger.LOGGER.awaitingJMSServerCreation();
}
}
else
{
Expand Down

0 comments on commit 55f6e60

Please sign in to comment.