chenweida hace 6 años
padre
commit
349a8e4b71

+ 6 - 1
common-logback-starter/src/main/java/com.yihu.base/es/buffer/EsBufferConsumer.java

@ -31,6 +31,7 @@ public class EsBufferConsumer implements Runnable {
    @Override
    public void run() {
        while (true) {
            JestClient jestClient = null;
            try {
                //格式格式化工具
                // patternLayout.setPattern(elasticsearchAppenderProperties.getMessageProperties().getPattern());
@ -44,7 +45,7 @@ public class EsBufferConsumer implements Runnable {
                //获取队列中的全部数据
                eventBuffer.getBuffer().drainTo(eventObjectList);
                //把数据存到ES中
                JestClient jestClient = ElasticSearchConnectionFactiory.getConnection();
                jestClient = ElasticSearchConnectionFactiory.getConnection();
                Bulk.Builder bulk = new Bulk.Builder()
                        .defaultIndex(elasticsearchAppenderProperties.getElasticsearchProperties().getIndex())
                        .defaultType(elasticsearchAppenderProperties.getElasticsearchProperties().getType());
@ -60,6 +61,10 @@ public class EsBufferConsumer implements Runnable {
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (jestClient != null) {
                    jestClient.shutdownClient();
                }
            }
        }
    }