Examples of SentSavingTemplate


Examples of org.springframework.amqp.remoting.testhelper.SentSavingTemplate

  @Before
  public void initializeTestRig() throws Exception {
    // Set up the service
    TestServiceInterface testService = new TestServiceImpl();
    final AmqpInvokerServiceExporter serviceExporter = new AmqpInvokerServiceExporter();
    final SentSavingTemplate sentSavingTemplate = new SentSavingTemplate();
    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();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.