use of org.orcid.utils.listener.LastModifiedMessage in project ORCID-Source by ORCID.
the class v2ClientPerMessageCacheTest method testRecordThenActivityCache.
@Test
public void testRecordThenActivityCache() throws LockedRecordException, DeprecatedRecordException {
// get it once
Date date = new Date();
date.setYear(1900);
BaseMessage message1 = new LastModifiedMessage("0000-0000-0000-0000", date);
Record r = orcid20ApiClient.fetchPublicRecord(message1);
assertEquals("http://orcid.org/0000-0000-0000-0000", r.getOrcidIdentifier().getPath());
// get it twice, if no error, then it's the cached version
when(mock_response.getEntity(Record.class)).thenThrow(new RuntimeException("called twice!"));
ActivitiesSummary s = orcid20ApiClient.fetchPublicActivities(message1);
assertEquals(s.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTitle().getContent(), "blah");
// get it with a different message, should return fresh
BaseMessage message2 = new LastModifiedMessage("0000-0000-0000-0000", new Date());
try {
s = orcid20ApiClient.fetchPublicActivities(message2);
fail("returned cached when it should get fresh");
} catch (RuntimeException e) {
if (e.getMessage() != "called twice!")
fail("something weird");
}
}
use of org.orcid.utils.listener.LastModifiedMessage in project ORCID-Source by ORCID.
the class UpdatedOrcidWorker method onRemoval.
/**
* Fires when the queue evicts after an inactivity period.
* Populates the Amazon S3 buckets and updates solr index
*/
public void onRemoval(RemovalNotification<String, LastModifiedMessage> removal) {
if (removal.wasEvicted()) {
LastModifiedMessage m = removal.getValue();
LOG.info("Removing " + removal.getKey() + " from UpdatedOrcidCacheQueue '" + m.getLastUpdated() + "' Removal cause " + removal.getCause());
s3Processor.accept(m);
solrProcessor.accept(m);
mongoProcessor.accept(m);
}
}
use of org.orcid.utils.listener.LastModifiedMessage 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);
mongoProcessor.accept(message);
}
Aggregations