Search in sources :

Example 1 with JmsListener

use of org.springframework.jms.annotation.JmsListener 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);
    }
}
Also used : AvailableBroker(org.orcid.listener.persistence.util.AvailableBroker) MissingResourceException(java.util.MissingResourceException) RetryMessage(org.orcid.utils.listener.RetryMessage) JmsListener(org.springframework.jms.annotation.JmsListener)

Example 2 with JmsListener

use of org.springframework.jms.annotation.JmsListener in project ORCID-Source by ORCID.

the class UpdatedOrcidListener method processMessage.

/**
     * Queues incoming messages for processing, eventually handled by UpdatedOrcidWorker
     * 
     * @param map
     */
@JmsListener(destination = MessageConstants.Queues.UPDATED_ORCIDS)
public void processMessage(final Map<String, String> map) {
    LastModifiedMessage message = new LastModifiedMessage(map);
    LOG.info("Recieved " + MessageConstants.Queues.UPDATED_ORCIDS + " message for orcid " + message.getOrcid() + " " + message.getLastUpdated());
    LastModifiedMessage existingMessage = cacheQueue.getCache().getIfPresent(message.getOrcid());
    if (existingMessage == null || message.getLastUpdated().after(existingMessage.getLastUpdated()))
        cacheQueue.getCache().put(message.getOrcid(), message);
}
Also used : LastModifiedMessage(org.orcid.utils.listener.LastModifiedMessage) JmsListener(org.springframework.jms.annotation.JmsListener)

Example 3 with JmsListener

use of org.springframework.jms.annotation.JmsListener in project ORCID-Source by ORCID.

the class ReIndexListener method processMessage.

/**
     * Processes messages on receipt.
     * 
     * @param map
     * @throws JsonProcessingException 
     * @throws JAXBException 
     * @throws AmazonClientException 
     */
@JmsListener(destination = MessageConstants.Queues.REINDEX)
public void processMessage(final Map<String, String> map) throws JsonProcessingException, AmazonClientException, JAXBException {
    LastModifiedMessage message = new LastModifiedMessage(map);
    String orcid = message.getOrcid();
    LOG.info("Recieved " + MessageConstants.Queues.REINDEX + " message for orcid " + orcid + " " + message.getLastUpdated());
    s3Processor.accept(message);
    solrProcessor.accept(message);
}
Also used : LastModifiedMessage(org.orcid.utils.listener.LastModifiedMessage) JmsListener(org.springframework.jms.annotation.JmsListener)

Aggregations

JmsListener (org.springframework.jms.annotation.JmsListener)3 LastModifiedMessage (org.orcid.utils.listener.LastModifiedMessage)2 MissingResourceException (java.util.MissingResourceException)1 AvailableBroker (org.orcid.listener.persistence.util.AvailableBroker)1 RetryMessage (org.orcid.utils.listener.RetryMessage)1