serviceExporter.setAmqpTemplate(sentSavingTemplate);
serviceExporter.setService(testService);
serviceExporter.setServiceInterface(TestServiceInterface.class);
// Set up the client
AmqpProxyFactoryBean amqpProxyFactoryBean = new AmqpProxyFactoryBean();
amqpProxyFactoryBean.setServiceInterface(TestServiceInterface.class);
AmqpTemplate directForwardingTemplate = new AbstractAmqpTemplate() {
@Override
public Object convertSendAndReceive(Object payload) throws AmqpException {
MessageConverter messageConverter = serviceExporter.getMessageConverter();
Address replyTo = new Address("fakeExchangeName", "fakeRoutingKey");
MessageProperties messageProperties = new MessageProperties();
messageProperties.setReplyToAddress(replyTo);
Message message = messageConverter.toMessage(payload, messageProperties);
serviceExporter.onMessage(message);
Message resultMessage = sentSavingTemplate.getLastMessage();
return messageConverter.fromMessage(resultMessage);
}
};
amqpProxyFactoryBean.setAmqpTemplate(directForwardingTemplate);
amqpProxyFactoryBean.afterPropertiesSet();
Object rawProxy = amqpProxyFactoryBean.getObject();
riggedProxy = (TestServiceInterface) rawProxy;
}