use of org.springframework.data.redis.serializer.StringRedisSerializer in project spring-integration by spring-projects.
the class RedisQueueOutboundChannelAdapterTests method testInt3015Default.
@Test
@RedisAvailable
public void testInt3015Default() throws Exception {
final String queueName = "si.test.testRedisQueueOutboundChannelAdapter";
final RedisQueueOutboundChannelAdapter handler = new RedisQueueOutboundChannelAdapter(queueName, this.connectionFactory);
String payload = "testing";
handler.handleMessage(MessageBuilder.withPayload(payload).build());
RedisTemplate<String, ?> redisTemplate = new StringRedisTemplate();
redisTemplate.setConnectionFactory(this.connectionFactory);
redisTemplate.afterPropertiesSet();
Object result = redisTemplate.boundListOps(queueName).rightPop(5000, TimeUnit.MILLISECONDS);
assertNotNull(result);
assertEquals(payload, result);
Date payload2 = new Date();
handler.handleMessage(MessageBuilder.withPayload(payload2).build());
RedisTemplate<String, ?> redisTemplate2 = new RedisTemplate<String, Object>();
redisTemplate2.setConnectionFactory(this.connectionFactory);
redisTemplate2.setEnableDefaultSerializer(false);
redisTemplate2.setKeySerializer(new StringRedisSerializer());
redisTemplate2.setValueSerializer(new JdkSerializationRedisSerializer());
redisTemplate2.afterPropertiesSet();
Object result2 = redisTemplate2.boundListOps(queueName).rightPop(5000, TimeUnit.MILLISECONDS);
assertNotNull(result2);
assertEquals(payload2, result2);
}
use of org.springframework.data.redis.serializer.StringRedisSerializer in project spring-integration by spring-projects.
the class RedisStoreWritingMessageHandlerTests method initTemplate.
private <K, V> RedisTemplate<K, V> initTemplate(RedisConnectionFactory rcf, RedisTemplate<K, V> redisTemplate) {
redisTemplate.setConnectionFactory(rcf);
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
use of org.springframework.data.redis.serializer.StringRedisSerializer in project spring-integration by spring-projects.
the class AggregatorWithRedisLocksTests method createTemplate.
private RedisTemplate<String, ?> createTemplate() {
RedisTemplate<String, ?> template = new RedisTemplate<String, Object>();
template.setConnectionFactory(this.getConnectionFactoryForTest());
template.setKeySerializer(new StringRedisSerializer());
template.afterPropertiesSet();
return template;
}
use of org.springframework.data.redis.serializer.StringRedisSerializer in project spring-integration by spring-projects.
the class RedisStoreWritingMessageHandler method onInit.
@Override
protected void onInit() throws Exception {
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.getBeanFactory());
Assert.state(!this.mapKeyExpressionExplicitlySet || (this.collectionType == CollectionType.MAP || this.collectionType == CollectionType.PROPERTIES), "'mapKeyExpression' can only be set for CollectionType.MAP or CollectionType.PROPERTIES");
if (!this.redisTemplateExplicitlySet) {
if (!this.extractPayloadElements) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
StringRedisSerializer serializer = new StringRedisSerializer();
template.setKeySerializer(serializer);
template.setHashKeySerializer(serializer);
this.redisTemplate = template;
}
this.redisTemplate.setConnectionFactory(this.connectionFactory);
this.redisTemplate.afterPropertiesSet();
}
this.initialized = true;
}
use of org.springframework.data.redis.serializer.StringRedisSerializer 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);
}
Aggregations