使用Apache camel进行Solr Delta导入调度 - 为Delta Import调用数据导入处理程序

时间:2014-01-20 12:20:05

标签: solr apache-camel

我是Solr和Camel的新手,这就是我想要实现的目标:

我正在使用数据导入处理程序将数据索引到Solr中。当我从solr管理员运行时,一切(完整/增量导入)工作正常。我想编写一个调度程序,它将定期运行并从我的webapp触发delta导入。我正在尝试使用Apache Camel来实现此目的。

我的目的是让Camel Quartz调度程序每隔5分钟创建一个事件,并将该事件重定向到solr路由,然后再调用Solr Delta Import处理程序。

    from("quartz2://SolrUpdateHandlerInvokerTimer?trigger.repeatCount=-1&trigger.repeatInterval=300000")
            .to("direct:insert");

    from("direct:insert")
            .to("solr://localhost:8080/solr/hylighter/dataimport?command=delta-import")
            .to("direct:commit");

    from("direct:commit")
          .setHeader(SolrConstants.OPERATION,constant(SolrConstants.OPERATION_COMMIT))
          .to("solr://localhost:8080/solr/hylighter");

但是这不起作用并且因以下异常而失败。

例外:

Caused by: 
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: solr://localhost:8080/solr/hylighter/dataimport?command=delta-import due to: Failed to resolve endpoint: solr://localhost:8080/solr/hylighter/dataimport?command=delta-import due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{command=delta-import}]

如果我删除?command=delta-import代码不会抛出任何异常并运行但是当我检查我的core / conf文件夹中的dataimport.properties时它没有更新,也没有我的索引。

有人可以帮我确定我错在哪里吗?

修改

路线变更:

    from("quartz2://SolrUpdateHandlerInvokerTimer?trigger.repeatCount=-1&trigger.repeatInterval=3000")
            .process(new LoggingProcessor())
            .to("direct:insert");

    from("direct:insert")
            .process(new SolrLoggingProcessor())
            .to("solr://localhost:8080/solr/hylighter/dataimport")
            .process(new SolrLoggingProcessor())
            .to("direct:commit");

    from("direct:commit")
            .setHeader(SolrConstants.OPERATION,constant(SolrConstants.OPERATION_COMMIT))
            .process(new CommitLoggingProcessor())
            .to("solr://localhost:8080/solr/hylighter")
            .process(new CommitLoggingProcessor());

追踪:

QUARTZ ROUTE:ID-Bee-58722-1390286766821-0-2
从Solr更新路线ID-Bee-58722-1390286766821-0-2
QUARTZ ROUTE:ID-Bee-58722-1390286766821-0-4
从Solr更新路线ID-Bee-58722-1390286766821-0-4
QUARTZ ROUTE:ID-Bee-58722-1390286766821-0-6
从Solr更新路线ID-Bee-58722-1390286766821-0-6
QUARTZ ROUTE:ID-Bee-58722-1390286766821-0-8
从Solr更新路线ID-Bee-58722-1390286766821-0-8

我在路由中的端点之前和路由中的端点之后添加了一个处理器,我看到一旦它到达调用solr数据导入的路由,它就不会返回并在路由中前进。

1 个答案:

答案 0 :(得分:0)

这就是我解决问题的方法。我使用Camel-Http组件而不是Camel-Solr组件,并调用Solr数据导入处理程序来执行delta导入。

路线:

    from("quartz2://SolrUpdateHandlerTimer?trigger.repeatCount=-1&trigger.repeatInterval=300000")
        .to("direct:start");

    from("direct:start")
        .setHeader(Exchange.HTTP_METHOD, constant("GET"))
        .to("http://localhost:8080/solr/hylighter/dataimport?command=delta-import&commit=true")
        .end();
相关问题