此版本仍在开发中,尚不被认为是稳定的。对于最新的稳定版本,请使用 Spring Integration 6.5.1spring-doc.cadn.net.cn

控制总线控制器

从 6.4 版开始,HTTP 模块提供了一个@EnableControlBusController配置类注释以公开ControlBusController作为 REST 服务,在/control-bus路径。 这ControlBusControllerConfigurationunderneath 启用ControlBusCommandRegistry以公开上述 REST 服务的所有可用控制总线命令。 这/control-busGET 请求以如下格式返回应用程序的所有控制总线命令:spring-doc.cadn.net.cn

[
  {
    "beanName": "errorChannel",
    "commands": [
      {
        "command": "errorChannel.setShouldTrack",
        "description": "setShouldTrack",
        "parameterTypes": [
          "boolean"
        ]
      },
      {
        "command": "errorChannel.setLoggingEnabled",
        "description": "Use to disable debug logging during normal message flow",
        "parameterTypes": [
          "boolean"
        ]
      },
      {
        "command": "errorChannel.isLoggingEnabled",
        "description": "isLoggingEnabled",
        "parameterTypes": []
      }
    ]
  },
  {
    "beanName": "testManagementComponent",
    "commands": [
      {
        "command": "testManagementComponent.operation2",
        "description": "operation2",
        "parameterTypes": []
      },
      {
        "command": "testManagementComponent.operation",
        "description": "operation",
        "parameterTypes": []
      },
      {
        "command": "testManagementComponent.operation",
        "description": "operation",
        "parameterTypes": [
          "int",
          "java.lang.String"
        ]
      },
      {
        "command": "testManagementComponent.operation",
        "description": "operation",
        "parameterTypes": [
          "int"
        ]
      }
    ]
  }
]

本质上,JSON 序列化列表ControlBusController.ControlBusBean实例。 每个条目都是一个 bean,其中包含控制总线合格方法的列表(请参阅ControlBusMethodFilter更多信息),其参数类型和描述来自@ManagedOperation@ManagedAttribute(否则回退到方法名称)。spring-doc.cadn.net.cn

POST 方法设置为/control-bus/{beanName.methodName}调用命令。请求的正文可能包含命令执行的值及其类型列表。例如,operation命令替换为int类的参数:spring-doc.cadn.net.cn

@ManagedResource
class TestManagementComponent {

    @ManagedOperation
    public void operation() {

    }

    @ManagedOperation(description = "The overloaded operation with int argument")
    public void operation(int input) {

    }

    @ManagedOperation(description = "The overloaded operation with two arguments")
    public void operation(int input1, String input2) {

    }

    @ManagedOperation
    public int operation2() {
    	return 123;
    }

}

可以称为/testManagementComponent.operation使用带有正文的提及 POST 方法:spring-doc.cadn.net.cn

[
    {
        "value": "1",
        "parameterType": "int"
    }
]

请参阅控制总线以了解更多信息。spring-doc.cadn.net.cn