aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java
blob: bce3e6c3d7d02255e5875dba0a438846b4c0e629 (plain)
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
package org.openecomp.mso.client.dmaap;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

import com.att.nsa.mr.client.MRBatchingPublisher;
import com.att.nsa.mr.client.MRClientFactory;

public class DmaapPublisher {
	
	private final long seconds;
	private final MRBatchingPublisher publisher;
	
	public DmaapPublisher(String filepath) throws FileNotFoundException, IOException {
		this.seconds = 20;
		this.publisher = MRClientFactory.createBatchingPublisher(filepath);
	}
	
	public DmaapPublisher(String filepath, long seconds) throws FileNotFoundException, IOException {
		this.seconds = seconds;
		this.publisher = MRClientFactory.createBatchingPublisher(filepath);
	}
	
	public void send(String json) throws IOException, InterruptedException {
		publisher.send(json);
		publisher.close(seconds, TimeUnit.SECONDS);
	}

}