@Override public Flux<? extends Message<String, V>> listenTo(Topic... topics) { ReactiveRedisMessageListenerContainer container = new ReactiveRedisMessageListenerContainer(getConnectionFactory()); return container .receive(Arrays.asList(topics), getSerializationContext().getStringSerializationPair(), getSerializationContext().getValueSerializationPair()) // .doFinally((signalType) -> container.destroyLater().subscribeOn(Schedulers.elastic())); }
/** * Executes the given action object within a connection that can be exposed or not. Additionally, the connection can * be pipelined. Note the results of the pipeline are discarded (making it suitable for write-only scenarios). * * @param <T> return type * @param action callback object to execute * @param exposeConnection whether to enforce exposure of the native Redis Connection to callback code * @return object returned by the action */ private <T> Publisher<T> doInConnection(ReactiveRedisCallback<T> action, boolean exposeConnection) { Assert.notNull(action, "Callback object must not be null"); ReactiveRedisConnectionFactory factory = getConnectionFactory(); ReactiveRedisConnection conn = factory.getReactiveConnection(); ReactiveRedisConnection connToUse = preProcessConnection(conn, false); ReactiveRedisConnection connToExpose = (exposeConnection ? connToUse : createRedisConnectionProxy(connToUse)); Publisher<T> result = action.doInRedis(connToExpose); return Flux.from(postProcessResult(result, connToUse, false)).doFinally(signal -> conn.close()); }
/** * Executes the given action object within a connection that can be exposed or not. Additionally, the connection can * be pipelined. Note the results of the pipeline are discarded (making it suitable for write-only scenarios). * * @param <T> return type * @param action callback object to execute * @param exposeConnection whether to enforce exposure of the native Redis Connection to callback code * @return object returned by the action */ public <T> Flux<T> execute(ReactiveRedisCallback<T> action, boolean exposeConnection) { Assert.notNull(action, "Callback object must not be null"); ReactiveRedisConnectionFactory factory = getConnectionFactory(); ReactiveRedisConnection conn = factory.getReactiveConnection(); try { ReactiveRedisConnection connToUse = preProcessConnection(conn, false); ReactiveRedisConnection connToExpose = (exposeConnection ? connToUse : createRedisConnectionProxy(connToUse)); Publisher<T> result = action.doInRedis(connToExpose); return Flux.from(postProcessResult(result, connToUse, false)).doFinally(signalType -> conn.close()); } catch (RuntimeException e) { conn.close(); throw e; } }
@Override public Flux<? extends Message<String, V>> listenTo(Topic... topics) { ReactiveRedisMessageListenerContainer container = new ReactiveRedisMessageListenerContainer(getConnectionFactory()); return container .receive(Arrays.asList(topics), getSerializationContext().getStringSerializationPair(), getSerializationContext().getValueSerializationPair()) // .doFinally((signalType) -> container.destroyLater().subscribeOn(Schedulers.elastic())); }
/** * Executes the given action object within a connection that can be exposed or not. Additionally, the connection can * be pipelined. Note the results of the pipeline are discarded (making it suitable for write-only scenarios). * * @param <T> return type * @param action callback object to execute * @param exposeConnection whether to enforce exposure of the native Redis Connection to callback code * @return object returned by the action */ private <T> Publisher<T> doInConnection(ReactiveRedisCallback<T> action, boolean exposeConnection) { Assert.notNull(action, "Callback object must not be null"); ReactiveRedisConnectionFactory factory = getConnectionFactory(); ReactiveRedisConnection conn = factory.getReactiveConnection(); ReactiveRedisConnection connToUse = preProcessConnection(conn, false); ReactiveRedisConnection connToExpose = (exposeConnection ? connToUse : createRedisConnectionProxy(connToUse)); Publisher<T> result = action.doInRedis(connToExpose); return Flux.from(postProcessResult(result, connToUse, false)).doFinally(signal -> conn.close()); }
@Override public Flux<? extends Message<String, V>> listenTo(Topic... topics) { ReactiveRedisMessageListenerContainer container = new ReactiveRedisMessageListenerContainer(getConnectionFactory()); return container .receive(Arrays.asList(topics), getSerializationContext().getStringSerializationPair(), getSerializationContext().getValueSerializationPair()) // .doFinally((signalType) -> container.destroyLater().subscribeOn(Schedulers.elastic())); }
/** * Executes the given action object within a connection that can be exposed or not. Additionally, the connection can * be pipelined. Note the results of the pipeline are discarded (making it suitable for write-only scenarios). * * @param <T> return type * @param action callback object to execute * @param exposeConnection whether to enforce exposure of the native Redis Connection to callback code * @return object returned by the action */ private <T> Publisher<T> doInConnection(ReactiveRedisCallback<T> action, boolean exposeConnection) { Assert.notNull(action, "Callback object must not be null"); ReactiveRedisConnectionFactory factory = getConnectionFactory(); ReactiveRedisConnection conn = factory.getReactiveConnection(); ReactiveRedisConnection connToUse = preProcessConnection(conn, false); ReactiveRedisConnection connToExpose = (exposeConnection ? connToUse : createRedisConnectionProxy(connToUse)); Publisher<T> result = action.doInRedis(connToExpose); return Flux.from(postProcessResult(result, connToUse, false)).doFinally(signal -> conn.close()); }
/** * Executes the given action object within a connection that can be exposed or not. Additionally, the connection can * be pipelined. Note the results of the pipeline are discarded (making it suitable for write-only scenarios). * * @param <T> return type * @param action callback object to execute * @param exposeConnection whether to enforce exposure of the native Redis Connection to callback code * @return object returned by the action */ public <T> Flux<T> execute(ReactiveRedisCallback<T> action, boolean exposeConnection) { Assert.notNull(action, "Callback object must not be null"); ReactiveRedisConnectionFactory factory = getConnectionFactory(); ReactiveRedisConnection conn = factory.getReactiveConnection(); try { ReactiveRedisConnection connToUse = preProcessConnection(conn, false); ReactiveRedisConnection connToExpose = (exposeConnection ? connToUse : createRedisConnectionProxy(connToUse)); Publisher<T> result = action.doInRedis(connToExpose); return Flux.from(postProcessResult(result, connToUse, false)).doFinally(signalType -> conn.close()); } catch (RuntimeException e) { conn.close(); throw e; } }
/** * Executes the given action object within a connection that can be exposed or not. Additionally, the connection can * be pipelined. Note the results of the pipeline are discarded (making it suitable for write-only scenarios). * * @param <T> return type * @param action callback object to execute * @param exposeConnection whether to enforce exposure of the native Redis Connection to callback code * @return object returned by the action */ public <T> Flux<T> execute(ReactiveRedisCallback<T> action, boolean exposeConnection) { Assert.notNull(action, "Callback object must not be null"); ReactiveRedisConnectionFactory factory = getConnectionFactory(); ReactiveRedisConnection conn = factory.getReactiveConnection(); try { ReactiveRedisConnection connToUse = preProcessConnection(conn, false); ReactiveRedisConnection connToExpose = (exposeConnection ? connToUse : createRedisConnectionProxy(connToUse)); Publisher<T> result = action.doInRedis(connToExpose); return Flux.from(postProcessResult(result, connToUse, false)).doFinally(signalType -> conn.close()); } catch (RuntimeException e) { conn.close(); throw e; } }