use of org.orcid.utils.listener.RetryMessage in project ORCID-Source by ORCID.
the class RetryListener method processMessage.
/**
* Processes messages on receipt.
*
* @param map
* @throws JsonProcessingException
* @throws JAXBException
* @throws AmazonClientException
*/
@JmsListener(destination = MessageConstants.Queues.RETRY)
public void processMessage(final Map<String, String> map) throws JsonProcessingException, AmazonClientException, JAXBException {
RetryMessage message = new RetryMessage(map);
String orcid = message.getOrcid();
if (message.getMap() == null || message.getMap().get(RetryMessage.BROKER_NAME) == null) {
throw new MissingResourceException("Unable to find destination broker", String.class.getName(), RetryMessage.BROKER_NAME);
}
AvailableBroker destinationBroker = AvailableBroker.fromValue(message.getMap().get(RetryMessage.BROKER_NAME));
LOG.info("Recieved " + MessageConstants.Queues.RETRY + " message for orcid " + orcid + " to broker " + destinationBroker);
if (AvailableBroker.DUMP_STATUS_1_2_API.equals(destinationBroker) || AvailableBroker.DUMP_STATUS_2_0_API.equals(destinationBroker)) {
s3Processor.accept(message);
} else if (AvailableBroker.SOLR.equals(destinationBroker)) {
solrProcessor.accept(message);
}
}
use of org.orcid.utils.listener.RetryMessage in project ORCID-Source by ORCID.
the class HandleFailedMessages method resendFailedElements.
@Scheduled(cron = "${org.orcid.cron.reindex-failed}")
public void resendFailedElements() {
List<RecordStatusEntity> failedElements = manager.getFailedElements(BATCH_SIZE);
List<RecordStatusEntity> elementsToNotify = new ArrayList<RecordStatusEntity>();
for (RecordStatusEntity element : failedElements) {
try {
// Send RetryMessage for 1.2 dump
if (element.getDumpStatus12Api() > 0) {
RetryMessage message = new RetryMessage(element.getId(), AvailableBroker.DUMP_STATUS_1_2_API.value());
jmsTemplate.convertAndSend(MessageConstants.Queues.RETRY, message.getMap());
}
// Send RetryMessage for 2.0 dump
if (element.getDumpStatus20Api() > 0) {
RetryMessage message = new RetryMessage(element.getId(), AvailableBroker.DUMP_STATUS_2_0_API.value());
jmsTemplate.convertAndSend(MessageConstants.Queues.RETRY, message.getMap());
}
// Send RetryMessage for solr indexing
if (element.getSolrStatus20Api() > 0) {
RetryMessage message = new RetryMessage(element.getId(), AvailableBroker.SOLR.value());
jmsTemplate.convertAndSend(MessageConstants.Queues.RETRY, message.getMap());
}
// Send RetryMessage for 2.0 activities dump
if (element.getDumpStatus20ActivitiesApi() > 0) {
RetryMessage message = new RetryMessage(element.getId(), AvailableBroker.DUMP_STATUS_2_0_ACTIVITIES_API.value());
jmsTemplate.convertAndSend(MessageConstants.Queues.RETRY, message.getMap());
}
// Should we notify about this element?
if ((element.getDumpStatus12Api() > maxFailuresBeforeNotify) || (element.getDumpStatus20Api() > maxFailuresBeforeNotify) || (element.getSolrStatus20Api() > maxFailuresBeforeNotify) || (element.getDumpStatus20ActivitiesApi() > maxFailuresBeforeNotify)) {
elementsToNotify.add(element);
}
} catch (JmsException e) {
LOGGER.warn("Unable to resend message for " + element.getId());
}
}
// Send summary
if (!elementsToNotify.isEmpty()) {
String message = buildNotificationMessage(elementsToNotify);
sendSystemAlert(message);
}
}
Aggregations