@Override public <C> RabbitConverterFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object, MessagePostProcessor messagePostProcessor) { return convertSendAndReceive(exchange, routingKey, object, messagePostProcessor, null); }
@Override public <C> RabbitConverterFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object, MessagePostProcessor messagePostProcessor) { return convertSendAndReceive(exchange, routingKey, object, messagePostProcessor, null); }
@Override public <C> RabbitConverterFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object) { return convertSendAndReceive(exchange, routingKey, object, null); }
@Override public <C> RabbitConverterFuture<C> convertSendAndReceive(String routingKey, Object object, MessagePostProcessor messagePostProcessor) { return convertSendAndReceive(this.template.getExchange(), routingKey, object, messagePostProcessor); }
@Override public <C> RabbitConverterFuture<C> convertSendAndReceiveAsType(String exchange, String routingKey, Object object, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<C> responseType) { Assert.state(this.template.getMessageConverter() instanceof SmartMessageConverter, "template's message converter must be a SmartMessageConverter"); return convertSendAndReceive(exchange, routingKey, object, messagePostProcessor, responseType); }
@Override public <C> RabbitConverterFuture<C> convertSendAndReceive(String routingKey, Object object) { return convertSendAndReceive(this.template.getExchange(), routingKey, object, null); }
@Override public <C> RabbitConverterFuture<C> convertSendAndReceive(String routingKey, Object object, MessagePostProcessor messagePostProcessor) { return convertSendAndReceive(this.template.getExchange(), routingKey, object, messagePostProcessor); }
@Override public <C> RabbitConverterFuture<C> convertSendAndReceiveAsType(String exchange, String routingKey, Object object, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<C> responseType) { Assert.state(this.template.getMessageConverter() instanceof SmartMessageConverter, "template's message converter must be a SmartMessageConverter"); return convertSendAndReceive(exchange, routingKey, object, messagePostProcessor, responseType); }
@Override public <C> RabbitConverterFuture<C> convertSendAndReceive(String routingKey, Object object) { return convertSendAndReceive(this.template.getExchange(), routingKey, object, null); }
@Override public <C> RabbitConverterFuture<C> convertSendAndReceive(Object object, MessagePostProcessor messagePostProcessor) { return convertSendAndReceive(this.template.getExchange(), this.template.getRoutingKey(), object, messagePostProcessor); }
@Override public <C> RabbitConverterFuture<C> convertSendAndReceive(Object object) { return convertSendAndReceive(this.template.getExchange(), this.template.getRoutingKey(), object, null); }
@Override public <C> RabbitConverterFuture<C> convertSendAndReceive(Object object, MessagePostProcessor messagePostProcessor) { return convertSendAndReceive(this.template.getExchange(), this.template.getRoutingKey(), object, messagePostProcessor); }
@Test public void testConvert1Arg() throws Exception { final AtomicBoolean mppCalled = new AtomicBoolean(); ListenableFuture<String> future = this.asyncTemplate.convertSendAndReceive("foo", m -> { mppCalled.set(true); return m; }); checkConverterResult(future, "FOO"); assertTrue(mppCalled.get()); }
@Test public void testConvert2Args() throws Exception { ListenableFuture<String> future = this.asyncTemplate.convertSendAndReceive(this.requests.getName(), "foo"); checkConverterResult(future, "FOO"); }
@Test public void testCancel() throws Exception { ListenableFuture<String> future = this.asyncTemplate.convertSendAndReceive("foo"); future.cancel(false); assertEquals(0, TestUtils.getPropertyValue(asyncTemplate, "pending", Map.class).size()); }
@Test public void testConvert3Args() throws Exception { ListenableFuture<String> future = this.asyncTemplate.convertSendAndReceive("", this.requests.getName(), "foo"); checkConverterResult(future, "FOO"); }
@Test public void testConvert4Args() throws Exception { ListenableFuture<String> future = this.asyncTemplate.convertSendAndReceive("", this.requests.getName(), "foo", message -> { String body = new String(message.getBody()); return new Message((body + "bar").getBytes(), message.getMessageProperties()); }); checkConverterResult(future, "FOOBAR"); }
@Test @DirtiesContext public void testConvertWithConfirmDirect() throws Exception { this.asyncDirectTemplate.setEnableConfirms(true); RabbitConverterFuture<String> future = this.asyncDirectTemplate.convertSendAndReceive("sleep"); ListenableFuture<Boolean> confirm = future.getConfirm(); assertNotNull(confirm); assertTrue(confirm.get(10, TimeUnit.SECONDS)); checkConverterResult(future, "SLEEP"); }
@Test @DirtiesContext public void testConvertWithConfirm() throws Exception { this.asyncTemplate.setEnableConfirms(true); RabbitConverterFuture<String> future = this.asyncTemplate.convertSendAndReceive("sleep"); ListenableFuture<Boolean> confirm = future.getConfirm(); assertNotNull(confirm); assertTrue(confirm.get(10, TimeUnit.SECONDS)); checkConverterResult(future, "SLEEP"); }
@Test public void testAsyncListener() throws Exception { assertEquals("FOO", this.rabbitTemplate.convertSendAndReceive(this.queue1.getName(), "foo")); RabbitConverterFuture<Object> future = this.asyncTemplate.convertSendAndReceive(this.queue1.getName(), "foo"); assertEquals("FOO", future.get(10, TimeUnit.SECONDS)); assertEquals("FOO", this.rabbitTemplate.convertSendAndReceive(this.queue2.getName(), "foo")); }