Spring Batch Writer is the implementation of org.springframework.batch.item.ItemWriter. You can write a custom writer, but Spring Batch already has some useful implementations, such as org.springframework.batch.item.amqp.AmqpItemWriter for AMQP brokers such as RabbitMQ org.springframework.batch.item.file.FlatFileItemWriter for a file org.springframework.batch.item.database.JpaItemWriter for database using JPA org.springframework.batch.item.database.JdbcBatchItemWriter for writing to database with plain SQL This post shows detailed information on using … Continue reading More on Spring Batch Writer
Category: Java
More on Spring Batch Reader
Spring Batch Job is composed of Reader, Processor and Writer. This post shows some more details on Reader. Reader is the implementation of org.springframework.batch.item.Reader. I recommend to use the following implementations. AmqpItemReader (org.springframework.batch.item.amqp.AmqpItemReader) : to interact with queue such as RabbitMQ FlatFileItemReader (org.springframework.batch.item.file.FlatFileItemReader) : to interact with a file JdbcCursorItemReader (org.springframework.batch.item.database.JdbcCursorItemReader) : to interact with … Continue reading More on Spring Batch Reader
Simple ETL with Spring Batch
Spring Batch is literally a batch framework based on Spring Framework. I usually use it to develop a simple ETL(Extraction, Transaformation and Loading) program. In this post, I'll show you how to write a simple ETL program. (This sample is tested on Spring Batch 3.0.10) Prerequisites Database (MySQL or Oracle) Spring batch context database Spring … Continue reading Simple ETL with Spring Batch
A tip on using user transaction on Mybatis
When using transation on Mybatis, there are 3 ways. Container managed transaction - JEE engine manages transaction User managed transaction - transaction is controlled by user source code Spring managed transaction - transaction is controlled by Spring Transaction policy I usually use Spring managed or container managed transaction. But sometimes, I need to control transaction … Continue reading A tip on using user transaction on Mybatis
At which point does Kafka consumer start to read
At which point does Kafka consumer start to read? It depends on the following scenarios. Basic concept Kafka can have several topics and each topic can have several partitions Each partition keeps offset for each message Offset starts from 0 and increases by 1 when a new message is published Kafka server keeps the next … Continue reading At which point does Kafka consumer start to read
Building a robust Zookeeper client : connection management
To support high available Zookeeper service, we need to configure Zookeeper ensemble. But this is not enough. we need to understand how client manages connection to Zookeeper server. For test, I set up a Zookeeper ensemble. (port : 2181, 2182, 2183) After then, write a test client with 2 important parameters - 1) connect string … Continue reading Building a robust Zookeeper client : connection management
Mockito thenReturn() vs thenAnswer()
Mockito is a very powerful test library for Java. In most cases, setting some mock action with thenReturn() is enough. But in some rare cases, we need to use thenAnswer(). thenReturn() example First, let's review the basic use of thenReturn() First, I want to test getResultWithParam(). Above test case succeeds. Wrong test case Next, I … Continue reading Mockito thenReturn() vs thenAnswer()
Programming Zookeeper – Watcher
The common pattern of Zookeeper is 1) to check existence of a znode or 2) to read a znode data. Let's suppose that you are building a program which does some action whenever a znode data is changed. The way to implement it is 1) to read the znode data periodically or 2) to get … Continue reading Programming Zookeeper – Watcher
Programming Zookeeper – Connecting to Zookeeper
When programming Zookeeper in Java, Zookeeper client or Curator is used. Zookeeper client is embedded in Zookeeper server library Curator is a wrapper for Zookeeper client, which enables easier programming There are something to consider when programming Zookeeper. The first point is connecting to Zookeeper. Let's suppose that you make a program which connects to … Continue reading Programming Zookeeper – Connecting to Zookeeper
Integrating Mybatis with Spring
Spring framework does not support Mybatis internally. Instead, mybatis-spring project supports integration of Mybatis with Spring. This article is based on Spring 4.3.16 and Mybatis 3.4.6. (As of writing this article, Spring 5.1.x still don't support Mybatis internally) You can download the sample project here. Test table for the sample Test Mybatis mapper xml Required … Continue reading Integrating Mybatis with Spring