小编lbv*_*rgo的帖子

方法返回无效时的Spring Integration Gateway回复通道

我对SI网关功能有疑问/澄清:

如果我的网关接口定义如下:

public interface MyGateway{
   public void myGatewayMethod(Message<?> inMessage);
}
Run Code Online (Sandbox Code Playgroud)

我的网关配置定义如下:

<int:gateway id="mySvcGateway"
                 service-interface="com.myCompany.myPkg.MyGateway"
                 error-channel="globalExceptionHandlerChannel">

        <int:method name="myGatewayMethod" request-channel="myGatewayReqChannel" />     
    </int:gateway>
Run Code Online (Sandbox Code Playgroud)

我的问题/澄清是:

1)由于网关服务接口方法返回void,网关代理bean是否仍在"default-reply-channel"或用户定义的"reply-channel"上寻找响应?

2)换句话说,我还需要提及reply-channel="nullChannel"(或default-reply-channel="nullChannel")吗?

要么

由于方法返回无效,网关会自动理解不听取回复频道吗?

3)我是否仍然reply-timeout可以为此配置添加属性,或者它没有意义,因为没有预期的回复?

在类似的上下文中,如果我在服务接口方法中添加另一个方法,如下所示:

public interface MyGateway{
       public void myGatewayMethod(Message<?> inMessage);
       public Object myGatewayMethod2(Message<?> inMessage);
    }
Run Code Online (Sandbox Code Playgroud)

并在我的网关配置中添加此方法,如下所示:

<int:gateway id="mySvcGateway"
                     service-interface="com.myCompany.myPkg.MyGateway"
                     error-channel="globalExceptionHandlerChannel">

            <int:method name="myGatewayMethod" request-channel="myGatewayReqChannel" /> 
<int:method name="myGatewayMethod2" request-channel="myGatewayReqChannel2" />   
        </int:gateway>
Run Code Online (Sandbox Code Playgroud)

4)在这种情况下,我相信我需要定义reply-channel,更正?

5)default-reply-channel对于这种情况可能不起作用,因为一个方法网关期望响应而不是其他,正确吗?

6)如果是,那么对于返回void的方法,我是否需要明确提及reply-channel="nullChannel"

谢谢确认.

methods integration gateway void spring-integration

6
推荐指数
1
解决办法
4061
查看次数

拦截器没有被 SpringBoot 初始化和调用

我有一个 Spring-Boot 应用程序,它被打包为一个带有 tomcat 依赖项的战争(所以我有两个选项 - 使用打包的 .war 在通过 java -jar 命令启动后在嵌入式容器中运行,并且还可以运行一个独立的 servlet 容器)。

下面是我的 App 主类

package com.mycompany.edsa.dgv.proxysvc;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import  org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.mycompany.edsa.dgv.proxysvc.interceptor.DGVProxySvcRequestInterceptor;

//import com.mycompany.edsa.dgv.proxysvc.config.ConfigExtension;

@SpringBootApplication
@ImportResource("classpath:dgv-proxy-svc-spring-ctx.xml")
//@Import(ConfigExtension.class)
public class DGVProxySvcAppMain extends SpringBootServletInitializer {

public static void main(String[] args) {
    SpringApplication.run(DGVProxySvcAppMain.class, args);
}

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(DGVProxySvcAppMain.class);
}

@Bean
public DGVProxySvcRequestInterceptor dgvProxySvcRequestInterceptor() {
    DGVProxySvcRequestInterceptor dgvProxySvcReqInterceptor = new DGVProxySvcRequestInterceptor();
    return dgvProxySvcReqInterceptor; …
Run Code Online (Sandbox Code Playgroud)

spring interceptor spring-boot

6
推荐指数
1
解决办法
1万
查看次数