如何强制 Camel Elasticsearch 在测试中不启动本地节点?
How force Camel Elasticsearch to not start local node in test?
我有一个由 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 节点?
camel-elasticsearch 组件检查 configuration.getIp() == null 以确定它是否创建了 Elasticsearch 节点。
因此您必须在 URI 中指定 IP 和端口才能禁用此功能,例如:
.to("elasticsearch://clusterName?ip="+ elasticHostIp + "&port=" + elasticHostPort + "&operation=INDEX&indexName=" + elasticIndex + "&indexType=" + elasticIndexType)
我有一个由 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 节点?
camel-elasticsearch 组件检查 configuration.getIp() == null 以确定它是否创建了 Elasticsearch 节点。
因此您必须在 URI 中指定 IP 和端口才能禁用此功能,例如:
.to("elasticsearch://clusterName?ip="+ elasticHostIp + "&port=" + elasticHostPort + "&operation=INDEX&indexName=" + elasticIndex + "&indexType=" + elasticIndexType)