@Test public void shouldWriteItemWhenInTransaction() throws Exception { IndexQueryBuilder builder = new IndexQueryBuilder(); builder.withObject(dummyDocument); final List<IndexQuery> items = asList(builder.build()); transactionTemplate.execute(new TransactionCallback<Void>() { @Override public Void doInTransaction(TransactionStatus status) { try { writer.write(items); } catch (Exception e) { fail("An error occurred while writing: " + e.getMessage()); } return null; } }); verify(elasticsearchOperations).index(items.iterator().next()); }
@Override public void write(List<? extends IndexQuery> items) throws Exception { if(isActualTransactionActive()) { addToBuffer(items); }else { writeItems(items); } }
ElasticsearchItemWriter implements ItemWriter<IndexQuery>, InitializingBean { @Override public void write(List<? extends IndexQuery> items) throws Exception { if(isActualTransactionActive()) { addToBuffer(items); }else { writeItems(items); } } }
ElasticsearchItemWriter implements ItemWriter<IndexQuery>, InitializingBean { @Override public void write(List<? extends IndexQuery> items) throws Exception { if(isActualTransactionActive()) { addToBuffer(items); }else { writeItems(items); } } ElasticsearchItemWriter(ElasticsearchOperations elasticsearchOperations); }
ElasticsearchItemWriter implements ItemWriter<IndexQuery>, InitializingBean { @Override public void write(List<? extends IndexQuery> items) throws Exception { if(isActualTransactionActive()) { addToBuffer(items); }else { writeItems(items); } } ElasticsearchItemWriter(ElasticsearchOperations elasticsearchOperations); void setDelete(boolean delete); @Override void afterPropertiesSet(); @Override void write(List<? extends IndexQuery> items); }
ElasticsearchItemWriter implements ItemWriter<IndexQuery>, InitializingBean { @Override public void write(List<? extends IndexQuery> items) throws Exception { if(isActualTransactionActive()) { addToBuffer(items); }else { writeItems(items); } } ElasticsearchItemWriter(ElasticsearchOperations elasticsearchOperations); void setDelete(boolean delete); @Override void afterPropertiesSet(); @Override void write(List<? extends IndexQuery> items);  }