Merge "Cleanup project's name in Sonar"
[so.git] / bpmn / MSOCommonBPMN / src / main / java / org / openecomp / mso / client / dmaap / DmaapPublisher.java
1 package org.openecomp.mso.client.dmaap;
2
3 import java.io.FileNotFoundException;
4 import java.io.IOException;
5 import java.util.concurrent.TimeUnit;
6
7 import com.att.nsa.mr.client.MRBatchingPublisher;
8 import com.att.nsa.mr.client.MRClientFactory;
9
10 public class DmaapPublisher {
11         
12         private final long seconds;
13         private final MRBatchingPublisher publisher;
14         
15         public DmaapPublisher(String filepath) throws FileNotFoundException, IOException {
16                 this.seconds = 20;
17                 this.publisher = MRClientFactory.createBatchingPublisher(filepath);
18         }
19         
20         public DmaapPublisher(String filepath, long seconds) throws FileNotFoundException, IOException {
21                 this.seconds = seconds;
22                 this.publisher = MRClientFactory.createBatchingPublisher(filepath);
23         }
24         
25         public void send(String json) throws IOException, InterruptedException {
26                 publisher.send(json);
27                 publisher.close(seconds, TimeUnit.SECONDS);
28         }
29
30 }