2016-02-17 17 views
0

我有一个骆驼Elasticsearch端点通过URI配置是这样的:如何迫使Camel Elasticsearch在测试中不启动本地节点?

.to("elasticsearch://clusterName?operation=INDEX&indexName=" + elasticIndex + "&indexType=" + elasticIndexType) 

在测试中,我拦截此终结,而只是想确认我在这里发出的有效载荷,这样做:

elasticEndpoint = context.getEndpoint("mock:elastic", MockEndpoint.class); 
interceptRoute = new AdviceWithRouteBuilder() { 
@Override 
public void configure() throws Exception { 
    interceptSendToEndpoint("elasticsearch:*") 
      .skipSendToOriginalEndpoint() 
      .to(elasticEndpoint); 
    } 
}; 

但是,这总是会提示Camel启动本地嵌入的ElasticSearch,这反过来会在我的Jenkins服务器上创建一个我不想要的数据文件夹。

如何禁用自动创建本地Elasticsearch节点?

回答

1

骆驼弹性搜索组件检查configuration.getIp() == null是否确定它是否创建Elasticsearch节点。

因此,你必须在指定的URI的IP和端口禁用此功能,因为这样:

.to("elasticsearch://clusterName?ip="+ elasticHostIp + "&port=" + elasticHostPort + "&operation=INDEX&indexName=" + elasticIndex + "&indexType=" + elasticIndexType)