Search in sources :

Example 1 with FatalQueueError

use of dk.dbc.pgqueue.consumer.FatalQueueError in project solr-document-store by DBCDK.

the class Worker method makeWorker.

public JobConsumer<QueueJob> makeWorker() {
    return new JobConsumer<QueueJob>() {

        @Override
        public void accept(Connection connection, QueueJob job, JobMetaData metaData) throws FatalQueueError, NonFatalQueueError, PostponedNonFatalQueueError {
            log.info("job = {}, metadata = {}", job, metaData);
            try {
                JsonNode sourceDoc = docProducer.fetchSourceDoc(job);
                SolrInputDocument solrDocument = docProducer.createSolrDocument(sourceDoc);
                String bibliographicShardId = docProducer.bibliographicShardId(sourceDoc);
                docProducer.deleteSolrDocuments(bibliographicShardId, job.getCommitwithin());
                docProducer.deploy(solrDocument, job.getCommitwithin());
            } catch (IOException ex) {
                throw new NonFatalQueueError(ex);
            } catch (SolrServerException ex) {
                throw new FatalQueueError(ex);
            }
        }
    };
}
Also used : SolrInputDocument(org.apache.solr.common.SolrInputDocument) JobMetaData(dk.dbc.pgqueue.consumer.JobMetaData) PostponedNonFatalQueueError(dk.dbc.pgqueue.consumer.PostponedNonFatalQueueError) NonFatalQueueError(dk.dbc.pgqueue.consumer.NonFatalQueueError) SolrServerException(org.apache.solr.client.solrj.SolrServerException) Connection(java.sql.Connection) JobConsumer(dk.dbc.pgqueue.consumer.JobConsumer) JsonNode(com.fasterxml.jackson.databind.JsonNode) PostponedNonFatalQueueError(dk.dbc.pgqueue.consumer.PostponedNonFatalQueueError) FatalQueueError(dk.dbc.pgqueue.consumer.FatalQueueError) NonFatalQueueError(dk.dbc.pgqueue.consumer.NonFatalQueueError) IOException(java.io.IOException) QueueJob(dk.dbc.search.solrdocstore.queue.QueueJob)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 FatalQueueError (dk.dbc.pgqueue.consumer.FatalQueueError)1 JobConsumer (dk.dbc.pgqueue.consumer.JobConsumer)1 JobMetaData (dk.dbc.pgqueue.consumer.JobMetaData)1 NonFatalQueueError (dk.dbc.pgqueue.consumer.NonFatalQueueError)1 PostponedNonFatalQueueError (dk.dbc.pgqueue.consumer.PostponedNonFatalQueueError)1 QueueJob (dk.dbc.search.solrdocstore.queue.QueueJob)1 IOException (java.io.IOException)1 Connection (java.sql.Connection)1 SolrServerException (org.apache.solr.client.solrj.SolrServerException)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1