use of org.springframework.integration.gateway.RequestReplyExchanger in project spring-integration by spring-projects.
the class RmiOutboundGateway method createProxy.
private RequestReplyExchanger createProxy(String url) {
RmiProxyFactoryBean proxyFactory = new RmiProxyFactoryBean();
proxyFactory.setServiceInterface(RequestReplyExchanger.class);
proxyFactory.setServiceUrl(url);
proxyFactory.setLookupStubOnStartup(false);
proxyFactory.setRefreshStubOnConnectFailure(true);
if (this.configurer != null) {
this.configurer.configure(proxyFactory);
}
proxyFactory.afterPropertiesSet();
return (RequestReplyExchanger) proxyFactory.getObject();
}
use of org.springframework.integration.gateway.RequestReplyExchanger in project spring-integration by spring-projects.
the class MiscellaneousTests method testTimeoutHonoringWhenRequestsQueuedUp.
/**
* Asserts that receive-timeout is honored even if
* requests (once in process), takes less then receive-timeout value
* when requests are queued up (e.g., single consumer receiver)
*/
@Test
public void testTimeoutHonoringWhenRequestsQueuedUp() throws Exception {
ActiveMqTestUtils.prepare();
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("honor-timeout.xml", this.getClass());
final RequestReplyExchanger gateway = context.getBean(RequestReplyExchanger.class);
final CountDownLatch latch = new CountDownLatch(3);
final AtomicInteger replies = new AtomicInteger();
StopWatch stopWatch = new StopWatch();
stopWatch.start();
for (int i = 0; i < 3; i++) {
this.exchange(latch, gateway, replies);
}
latch.await();
stopWatch.stop();
assertTrue(stopWatch.getTotalTimeMillis() <= 18000);
assertEquals(1, replies.get());
context.close();
}
use of org.springframework.integration.gateway.RequestReplyExchanger in project spring-integration by spring-projects.
the class RequestReplyScenariosWithCorrelationKeyProvidedTests method messageCorrelationBasedCustomCorrelationKeyDelayedReplies.
@Test
public void messageCorrelationBasedCustomCorrelationKeyDelayedReplies() throws Exception {
ActiveMqTestUtils.prepare();
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("explicit-correlation-key.xml", this.getClass());
RequestReplyExchanger gateway = context.getBean("explicitCorrelationKeyGatewayC", RequestReplyExchanger.class);
for (int i = 0; i < 3; i++) {
try {
gateway.exchange(MessageBuilder.withPayload("hello").build());
} catch (Exception e) {
// ignore
}
}
JmsOutboundGateway outGateway = TestUtils.getPropertyValue(context.getBean("outGateway"), "handler", JmsOutboundGateway.class);
outGateway.setReceiveTimeout(5000);
assertEquals("foo", gateway.exchange(MessageBuilder.withPayload("foo").build()).getPayload());
context.close();
}
use of org.springframework.integration.gateway.RequestReplyExchanger in project spring-integration by spring-projects.
the class RequestReplyScenariosWithCorrelationKeyProvidedTests method messageCorrelationBasedCustomCorrelationKey.
@Test
public void messageCorrelationBasedCustomCorrelationKey() throws Exception {
ActiveMqTestUtils.prepare();
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("explicit-correlation-key.xml", this.getClass());
RequestReplyExchanger gateway = context.getBean("explicitCorrelationKeyGateway", RequestReplyExchanger.class);
gateway.exchange(MessageBuilder.withPayload("foo").build());
context.close();
}
use of org.springframework.integration.gateway.RequestReplyExchanger in project spring-integration by spring-projects.
the class RequestReplyScenariosWithTempReplyQueuesTests method messageCorrelationBasedOnRequestMessageId.
@SuppressWarnings("resource")
@Test
public void messageCorrelationBasedOnRequestMessageId() throws Exception {
ActiveMqTestUtils.prepare();
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("producer-temp-reply-consumers.xml", this.getClass());
RequestReplyExchanger gateway = context.getBean(RequestReplyExchanger.class);
CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.class);
final JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
final Destination requestDestination = context.getBean("siOutQueue", Destination.class);
new Thread(() -> {
final Message requestMessage = jmsTemplate.receive(requestDestination);
Destination replyTo = null;
try {
replyTo = requestMessage.getJMSReplyTo();
} catch (Exception e) {
fail();
}
jmsTemplate.send(replyTo, (MessageCreator) session -> {
try {
TextMessage message = session.createTextMessage();
message.setText("bar");
message.setJMSCorrelationID(requestMessage.getJMSMessageID());
return message;
} catch (Exception e) {
}
return null;
});
}).start();
gateway.exchange(new GenericMessage<String>("foo"));
context.close();
}
Aggregations