Java 在Spring集成中向发送方发送确认:tcp输入/输出通道适配器

Java 在Spring集成中向发送方发送确认:tcp输入/输出通道适配器,java,spring-integration,Java,Spring Integration,我制作了分布式应用程序。 1.Web应用程序和2。Spring集成控制台应用程序 我可以使用控制台应用程序将数据从一个发送到另一个,并进行后台工作,但我希望接收端向发送方确认接收到的数据 发送者应该得到确认 我的代码: Web应用程序端(发送方/客户端): xml: 类来处理请求: @Component public class ESBReceiver { public void getDataFromGL(String msg){ Sys

我制作了分布式应用程序。 1.Web应用程序和2。Spring集成控制台应用程序

我可以使用控制台应用程序将数据从一个发送到另一个,并进行后台工作,但我希望接收端向发送方确认接收到的数据

发送者应该得到确认

我的代码:

Web应用程序端(发送方/客户端):

xml:

类来处理请求:

    @Component
    public class ESBReceiver {
        public void getDataFromGL(String msg){
            System.out.println("From GL We Get :: " + msg);
            System.out.println("Length :: " + msg.length());
        }
    }
在ESBReceiver类中,我记录有关用户登录时间和注销时间的数据

我想将这个类的确认信息发送到我的web应用程序。
那有可能吗?如果是,请提供任何指导。

如果您只想在服务器完成后发送回复;使用tcp网关而不是通道适配器


如果要发送异步消息,请使用。

是,正如@Gary Russell告诉您的,您可以使用tcp网关

例如:

   <int-ip:tcp-inbound-gateway id="inGateway"
    request-channel="tcpChannel"
    reply-channel="replyChannel"
    connection-factory="cfServer"
    reply-timeout="10000"/>   

   <int-ip:tcp-outbound-gateway id="outGateway"
    request-channel="tcpChannel"
    reply-channel="replyChannel"
    connection-factory="cfClient"
    request-timeout="10000"
    remote-timeout="10000"/>


看看它。

@Garu Russell:先生,我正在使用spring集成进行登录和注销。我在登录和注销时传递用户的用户id。我做的事对不对?我已经做了上面的代码,所以它的任何修改。如果用户密码是错误的,那么我发送邮件给他只是为了测试的目的,一件事是,我希望两个双向通信,两个应用程序可以发送和接收彼此的数据,所以我将要做什么?先生,请指点一下。。谢谢。先生,如果可能的话,你能给我举个小例子吗?我是新手,所以我完全糊涂了。谢谢。有一个(客户端和服务器端)。完全异步双向稍微复杂一点;您必须使用我在回答中描述的协作适配器。@GaryRussell:先生,如果您不使用我的适配器,您能告诉我如何进行双向通信吗?是否有可能一条消息我想发送给所有订户,一条消息只发送给所选订户,然后怎么办?任何过滤?当然;一切皆有可能,但我没有时间为你写申请书。你需要自己做一些研究,如果有任何问题,请带着具体问题回到这里。
    <bean id="javaSerializer" class="org.springframework.core.serializer.DefaultSerializer"/>
    <bean id="javaDeserializer" class="org.springframework.core.serializer.DefaultDeserializer"/>
    <int-ip:tcp-connection-factory id="server" type="server" host="localhost" port="56565" single-use="true" so-timeout="10000" deserializer="javaDeserializer" serializer="javaSerializer"/>
    <int-ip:tcp-inbound-channel-adapter id="inboundServer" channel="inputChannel" connection-factory="server"/>
    <int:channel id="inputChannel"> <int:queue capacity="100" /></int:channel>
    <int:channel id="outputChannel"/>
    <int:service-activator id="loginChannel" input-channel="inputChannel" ref="ESBReceiver" method="getDataFromGL" output-channel="outputChannel">
        <int:poller fixed-rate="500" error-channel="outputChannel" />
    </int:service-activator>
    <int:logging-channel-adapter id="esbLogger" level="DEBUG"/>
    <int:wire-tap channel="esbLogger"></int:wire-tap>
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("/receiver/receiver-esb.xml");
    }
    @Component
    public class ESBReceiver {
        public void getDataFromGL(String msg){
            System.out.println("From GL We Get :: " + msg);
            System.out.println("Length :: " + msg.length());
        }
    }
   <int-ip:tcp-inbound-gateway id="inGateway"
    request-channel="tcpChannel"
    reply-channel="replyChannel"
    connection-factory="cfServer"
    reply-timeout="10000"/>   

   <int-ip:tcp-outbound-gateway id="outGateway"
    request-channel="tcpChannel"
    reply-channel="replyChannel"
    connection-factory="cfClient"
    request-timeout="10000"
    remote-timeout="10000"/>