Created
November 24, 2010 10:57
-
-
Save rhyskeepence/713483 to your computer and use it in GitHub Desktop.
Print a message if connecting is taking too long
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void attachListener() { | |
ScheduledFuture<?> activemqWarning = scheduleWarningIfJmsConnectionTakesTooLong(); | |
try { | |
// perform some operation that may hang if ActiveMq is not running | |
} finally { | |
activemqWarning.cancel(true); | |
} | |
} | |
private ScheduledFuture<?> scheduleWarningIfJmsConnectionTakesTooLong() { | |
return Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() { | |
public void run() { | |
System.err.println("WARNING: It's taking a long time to connect to JMS - check ActiveMQ is running!"); | |
} | |
}, 10, TimeUnit.SECONDS); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setting a failover timeout means my app quits. I'd rather see a warning and be able to start activemq without restarting my app.