INT-851 Added method name to the "name" property of the MessageHistory.Event for a gateway.
This commit is contained in:
@@ -45,7 +45,7 @@ public class MessageHistory implements Iterable<MessageHistory.Event>, Serializa
|
||||
|
||||
|
||||
public static enum ComponentType {
|
||||
channel, endpoint;
|
||||
channel, endpoint, gateway;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.springframework.integration.annotation.Headers;
|
||||
import org.springframework.integration.annotation.Payload;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.core.MessageHistory.ComponentType;
|
||||
import org.springframework.integration.message.InboundMessageMapper;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.MessageHandlingException;
|
||||
@@ -154,7 +155,11 @@ public class ArgumentArrayMessageMapper implements InboundMessageMapper<Object[]
|
||||
throw new IllegalArgumentException(prefix + " parameters provided for method [" + method +
|
||||
"], expected " + this.parameterList.size() + " but received " + arguments.length + ".");
|
||||
}
|
||||
return this.mapArgumentsToMessage(arguments);
|
||||
Message<?> message = this.mapArgumentsToMessage(arguments);
|
||||
if (message != null) {
|
||||
message.getHeaders().getHistory().add(ComponentType.gateway, this.method.getName());
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private Object[] mapMessageToArguments(Message<?> message) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -34,7 +35,10 @@ import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.core.MessageHistory.ComponentType;
|
||||
import org.springframework.integration.core.MessageHistory.Event;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.handler.BridgeHandler;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -249,12 +253,39 @@ public class GatewayProxyFactoryBeanTests {
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodNameInHistory() throws Exception {
|
||||
GatewayProxyFactoryBean proxyFactory = new GatewayProxyFactoryBean();
|
||||
DirectChannel channel = new DirectChannel();
|
||||
channel.setBeanName("testChannel");
|
||||
EventDrivenConsumer consumer = new EventDrivenConsumer(channel, new BridgeHandler());
|
||||
consumer.start();
|
||||
proxyFactory.setDefaultRequestChannel(channel);
|
||||
proxyFactory.setServiceInterface(TestEchoService.class);
|
||||
proxyFactory.afterPropertiesSet();
|
||||
TestEchoService proxy = (TestEchoService) proxyFactory.getObject();
|
||||
Message<?> message = proxy.echo("test");
|
||||
Iterator<Event> historyIterator = message.getHeaders().getHistory().iterator();
|
||||
Event event1 = historyIterator.next();
|
||||
Event event2 = historyIterator.next();
|
||||
assertEquals(ComponentType.gateway, event1.getComponentType());
|
||||
assertEquals("echo", event1.getComponentName());
|
||||
assertEquals(ComponentType.channel, event2.getComponentType());
|
||||
assertEquals("testChannel", event2.getComponentName());
|
||||
}
|
||||
|
||||
|
||||
public static void throwTestException() throws TestException {
|
||||
throw new TestException();
|
||||
}
|
||||
|
||||
|
||||
static interface TestEchoService {
|
||||
|
||||
Message<?> echo(String s);
|
||||
}
|
||||
|
||||
|
||||
static interface TestExceptionThrowingInterface {
|
||||
|
||||
String throwCheckedException(String s) throws TestException;
|
||||
|
||||
Reference in New Issue
Block a user