/** * @param event * @param code * @param msg */ private void sendToAdviceListener(JetstreamEvent event, RetryEventCode code, String msg) { try { if (getAdviceListener() != null) { if (event.containsKey(JetstreamReservedKeys.RetryCount.toString())) { Integer retryCount = (Integer) event.get(JetstreamReservedKeys.RetryCount.toString()); if (retryCount > getRetryCount()) { LOGGER.info("Unable to deliver this event so dropping it.." + event.getEventId()); m_totalEventsDropped.increment(); return; } } getAdviceListener().retry(event, code, msg); incrementAdviceListenerCount(); } } catch (Throwable e) { m_errors.registerError(e); LOGGER.debug(e.getLocalizedMessage()); } }
/* * (non-Javadoc) * * @see com.ebay.jetstream.messaging.JetstreamMessageListener#onMessage(com.ebay.jetstream.messaging.JetstreamMessage) */ public void onMessage(JetstreamMessage m) { if (m instanceof AdvisoryMessage) { AdvisoryMessage advise = (AdvisoryMessage) m; if (advise.isStopSending() && matchesMyPublishingContexts(advise.getAdvisoryTopic().getRootContext())) { LOGGER.warn("Outbound Messaging Channel raising alarm"); setTopicAlarmState(advise.getAdvisoryTopic().getRootContext()); incrementAlarmsRaisedCounter(); if (areAllContextsInAlarmCondition()) { m_alarmRaised.set(true); getAlarmListener().alarm(ChannelAlarm.OVERRUN); postAlert("All Contexts in Alarm Condition - ", AlertStrength.ORANGE); } } else if (advise.isResumeSending() && matchesMyPublishingContexts(advise.getAdvisoryTopic().getRootContext())) { LOGGER.info( "Outbound Messaging Channel clearing alarm for topic-> " + advise.getAdvisoryTopic().getRootContext()); resetTopicAlarmState(advise.getAdvisoryTopic().getRootContext()); if (!areAllContextsInAlarmCondition()) { m_alarmRaised.set(false); getAlarmListener().alarm(ChannelAlarm.CLEAR); postAlert("Alarm Condition Cleared - ", AlertStrength.YELLOW); incrementAlarmsClearedCounter(); } } else if (advise.isResendMessage()) { JetstreamEvent evt = (JetstreamEvent) ((Any) ((AdvisoryMessage) m).getUndeliveredMsg()).getObject(); try { evt = evt.clone(); } catch (CloneNotSupportedException e) { m_errors.registerError(e); LOGGER.debug("Failed to clone event : Exception = " + e.getLocalizedMessage()); this.incrementEventDroppedCounter(); return; } List<String> topics = m_address.getChannelTopics(); String topic = ((AdvisoryMessage) m).getAdvisoryTopic().toString(); // Fix issue when multiple OMCs subscribe different topics under same context. // Each OMC will receive broadcast advisory events. if (topic == null || topics.contains(topic)) { evt.put(JetstreamReservedKeys.EventReplayTopic.toString(), topic); Integer retryCount = 1; if (evt != null) { if (evt.containsKey(JetstreamReservedKeys.RetryCount.toString())) { retryCount = (Integer) evt.get(JetstreamReservedKeys.RetryCount.toString()); retryCount++; } evt.put(JetstreamReservedKeys.RetryCount.toString(), retryCount); sendToAdviceListener( evt, RetryEventCode.MSG_RETRY, AdvisoryCode.RESEND_MESSAGE.toString()); incrementRetryAdvisoryEvents(); } } } } }