Skip to content
Permalink
Browse files
Applied patch for TRANSPORTS-35.
  • Loading branch information
Sagara Gunathunga committed Feb 28, 2012
1 parent f341262 commit 1a7251a4ec94b154678a6b832bb71271cc085432
Showing 1 changed file with 17 additions and 4 deletions.
@@ -144,6 +144,9 @@ public class ServiceTaskManager {
/** The JMS Connection shared between multiple polling tasks - when enabled (reccomended) */
private Connection sharedConnection = null;

/** Is this error triggers a JMS onException ?*/
private volatile boolean isOnExceptionError = false;

/**
* Start or re-start the Task Manager by shutting down any existing worker tasks and
* re-creating them. However, if this is STM is PAUSED, a start request is ignored.
@@ -464,9 +467,13 @@ public void run() {
synchronized(pollingTasks) {
pollingTasks.remove(this);
}

// My time is up, so if I am going away, create another
scheduleNewTaskIfAppropriate();

// if this is a JMS onException, ServiceTaskManager#onException will schedule
// a new polling task
if (!isOnExceptionError) {
// My time is up, so if I am going away, create another
scheduleNewTaskIfAppropriate();
}
}

}
@@ -592,6 +599,8 @@ private void handleMessage(Message message, UserTransaction ut) {
*/
public void onException(JMSException j) {

isOnExceptionError = true;

if (!isSTMActive()) {
requestShutdown();
return;
@@ -631,16 +640,20 @@ public void onException(JMSException j) {
}

if (!connected) {
retryDuration = (long) (retryDuration * reconnectionProgressionFactor);
log.error("Reconnection attempt : " + (r++) + " for service : " + serviceName +
" failed. Next retry in " + (retryDuration/1000) + "seconds");
retryDuration = (long) (retryDuration * reconnectionProgressionFactor);
if (retryDuration > maxReconnectDuration) {
retryDuration = maxReconnectDuration;
}

try {
Thread.sleep(retryDuration);
} catch (InterruptedException ignore) {}
} else {
isOnExceptionError = false;
log.info("Reconnection attempt: " + r + " for service: " + serviceName +
" was successful!");
}

} while (!isSTMActive() || getConnectedTaskCount() < concurrentConsumers);

0 comments on commit 1a7251a

Please sign in to comment.