+ change default serializer for MessageListener adapter (since messages are usually strings)
+ rename serializer setter on MessageContainer
This commit is contained in:
@@ -78,7 +78,10 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
|||||||
if (usePool) {
|
if (usePool) {
|
||||||
return pool.getResource();
|
return pool.getResource();
|
||||||
}
|
}
|
||||||
return new Jedis(getShardInfo());
|
Jedis jedis = new Jedis(getShardInfo());
|
||||||
|
// force initialization (see Jedis issue #82)
|
||||||
|
jedis.connect();
|
||||||
|
return jedis;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new DataAccessResourceFailureException("Cannot get Jedis connection", ex);
|
throw new DataAccessResourceFailureException("Cannot get Jedis connection", ex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ public class RedisMessageListenerContainer implements InitializingBean, Disposab
|
|||||||
*
|
*
|
||||||
* @param serializer The serializer to set.
|
* @param serializer The serializer to set.
|
||||||
*/
|
*/
|
||||||
public void setSerializer(RedisSerializer<String> serializer) {
|
public void setTopicSerializer(RedisSerializer<String> serializer) {
|
||||||
this.serializer = serializer;
|
this.serializer = serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.springframework.data.keyvalue.redis.connection.Message;
|
|||||||
import org.springframework.data.keyvalue.redis.connection.MessageListener;
|
import org.springframework.data.keyvalue.redis.connection.MessageListener;
|
||||||
import org.springframework.data.keyvalue.redis.serializer.JdkSerializationRedisSerializer;
|
import org.springframework.data.keyvalue.redis.serializer.JdkSerializationRedisSerializer;
|
||||||
import org.springframework.data.keyvalue.redis.serializer.RedisSerializer;
|
import org.springframework.data.keyvalue.redis.serializer.RedisSerializer;
|
||||||
|
import org.springframework.data.keyvalue.redis.serializer.StringRedisSerializer;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.MethodInvoker;
|
import org.springframework.util.MethodInvoker;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
@@ -62,6 +63,10 @@ import org.springframework.util.ObjectUtils;
|
|||||||
* For further examples and discussion please do refer to the Spring Data
|
* For further examples and discussion please do refer to the Spring Data
|
||||||
* reference documentation which describes this class (and its attendant
|
* reference documentation which describes this class (and its attendant
|
||||||
* configuration) in detail.
|
* configuration) in detail.
|
||||||
|
*
|
||||||
|
* <b>Important:</b> Due to the nature of messages, the default serializer used by
|
||||||
|
* the adapter is {@link StringRedisSerializer}. If the messages are of a different type,
|
||||||
|
* change them accordingly through {@link #setSerializer(RedisSerializer)}.
|
||||||
*
|
*
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @author Costin Leau
|
* @author Costin Leau
|
||||||
@@ -200,7 +205,7 @@ public class MessageListenerAdapter implements MessageListener {
|
|||||||
* @see JdkSerializationRedisSerializer
|
* @see JdkSerializationRedisSerializer
|
||||||
*/
|
*/
|
||||||
protected void initDefaultStrategies() {
|
protected void initDefaultStrategies() {
|
||||||
setSerializer(new JdkSerializationRedisSerializer());
|
setSerializer(new StringRedisSerializer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user