- for (N notification: notifications) {
- boolean notificationOfferAttemptSuccess = false;
- // The offer is attempted for up to 10 minutes, with a status message printed each minute
- for (int notificationOfferAttempts = 0;
- notificationOfferAttempts < MAX_NOTIFICATION_OFFER_ATTEMPTS; notificationOfferAttempts++) {
-
- // Try to offer for up to a minute and log a message if it times out.
- if (LOG.isDebugEnabled()) {
- LOG.debug( "{}: Offering notification to the queue for listener {}: {}",
- name, listenerKey.toString(), notification );
- }
-
- if (notificationOfferAttemptSuccess = notificationQueue.offer(
- notification, 1, TimeUnit.MINUTES)) {
- break;
- }
-
- LOG.warn(
- "{}: Timed out trying to offer a notification to the queue for listener {} "
- + "on attempt {} of {}. " + "The queue has reached its capacity of {}",
- name, listenerKey.toString(), notificationOfferAttempts,
- MAX_NOTIFICATION_OFFER_ATTEMPTS, maxQueueCapacity);
- }
- if (!notificationOfferAttemptSuccess) {
- LOG.warn(
- "{}: Failed to offer a notification to the queue for listener {}. "
- + "Exceeded max allowable attempts of {} in {} minutes; the listener "
- + "is likely in an unrecoverable state (deadlock or endless loop).",
- name, listenerKey.toString(), MAX_NOTIFICATION_OFFER_ATTEMPTS,
- MAX_NOTIFICATION_OFFER_ATTEMPTS);
- }