use of org.redisson.api.RedissonReactiveClient in project redisson by redisson.
the class RedissonRemoteServiceTest method testReactive.
@Test
public void testReactive() throws InterruptedException {
RedissonReactiveClient r1 = Redisson.create(createConfig()).reactive();
r1.getRemoteService().register(RemoteInterface.class, new RemoteImpl());
RedissonReactiveClient r2 = Redisson.create(createConfig()).reactive();
RemoteInterfaceReactive ri = r2.getRemoteService().get(RemoteInterfaceReactive.class);
Mono<Void> f = ri.voidMethod("someName", 100L);
f.block();
Mono<Long> resFuture = ri.resultMethod(100L);
assertThat(resFuture.block()).isEqualTo(200);
r1.shutdown();
r2.shutdown();
}
use of org.redisson.api.RedissonReactiveClient in project redisson by redisson.
the class RedissonRemoteServiceTest method testCancelReactive.
@Test
public void testCancelReactive() throws InterruptedException {
RedissonReactiveClient r1 = Redisson.create(createConfig()).reactive();
AtomicInteger iterations = new AtomicInteger();
ExecutorService executor = Executors.newSingleThreadExecutor();
r1.getKeys().flushall();
r1.getRemoteService().register(RemoteInterface.class, new RemoteImpl(iterations), 1, executor);
RedissonReactiveClient r2 = Redisson.create(createConfig()).reactive();
RemoteInterfaceReactive ri = r2.getRemoteService().get(RemoteInterfaceReactive.class);
Mono<Void> f = ri.cancelMethod();
Disposable t = f.doOnSubscribe(s -> s.request(1)).subscribe();
Thread.sleep(500);
t.dispose();
executor.shutdown();
r1.shutdown();
r2.shutdown();
assertThat(iterations.get()).isLessThan(Integer.MAX_VALUE / 2);
assertThat(executor.awaitTermination(2, TimeUnit.SECONDS)).isTrue();
}
use of org.redisson.api.RedissonReactiveClient in project redisson by redisson.
the class RedissonReferenceReactiveTest method shouldUseDefaultCodec.
@Test
public void shouldUseDefaultCodec() throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
objectMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
JsonJacksonCodec codec = new JsonJacksonCodec(objectMapper);
Config config = new Config();
config.setCodec(codec);
config.useSingleServer().setAddress(RedisRunner.getDefaultRedisServerBindAddressAndPort());
RedissonReactiveClient reactive = Redisson.create(config).reactive();
RBucketReactive<Object> b1 = reactive.getBucket("b1");
sync(b1.set(new MyObject()));
RSetReactive<Object> s1 = reactive.getSet("s1");
Assertions.assertTrue(sync(s1.add(b1)));
Assertions.assertTrue(codec == b1.getCodec());
RedissonReactiveClient reactive1 = Redisson.create(config).reactive();
RSetReactive<RBucketReactive> s2 = reactive1.getSet("s1");
RBucketReactive<MyObject> b2 = sync(s2.iterator(1));
Assertions.assertTrue(codec == b2.getCodec());
Assertions.assertTrue(sync(b2.get()) instanceof MyObject);
reactive.shutdown();
reactive1.shutdown();
}
Aggregations