-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRSIItemWriter.java
40 lines (31 loc) · 1.02 KB
/
RSIItemWriter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.oracle.rsi.demospringbatch;
import java.util.List;
import java.util.concurrent.SubmissionPublisher;
import java.util.logging.Logger;
import org.springframework.batch.item.ItemWriter;
import oracle.rsi.ReactiveStreamsIngestion;
/**
* Custom ItemWriter.
* It uses RSI to stream rows into the target Oracle Database.
* Overrides write to publish items into RSI using a SubmissionPublisher.
*
* @author psilberk
*/
public class RSIItemWriter<T> implements ItemWriter<T> {
private ReactiveStreamsIngestion rsi = null;
private SubmissionPublisher<T> publisher = null;
private Logger logger = Logger.getLogger(RSIItemWriter.class.getName());
public RSIItemWriter(ReactiveStreamsIngestion rsi) {
this.rsi = rsi;
publisher = new SubmissionPublisher<>();
publisher.subscribe(rsi.subscriber());
logger.info("RSI Item Writer Started!");
}
@Override
public void write(List<? extends T> items) throws Exception {
items.forEach(publisher::submit);
}
public void close() {
rsi.close();
}
}