首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring Integration IP UDP - IN/OUTBOUND错误

Spring Integration IP UDP - IN/OUTBOUND错误
EN

Stack Overflow用户
提问于 2014-05-30 16:19:06
回答 2查看 961关注 0票数 1

我正在尝试在两个应用程序之间进行通信:

在第一个应用程序中,我做了一些类似的事情,并且没有错误地工作,它是有效的还是无效的,我没有。

代码语言:javascript
复制
public class Main {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/new_tutorial.xml");
        applicationContext.registerShutdownHook();
    }
}

它的XML配置:

代码语言:javascript
复制
    <int:inbound-channel-adapter channel="quakeinfotrigger.channel" expression="''">
        <int:poller fixed-delay="60000" />
    </int:inbound-channel-adapter>

    <int:channel id="quakeinfo.channel">
        <int:queue capacity="10"/>
    </int:channel>

    <int:channel id="quakeinfotrigger.channel" />

    <int:inbound-channel-adapter channel="quakeinfotrigger.channel" expression="''">
        <int:poller fixed-delay="60000" />
    </int:inbound-channel-adapter>

    <int-ip:udp-outbound-channel-adapter id="metoo" channel="quakeinfotrigger.channel" port="11111" host="localhost"/>

    <int:logging-channel-adapter id="messageLogger" log-full-message="true" channel="quakeinfo.channel" level="ERROR">
        <int:poller fixed-delay="5000" />
    </int:logging-channel-adapter>

在第二个应用程序中,我是这样做的:

代码语言:javascript
复制
public class InboundESB {
    public static void main(String[] args) {       
        ApplicationContext context = new ClassPathXmlApplicationContext("/getinbound.xml");       
    }
}

在第二个应用程序的xml代码中:

代码语言:javascript
复制
    <int:inbound-channel-adapter channel="quakeinfotrigger.channel" expression="''">
        <int:poller fixed-delay="60000" />
    </int:inbound-channel-adapter>

    <int:channel id="quakeinfotrigger.channel" />

    <int:inbound-channel-adapter channel="quakeinfotrigger.channel" expression="''">
        <int:poller fixed-delay="60000" />
    </int:inbound-channel-adapter>

    <int-ip:udp-inbound-channel-adapter id="metoo" port="11111" channel="quakeinfotrigger.channel"/>

当我在第一个应用程序之后执行第二个应用程序时,它会给我一个错误:

代码语言:javascript
复制
org.springframework.integration.handler.LoggingHandler handleMessageInternal
SEVERE: org.springframework.integration.MessageDeliveryException: Dispatcher has no subscribers for channel quakeinfotrigger.channel.

我想将消息从onr应用程序传递到其他应用程序,但我是spring集成的新手,所以我不知道该怎么做?对此有什么帮助吗?

EN

回答 2

Stack Overflow用户

发布于 2014-05-30 22:01:29

尝试下面这样的方法。你的接收器应用:

代码语言:javascript
复制
<int:channel id="quakeinfotrigger.channel">
        <int:queue />
    </int:channel>

    <int-ip:udp-inbound-channel-adapter id="metoo" port="11111" channel="quakeinfotrigger.channel"/>

    <int:service-activator input-channel="quakeinfotrigger.channel"
        output-channel="logger"
        ref="echoService" 
        method="test">
        <int:poller fixed-rate="1000" />
    </int:service-activator>

    <bean id="echoService"
        class="com.foo.bar.EchoService" />

    <int:logging-channel-adapter id="logger" logger-name="com.foo.bar"/>


public class EchoService {
    public String test(String input) {
        return input + ":echo";
    }
}

public class InboundESB {
    public static void main(String[] args) {       
        ApplicationContext context = new ClassPathXmlApplicationContext("/getinbound.xml");
context.registerShutdownHook();
    }
}

消息通过入站通道到达,当收到消息时,将调用来自echoServicetest方法。回复被发送到logger通道,该通道在控制台上打印它。

您的发件人应用程序:

代码语言:javascript
复制
<int:channel id="quakeinfotrigger.channel" />

    <int:gateway id="sender"
        service-interface="com.foo.bar.Sender"
        default-request-channel="quakeinfotrigger.channel" 
    />

    <int-ip:udp-outbound-channel-adapter id="metoo" channel="quakeinfotrigger.channel" port="11111" host="localhost"/>

public interface Sender {
    public void sendMessage(String message);
}

public class Main {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/new_tutorial.xml");
        applicationContext.registerShutdownHook();

        Sender sender = (Sender) context.getBean("sender");
        sender.sendMessage("123");
    }
}

Sender接口是Spring Integration API的入口点(网关)。一旦此网关上的一个方法被调用,消息就被放到通道上,并通过出站通道适配器发送。

票数 1
EN

Stack Overflow用户

发布于 2014-05-30 21:08:33

您没有从quakeinfotrigger消耗任何东西-您有两个轮询入站适配器和UDP入站适配器,它们都生成消息并将它们发送到该通道,但是您需要一些东西来实际处理这些消息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23950032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档