@Override protected void sendToRabbit(Channel channel, String exchange, String routingKey, boolean mandatory, Message message) { Listeners listenersForRoute = this.listeners.get(routingKey); if (listenersForRoute == null) { throw new IllegalArgumentException("No listener for " + routingKey); } try { invoke(listenersForRoute.next(), message, channel); } catch (Exception e) { throw RabbitExceptionTranslator.convertRabbitAccessException(e); } }
public TestRabbitTemplate(ConnectionFactory connectionFactory) { super(connectionFactory); setReplyAddress(REPLY_QUEUE); }
@Override public void afterSingletonsInstantiated() { this.registry.getListenerContainers() .stream() .map(container -> (AbstractMessageListenerContainer) container) .forEach(c -> { for (String queue : c.getQueueNames()) { setupListener(c, queue); } }); this.applicationContext.getBeansOfType(AbstractMessageListenerContainer.class).values() .stream() .forEach(container -> { for (String queue : container.getQueueNames()) { setupListener(container, queue); } }); }
Envelope envelope = new Envelope(1, false, "", REPLY_QUEUE); reply.set(MessageBuilder.withBody(i.getArgument(4)) // NOSONAR magic # .andProperties(getMessagePropertiesConverter() .toMessageProperties(i.getArgument(3), envelope, // NOSONAR magic # adapter.getEncoding()))
@Bean public TestRabbitTemplate template() throws IOException { return new TestRabbitTemplate(connectionFactory()); }
@Test public void testSimpleSends() { this.template.convertAndSend("foo", "hello1"); assertThat(this.config.fooIn, equalTo("foo:hello1")); this.template.convertAndSend("bar", "hello2"); assertThat(this.config.barIn, equalTo("bar:hello2")); assertThat(this.config.smlc1In, equalTo("smlc1:")); this.template.convertAndSend("foo", "hello3"); assertThat(this.config.fooIn, equalTo("foo:hello1")); this.template.convertAndSend("bar", "hello4"); assertThat(this.config.barIn, equalTo("bar:hello2")); assertThat(this.config.smlc1In, equalTo("smlc1:hello3hello4")); }
@Test public void testSendAndReceive() { assertThat(this.template.convertSendAndReceive("baz", "hello"), equalTo("baz:hello")); }
@Override public void afterSingletonsInstantiated() { this.registry.getListenerContainers() .stream() .map(container -> (AbstractMessageListenerContainer) container) .forEach(c -> { for (String queue : c.getQueueNames()) { setupListener(c, queue); } }); this.applicationContext.getBeansOfType(AbstractMessageListenerContainer.class).values() .stream() .forEach(container -> { for (String queue : container.getQueueNames()) { setupListener(container, queue); } }); }
Envelope envelope = new Envelope(1, false, "", REPLY_QUEUE); reply.set(MessageBuilder.withBody(i.getArgument(4)) // NOSONAR magic # .andProperties(getMessagePropertiesConverter() .toMessageProperties(i.getArgument(3), envelope, // NOSONAR magic # adapter.getEncoding()))
public TestRabbitTemplate(ConnectionFactory connectionFactory) { super(connectionFactory); setReplyAddress(REPLY_QUEUE); }
@Override protected void sendToRabbit(Channel channel, String exchange, String routingKey, boolean mandatory, Message message) { Listeners listenersForRoute = this.listeners.get(routingKey); if (listenersForRoute == null) { throw new IllegalArgumentException("No listener for " + routingKey); } try { invoke(listenersForRoute.next(), message, channel); } catch (Exception e) { throw RabbitExceptionTranslator.convertRabbitAccessException(e); } }