Search in sources :

Example 1 with PreparedQueueSupplier

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

the class WorkerIT method testQueueWorkerConsumes.

@Test(timeout = 5000L)
public void testQueueWorkerConsumes() throws Exception {
    System.out.println("testQueueWorkerConsumes");
    SolrClient solrClient = SolrApi.makeSolrClient(solrUrl);
    try (Connection connection = dataSource.getConnection()) {
        Requests.load("test1-part1", solrDocStoreUrl);
        long count = solrClient.query(new SolrQuery("*:*")).getResults().getNumFound();
        assertEquals("After delete sorl document count: ", 0, count);
        PreparedQueueSupplier supplier = new QueueSupplier<>(QueueJob.STORAGE_ABSTRACTION).preparedSupplier(connection);
        supplier.enqueue("test", new QueueJob(300000, "clazzifier", "23645564"));
        int maxRuns = 2500 / 50;
        while (solrClient.query(new SolrQuery("*:*")).getResults().getNumFound() == 0) {
            Thread.sleep(50L);
            solrClient.commit(true, true);
            if (maxRuns-- <= 0) {
                break;
            }
        }
        worker.destroy();
        count = solrClient.query(new SolrQuery("*:*")).getResults().getNumFound();
        assertEquals("After dequeue -  sorl document count: ", 3, count);
    }
}
Also used : SolrClient(org.apache.solr.client.solrj.SolrClient) PreparedQueueSupplier(dk.dbc.pgqueue.PreparedQueueSupplier) Connection(java.sql.Connection) QueueJob(dk.dbc.search.solrdocstore.queue.QueueJob) SolrQuery(org.apache.solr.client.solrj.SolrQuery) Test(org.junit.Test)

Aggregations

PreparedQueueSupplier (dk.dbc.pgqueue.PreparedQueueSupplier)1 QueueJob (dk.dbc.search.solrdocstore.queue.QueueJob)1 Connection (java.sql.Connection)1 SolrClient (org.apache.solr.client.solrj.SolrClient)1 SolrQuery (org.apache.solr.client.solrj.SolrQuery)1 Test (org.junit.Test)1