本文整理了Java中org.springframework.data.redis.connection.RedisConnection.isClosed
方法的一些代码示例,展示了RedisConnection.isClosed
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisConnection.isClosed
方法的具体详情如下:
包路径:org.springframework.data.redis.connection.RedisConnection
类名称:RedisConnection
方法名:isClosed
[英]Indicates whether the underlying connection is closed or not.
[中]指示基础连接是否已关闭。
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public boolean isClosed() {
return delegate.isClosed();
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
RedisCommand commandToExecute = RedisCommand.failsafeCommandLookup(method.getName());
if (isPotentiallyThreadBoundCommand(commandToExecute)) {
if (log.isDebugEnabled()) {
log.debug(String.format("Invoke '%s' on bound conneciton", method.getName()));
}
return invoke(method, obj, args);
}
if (log.isDebugEnabled()) {
log.debug(String.format("Invoke '%s' on unbound conneciton", method.getName()));
}
RedisConnection connection = factory.getConnection();
try {
return invoke(method, connection, args);
} finally {
// properly close the unbound connection after executing command
if (!connection.isClosed()) {
connection.close();
}
}
}
代码示例来源:origin: 1991wangliang/tx-lcn
@Override
public boolean isClosed() {
return redisConnection.isClosed();
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public boolean isClosed() {
return delegate.isClosed();
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public boolean isClosed() {
return delegate.isClosed();
}
代码示例来源:origin: gudaoxuri/dew
@Override
protected void doResponse(String address, Consumer<String> consumer) {
new Thread(() -> redisTemplate.execute((RedisCallback<Void>) connection -> {
while (!connection.isClosed()) {
List<byte[]> messages = connection.bRPop(30, address.getBytes());
if (messages == null) {
continue;
}
String message = new String(messages.get(1), StandardCharsets.UTF_8);
consumer.accept(message);
}
return null;
})).start();
}
}
代码示例来源:origin: aillamsun/devX
@Override
public void response(String address, Consumer<String> consumer) {
new Thread(() -> redisTemplate.execute((RedisCallback<Void>) connection -> {
try {
while (!connection.isClosed()) {
List<byte[]> messages = connection.bRPop(30, address.getBytes());
if (messages == null) {
continue;
}
String message = new String(messages.get(1), "UTF-8");
logger.trace("[MQ] response {}:{}", address, message);
consumer.accept(message);
}
} catch (Exception e) {
logger.error("Redis Response error.", e);
}
return null;
}
)).start();
}
}
代码示例来源:origin: com.ecfront.dew/cluster-spi-redis
@Override
public void response(String address, Consumer<String> consumer) {
new Thread(() -> {
RedisConnection connection = null;
try {
connection = redisTemplate.getConnectionFactory().getConnection();
while (!connection.isClosed()) {
List<byte[]> messages = connection.bRPop(30, address.getBytes());
if (messages == null) {
continue;
}
String message = new String(messages.get(1), "UTF-8");
logger.trace("[MQ] response {}:{}", address, message);
consumer.accept(message);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection != null && !connection.isClosed()) {
connection.close();
}
}
}).start();
}
代码示例来源:origin: com.ecfront.dew/cluster-spi-redis
@Override
public void request(String address, String message) {
logger.trace("[MQ] request {}:{}", address, message);
RedisConnection connection = null;
try {
connection = redisTemplate.getConnectionFactory().getConnection();
connection.lPush(address.getBytes(), message.getBytes());
} finally {
if (connection != null && !connection.isClosed()) {
connection.close();
}
}
}
代码示例来源:origin: com.ecfront.dew/cluster-spi-redis
@Override
public void publish(String topic, String message) {
logger.trace("[MQ] publish {}:{}", topic, message);
RedisConnection connection = null;
try {
connection = redisTemplate.getConnectionFactory().getConnection();
connection.publish(topic.getBytes(), message.getBytes());
} finally {
if (connection != null && !connection.isClosed()) {
connection.close();
}
}
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
RedisCommand commandToExecute = RedisCommand.failsafeCommandLookup(method.getName());
if (isPotentiallyThreadBoundCommand(commandToExecute)) {
if (log.isDebugEnabled()) {
log.debug(String.format("Invoke '%s' on bound conneciton", method.getName()));
}
return invoke(method, obj, args);
}
if (log.isDebugEnabled()) {
log.debug(String.format("Invoke '%s' on unbound conneciton", method.getName()));
}
RedisConnection connection = factory.getConnection();
try {
return invoke(method, connection, args);
} finally {
// properly close the unbound connection after executing command
if (!connection.isClosed()) {
connection.close();
}
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
RedisCommand commandToExecute = RedisCommand.failsafeCommandLookup(method.getName());
if (isPotentiallyThreadBoundCommand(commandToExecute)) {
if (log.isDebugEnabled()) {
log.debug(String.format("Invoke '%s' on bound conneciton", method.getName()));
}
return invoke(method, obj, args);
}
if (log.isDebugEnabled()) {
log.debug(String.format("Invoke '%s' on unbound conneciton", method.getName()));
}
RedisConnection connection = factory.getConnection();
try {
return invoke(method, connection, args);
} finally {
// properly close the unbound connection after executing command
if (!connection.isClosed()) {
connection.close();
}
}
}
代码示例来源:origin: com.ecfront.dew/cluster-spi-redis
@Override
public void subscribe(String topic, Consumer<String> consumer) {
RedisConnection connection = null;
try {
connection = redisTemplate.getConnectionFactory().getConnection();
connection.subscribe((message, pattern) -> {
try {
String msg = new String(message.getBody(), "UTF-8");
logger.trace("[MQ] subscribe {}:{}", topic, msg);
consumer.accept(msg);
} catch (Exception e) {
e.printStackTrace();
}
}, topic.getBytes());
} finally {
if (connection != null && !connection.isClosed()) {
connection.close();
}
}
}
代码示例来源:origin: stackoverflow.com
} finally {
if (!connection.isClosed()) {
connection.close();
内容来源于网络,如有侵权,请联系作者删除!