public Object sendAndReceive(String route, Object message) { return amqpTemplate.convertSendAndReceive(route, message); } }
@Test public void testAmqpInboundGatewayFlow() { assertNotNull(this.amqpInboundGatewayContainer); assertSame(this.amqpTemplate, TestUtils.getPropertyValue(this.amqpInboundGateway, "amqpTemplate")); Object result = this.amqpTemplate.convertSendAndReceive(this.amqpQueue.getName(), "world"); assertEquals("HELLO WORLD", result); this.amqpInboundGateway.stop(); //INTEXT-209 this.amqpInboundGateway.start(); this.amqpTemplate.convertAndSend(this.amqpQueue.getName(), "world"); ((RabbitTemplate) this.amqpTemplate).setReceiveTimeout(10000); result = this.amqpTemplate.receiveAndConvert("defaultReplyTo"); assertEquals("HELLO WORLD", result); }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { RemoteInvocation remoteInvocation = getRemoteInvocationFactory().createRemoteInvocation(invocation); Object rawResult; if (getRoutingKey() == null) { // Use the template's default routing key rawResult = this.amqpTemplate.convertSendAndReceive(remoteInvocation); } else { rawResult = this.amqpTemplate.convertSendAndReceive(this.routingKey, remoteInvocation); } if (rawResult == null) { throw new RemoteProxyFailureException("No reply received from '" + remoteInvocation.getMethodName() + "' with arguments '" + Arrays.asList(remoteInvocation.getArguments()) + // NOSONAR (null) "' - perhaps a timeout in the template?", null); } else if (!(rawResult instanceof RemoteInvocationResult)) { throw new RemoteProxyFailureException("Expected a result of type " + RemoteInvocationResult.class.getCanonicalName() + " but found " + rawResult.getClass().getCanonicalName(), null); // NOSONAR (null) } RemoteInvocationResult result = (RemoteInvocationResult) rawResult; return result.recreate(); }
@Test public void testAmqpInboundGatewayFlow() throws Exception { Object result = this.amqpTemplate.convertSendAndReceive(this.amqpQueue.getName(), "world"); assertEquals("HELLO WORLD", result); this.amqpInboundGateway.stop(); //INTEXT-209 this.amqpInboundGateway.start(); this.amqpTemplate.convertAndSend(this.amqpQueue.getName(), "world"); ((RabbitTemplate) this.amqpTemplate).setReceiveTimeout(10000); result = this.amqpTemplate.receiveAndConvert("defaultReplyTo"); assertEquals("HELLO WORLD", result); assertSame(this.amqpTemplate, TestUtils.getPropertyValue(this.amqpInboundGateway, "amqpTemplate")); }