byte[] reply = (byte[]) boundListOperations.rightPop(this.receiveTimeout, TimeUnit.MILLISECONDS); if (reply != null && reply.length > 0) { return createReply(reply);
@Nullable private Object createReply(byte[] reply) { Object replyMessage = this.serializer.deserialize(reply); if (replyMessage == null) { return null; } if (this.extractPayload) { return getMessageBuilderFactory() .withPayload(replyMessage); } else { return replyMessage; } }
@Test @RedisAvailable public void testRequestReplyWithMessage() { this.inboundGateway.setSerializer(new JdkSerializationRedisSerializer()); this.inboundGateway.setExtractPayload(false); this.outboundGateway.setSerializer(new JdkSerializationRedisSerializer()); this.outboundGateway.setExtractPayload(false); this.sendChannel.send(new GenericMessage<>(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); }
@Test @RedisAvailable public void testInboundGatewayStop() { Integer receiveTimeout = TestUtils.getPropertyValue(this.outboundGateway, "receiveTimeout", Integer.class); this.outboundGateway.setReceiveTimeout(1); this.inboundGateway.stop(); try { this.sendChannel.send(new GenericMessage<>("test1")); } catch (Exception e) { assertTrue(e.getMessage().contains("No reply produced")); } finally { this.outboundGateway.setReceiveTimeout(receiveTimeout); } }
@Test @RedisAvailable public void testNullSerializer() { Integer receiveTimeout = TestUtils.getPropertyValue(this.outboundGateway, "receiveTimeout", Integer.class); this.outboundGateway.setReceiveTimeout(1); this.inboundGateway.setSerializer(null); try { this.sendChannel.send(new GenericMessage<>("test1")); } catch (Exception e) { assertTrue(e.getMessage().contains("No reply produced")); } finally { this.inboundGateway.setSerializer(new StringRedisSerializer()); this.outboundGateway.setReceiveTimeout(receiveTimeout); } }
@Nullable private Object createReply(byte[] reply) { Object replyMessage = this.serializer.deserialize(reply); if (replyMessage == null) { return null; } if (this.extractPayload) { return getMessageBuilderFactory() .withPayload(replyMessage); } else { return replyMessage; } }
byte[] reply = (byte[]) boundListOperations.rightPop(this.receiveTimeout, TimeUnit.MILLISECONDS); if (reply != null && reply.length > 0) { return createReply(reply);