Example usage for org.springframework.integration.gateway GatewayProxyFactoryBean setDefaultReplyTimeout

List of usage examples for org.springframework.integration.gateway GatewayProxyFactoryBean setDefaultReplyTimeout

Introduction

In this page you can find the example usage for org.springframework.integration.gateway GatewayProxyFactoryBean setDefaultReplyTimeout.

Prototype

public void setDefaultReplyTimeout(Long defaultReplyTimeout) 

Source Link

Document

Set the default timeout value for receiving reply messages.

Usage

From source file:com.acmemotors.batch.LoaderJobConfiguration.java

@Bean
public GatewayProxyFactoryBean gatewayProxyFactoryBean() {
    GatewayProxyFactoryBean gatewayProxyFactoryBean = new GatewayProxyFactoryBean();
    gatewayProxyFactoryBean.setServiceInterface(RequestGateway.class);
    gatewayProxyFactoryBean.setDefaultRequestChannel(requestChannel());
    gatewayProxyFactoryBean.setDefaultReplyTimeout(5000l);
    return gatewayProxyFactoryBean;
}

From source file:org.springframework.integration.handler.AsyncHandlerTests.java

@Test
public void testGateway() throws Exception {
    this.whichTest = 0;
    GatewayProxyFactoryBean gpfb = new GatewayProxyFactoryBean(Foo.class);
    gpfb.setBeanFactory(mock(BeanFactory.class));
    DirectChannel input = new DirectChannel();
    gpfb.setDefaultRequestChannel(input);
    gpfb.setDefaultReplyTimeout(10000L);
    gpfb.afterPropertiesSet();//from   w w  w  . j a va 2 s .  com
    Foo foo = (Foo) gpfb.getObject();
    this.handler.setOutputChannel(null);
    EventDrivenConsumer consumer = new EventDrivenConsumer(input, this.handler);
    consumer.afterPropertiesSet();
    consumer.start();
    this.latch.countDown();
    String result = foo.exchange("foo");
    assertEquals("reply", result);
}

From source file:org.springframework.integration.handler.AsyncHandlerTests.java

@Test
public void testGatewayWithException() throws Exception {
    this.whichTest = 0;
    GatewayProxyFactoryBean gpfb = new GatewayProxyFactoryBean(Foo.class);
    gpfb.setBeanFactory(mock(BeanFactory.class));
    DirectChannel input = new DirectChannel();
    gpfb.setDefaultRequestChannel(input);
    gpfb.setDefaultReplyTimeout(10000L);
    gpfb.afterPropertiesSet();/*from  w  w  w .  j  av  a2  s  .  com*/
    Foo foo = (Foo) gpfb.getObject();
    this.handler.setOutputChannel(null);
    EventDrivenConsumer consumer = new EventDrivenConsumer(input, this.handler);
    consumer.afterPropertiesSet();
    consumer.start();
    this.latch.countDown();
    try {
        foo.exchange("foo");
    } catch (MessagingException e) {
        assertThat(e.getClass().getSimpleName(), equalTo("RuntimeException"));
        assertThat(e.getMessage(), equalTo("foo"));
    }
}