use of com.moilioncircle.redis.replicator.CloseListener in project rocketmq-externals by apache.
the class ListenerTest method closeListenerTest.
@Test
public void closeListenerTest() {
CloseListener closeListener = new RedisClosedListener(processor);
closeListener.handle(null);
}
use of com.moilioncircle.redis.replicator.CloseListener in project rocketmq-externals by apache.
the class RocketMQRedisReplicatorTest method open.
@Test
public void open() throws Exception {
Configure configure = new Configure(properties);
Replicator replicator = new RocketMQRedisReplicator(configure);
final RocketMQRedisProducer producer = new RocketMQRedisProducer(configure);
producer.open();
final AtomicInteger test = new AtomicInteger();
replicator.addEventListener(new EventListener() {
@Override
public void onEvent(Replicator replicator, Event event) {
if (event instanceof KeyValuePair<?, ?>) {
try {
boolean success = producer.send(event);
if (success) {
test.incrementAndGet();
}
} catch (Exception e) {
LOGGER.error("Fail to send KeyValuePair", e);
}
} else if (event instanceof Command) {
try {
boolean success = producer.send(event);
if (success) {
test.incrementAndGet();
}
} catch (Exception e) {
LOGGER.error("Fail to send command", e);
}
}
}
});
replicator.addCloseListener(new CloseListener() {
@Override
public void handle(Replicator replicator) {
producer.close();
}
});
replicator.open();
assertEquals(19, test.get());
}
Aggregations