@Override public Long publish(byte[] channel, byte[] message) { return convertAndReturn(delegate.publish(channel, message), identityConverter); }
@Override public void convertAndSend(String channel, Object message) { Assert.hasText(channel, "a non-empty channel is required"); byte[] rawChannel = rawString(channel); byte[] rawMessage = rawValue(message); execute(connection -> { connection.publish(rawChannel, rawMessage); return null; }, true); }
@Test @RedisAvailable public void testInboundChannelAdapterMessaging() throws Exception { RedisInboundChannelAdapter adapter = context.getBean("adapter", RedisInboundChannelAdapter.class); this.awaitContainerSubscribedWithPatterns(TestUtils.getPropertyValue(adapter, "container", RedisMessageListenerContainer.class)); RedisConnectionFactory connectionFactory = this.getConnectionFactoryForTest(); connectionFactory.getConnection().publish("foo".getBytes(), "Hello Redis from foo".getBytes()); connectionFactory.getConnection().publish("bar".getBytes(), "Hello Redis from bar".getBytes()); QueueChannel receiveChannel = context.getBean("receiveChannel", QueueChannel.class); for (int i = 0; i < 3; i++) { Message<?> receive = receiveChannel.receive(10000); assertNotNull(receive); assertThat(receive.getPayload(), Matchers.<Object>isOneOf("Hello Redis from foo", "Hello Redis from bar")); } adapter.stop(); }
@Override public Long publish(byte[] channel, byte[] message) { return redisConnection.publish(channel, message); }
@Override public Long publish(byte[] channel, byte[] message) { return convertAndReturn(delegate.publish(channel, message), identityConverter); }
@Override protected boolean doPublish(String topic, String message) { redisTemplate.execute((RedisCallback<Void>) connection -> { connection.publish(topic.getBytes(), message.getBytes()); return null; }); return true; }
@Override public boolean publish(String topic, String message) { logger.trace("[MQ] publish {}:{}", topic, message); redisTemplate.execute((RedisCallback<Void>) connection -> { connection.publish(topic.getBytes(), message.getBytes()); return null; }); return true; }
@Override public Long publish(byte[] channel, byte[] message) { return convertAndReturn(delegate.publish(channel, message), identityConverter); }
@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(); } } }
@Override public void convertAndSend(String channel, Object message) { Assert.hasText(channel, "a non-empty channel is required"); byte[] rawChannel = rawString(channel); byte[] rawMessage = rawValue(message); execute(connection -> { connection.publish(rawChannel, rawMessage); return null; }, true); }
@Override public void convertAndSend(String channel, Object message) { Assert.hasText(channel, "a non-empty channel is required"); byte[] rawChannel = rawString(channel); byte[] rawMessage = rawValue(message); execute(connection -> { connection.publish(rawChannel, rawMessage); return null; }, true); }