GH-3386: Add method signature for gateway proxy (#3387)

* GH-3386: Add method signature for gateway proxy

Fixes https://github.com/spring-projects/spring-integration/issues/3386

All the gateway proxy method invokers are supplied with the same
bean name inherited from the proxy.

* Add method signature for proxy method bean to fine-grain the
management for those bean in the logs, message history and metrics

* * Use `Class.getSimpleName()` instead to make gateway names less verbose
This commit is contained in:
Artem Bilan
2020-09-18 15:40:32 -04:00
committed by GitHub
parent e223d341f3
commit e714310dae
7 changed files with 74 additions and 62 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,10 +17,9 @@
package org.springframework.integration.jmx;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,8 +35,7 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/**
* See INT-1688 for background.
@@ -45,10 +43,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @author Mark Fisher
* @author Artem Bilan
* @author Gary Russell
*
* @since 2.0.1
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringJUnitConfig
@DirtiesContext
public class ServiceActivatorDefaultFrameworkMethodTests {
@@ -86,7 +84,8 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
this.gatewayTestInputChannel.send(message);
Message<?> reply = replyChannel.receive(0);
assertThat(reply.getHeaders().get("history").toString())
.isEqualTo("gatewayTestInputChannel,gatewayTestService,gateway,requestChannel,bridge,replyChannel");
.isEqualTo("gatewayTestInputChannel,gatewayTestService," +
"gateway#exchange(Message),requestChannel,bridge,replyChannel");
}
@Test
@@ -170,19 +169,11 @@ public class ServiceActivatorDefaultFrameworkMethodTests {
@Test
public void testFailOnDoubleReference() {
try {
new ClassPathXmlApplicationContext(this.getClass().getSimpleName() + "-fail-context.xml",
this.getClass()).close();
fail("Expected exception due to 2 endpoints referencing the same bean");
}
catch (Exception e) {
assertThat(e).isInstanceOf(BeanCreationException.class);
assertThat(e.getCause()).isInstanceOf(BeanCreationException.class);
assertThat(e.getCause().getCause()).isInstanceOf(IllegalArgumentException.class);
assertThat(e.getCause().getCause().getMessage())
.contains("An AbstractMessageProducingMessageHandler may only be referenced once");
}
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(() ->
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-fail-context.xml", getClass()))
.withMessageContaining("An AbstractMessageProducingMessageHandler may only be referenced once")
.withRootCauseExactlyInstanceOf(IllegalArgumentException.class);
}
private interface Foo {