use of org.apache.rya.periodic.notification.serialization.CommandNotificationSerializer in project incubator-rya by apache.
the class PeriodicNotificationApplicationIT method init.
@Before
public void init() throws Exception {
final String topic = rule.getKafkaTopicName();
rule.createTopic(topic);
// get user specified props and update with the embedded kafka bootstrap servers and rule generated topic
props = getProps();
props.setProperty(NOTIFICATION_TOPIC, topic);
props.setProperty(KAFKA_BOOTSTRAP_SERVERS, bootstrapServers);
conf = new PeriodicNotificationApplicationConfiguration(props);
// create Kafka Producer
kafkaProps = getKafkaProperties(conf);
producer = new KafkaProducer<>(kafkaProps, new StringSerializer(), new CommandNotificationSerializer());
// extract kafka specific properties from application config
app = PeriodicNotificationApplicationFactory.getPeriodicApplication(conf);
registrar = new KafkaNotificationRegistrationClient(conf.getNotificationTopic(), producer);
}
use of org.apache.rya.periodic.notification.serialization.CommandNotificationSerializer in project incubator-rya by apache.
the class PeriodicCommandNotificationConsumerIT method kafkaNotificationMillisProviderTest.
@Test
public void kafkaNotificationMillisProviderTest() throws InterruptedException {
BasicConfigurator.configure();
final BlockingQueue<TimestampedNotification> notifications = new LinkedBlockingQueue<>();
final Properties props = createKafkaConfig();
final KafkaProducer<String, CommandNotification> producer = new KafkaProducer<>(props);
final String topic = rule.getKafkaTopicName();
rule.createTopic(topic);
registration = new KafkaNotificationRegistrationClient(topic, producer);
coord = new PeriodicNotificationCoordinatorExecutor(1, notifications);
provider = new KafkaNotificationProvider(topic, new StringDeserializer(), new CommandNotificationSerializer(), props, coord, 1);
provider.start();
registration.addNotification("1", 1000, 0, TimeUnit.MILLISECONDS);
Thread.sleep(4000);
// check that notifications are being added to the blocking queue
Assert.assertEquals(true, notifications.size() > 0);
registration.deleteNotification("1");
Thread.sleep(2000);
final int size = notifications.size();
// sleep for 2 seconds to ensure no more messages being produced
Thread.sleep(2000);
Assert.assertEquals(size, notifications.size());
tearDown();
}
use of org.apache.rya.periodic.notification.serialization.CommandNotificationSerializer in project incubator-rya by apache.
the class PeriodicCommandNotificationConsumerIT method kafkaNotificationProviderTest.
@Test
public void kafkaNotificationProviderTest() throws InterruptedException {
BasicConfigurator.configure();
final BlockingQueue<TimestampedNotification> notifications = new LinkedBlockingQueue<>();
final Properties props = createKafkaConfig();
final KafkaProducer<String, CommandNotification> producer = new KafkaProducer<>(props);
final String topic = rule.getKafkaTopicName();
rule.createTopic(topic);
registration = new KafkaNotificationRegistrationClient(topic, producer);
coord = new PeriodicNotificationCoordinatorExecutor(1, notifications);
provider = new KafkaNotificationProvider(topic, new StringDeserializer(), new CommandNotificationSerializer(), props, coord, 1);
provider.start();
registration.addNotification("1", 1, 0, TimeUnit.SECONDS);
Thread.sleep(4000);
// check that notifications are being added to the blocking queue
Assert.assertEquals(true, notifications.size() > 0);
registration.deleteNotification("1");
Thread.sleep(2000);
final int size = notifications.size();
// sleep for 2 seconds to ensure no more messages being produced
Thread.sleep(2000);
Assert.assertEquals(size, notifications.size());
tearDown();
}
Aggregations