Search in sources :

Example 16 with JdkSerializationRedisSerializer

use of org.springframework.data.redis.serializer.JdkSerializationRedisSerializer in project spring-integration by spring-projects.

the class RedisQueueGatewayIntegrationTests method testRequestReplyWithMessage.

@Test
@RedisAvailable
public void testRequestReplyWithMessage() throws Exception {
    this.inboundGateway.setSerializer(new JdkSerializationRedisSerializer());
    this.inboundGateway.setExtractPayload(false);
    this.outboundGateway.setSerializer(new JdkSerializationRedisSerializer());
    this.outboundGateway.setExtractPayload(false);
    this.sendChannel.send(new GenericMessage<Integer>(2));
    Message<?> receive = this.outputChannel.receive(10000);
    assertNotNull(receive);
    assertEquals(3, receive.getPayload());
    this.inboundGateway.setSerializer(new StringRedisSerializer());
    this.inboundGateway.setExtractPayload(true);
    this.outboundGateway.setSerializer(new StringRedisSerializer());
    this.outboundGateway.setExtractPayload(true);
}
Also used : StringRedisSerializer(org.springframework.data.redis.serializer.StringRedisSerializer) JdkSerializationRedisSerializer(org.springframework.data.redis.serializer.JdkSerializationRedisSerializer) RedisAvailable(org.springframework.integration.redis.rules.RedisAvailable) Test(org.junit.Test)

Example 17 with JdkSerializationRedisSerializer

use of org.springframework.data.redis.serializer.JdkSerializationRedisSerializer in project dq-easy-cloud by dq-open-cloud.

the class EcDefaultRedisConfig method redisTemplateValueSerializer.

/**
 * <p>
 * 实例化 RedisTemplate 对象--保存的值为对象经过jdk序列化后的对象
 * </p>
 *
 * @return
 * @author daiqi
 * @date 2017年12月7日 下午5:19:51
 */
@Bean(value = EcRedisTemplateName.REDIS_TEMPLATE_VALUE_SERIALIZER_NAME)
public RedisTemplate<String, Object> redisTemplateValueSerializer(@Qualifier(value = "defaultRedisConnectionFactory") RedisConnectionFactory redisConnectionFactory) {
    RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
    redisTemplate.setKeySerializer(new StringRedisSerializer());
    redisTemplate.setHashKeySerializer(new StringRedisSerializer());
    redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
    redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
    redisTemplate.setConnectionFactory(redisConnectionFactory);
    return redisTemplate;
}
Also used : StringRedisSerializer(org.springframework.data.redis.serializer.StringRedisSerializer) StringRedisTemplate(org.springframework.data.redis.core.StringRedisTemplate) RedisTemplate(org.springframework.data.redis.core.RedisTemplate) JdkSerializationRedisSerializer(org.springframework.data.redis.serializer.JdkSerializationRedisSerializer) Bean(org.springframework.context.annotation.Bean)

Example 18 with JdkSerializationRedisSerializer

use of org.springframework.data.redis.serializer.JdkSerializationRedisSerializer in project new-cloud by xie-summer.

the class RedisCacheConfig method redisTemplate.

@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
    RedisTemplate<String, Object> template = new RedisTemplate<>();
    template.setConnectionFactory(redisConnectionFactory);
    template.setKeySerializer(new StringRedisSerializer());
    template.setValueSerializer(new JdkSerializationRedisSerializer());
    return template;
}
Also used : StringRedisSerializer(org.springframework.data.redis.serializer.StringRedisSerializer) RedisTemplate(org.springframework.data.redis.core.RedisTemplate) JdkSerializationRedisSerializer(org.springframework.data.redis.serializer.JdkSerializationRedisSerializer) Bean(org.springframework.context.annotation.Bean)

Aggregations

JdkSerializationRedisSerializer (org.springframework.data.redis.serializer.JdkSerializationRedisSerializer)18 StringRedisSerializer (org.springframework.data.redis.serializer.StringRedisSerializer)14 Test (org.junit.Test)12 RedisTemplate (org.springframework.data.redis.core.RedisTemplate)11 StringRedisTemplate (org.springframework.data.redis.core.StringRedisTemplate)11 RedisAvailable (org.springframework.integration.redis.rules.RedisAvailable)9 BeanFactory (org.springframework.beans.factory.BeanFactory)5 Date (java.util.Date)4 Bean (org.springframework.context.annotation.Bean)4 QueueChannel (org.springframework.integration.channel.QueueChannel)4 Message (org.springframework.messaging.Message)3 PollableChannel (org.springframework.messaging.PollableChannel)3 ErrorMessage (org.springframework.messaging.support.ErrorMessage)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 ReactiveRedisTemplate (org.springframework.data.redis.core.ReactiveRedisTemplate)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 lombok.val (lombok.val)1 Ignore (org.junit.Ignore)1