2016-07-21 16 views
0

Ich versuche, RPC mit Spring-Integration AMQP zu machen, ich habe eine Methode, die keine Argumente innerhalb meines Gateways, aber die Nachricht wird nicht an meine Börse gesendet, wenn ich es anrufe.Gibt es eine Möglichkeit, leere Payload-Nachricht mit Spring Integration Gateway zu senden?

@MessagingGateway 
public interface StatusGateway { 
    boolean getStatus(); 
} 

Hier meine integrations context.xml

<rabbit:connection-factory id="rabbitConnectionFactory" 
    host="172.17.0.2" virtual-host="/myvhost" 
    username="myuser" password="mypasswd" /> 

<rabbit:template id="default" connection-factory="rabbitConnectionFactory" /> 
<rabbit:topic-exchange name="slr-input" auto-declare="false" /> 

<int:gateway id="statusGateway" 
    service-interface="com.example.StatusGateway" 
    default-request-channel="requestChannel" 
    default-reply-channel="replyChannel" /> 

<int:channel id="requestChannel" /> 
<int:channel id="replyChannel" /> 

<int-amqp:outbound-gateway id="statusRequestGateway" 
    amqp-template="default" 
    exchange-name="slr-input" 
    routing-key="operation.status" 
    request-channel="requestChannel" 
    reply-channel="replyChannel" 
    lazy-connect="true" /> 

Und wenn ich die getStatus Methode, die ich die folgende Ausnahme erhalten rufen

java.lang.IllegalStateException: Failed to execute CommandLineRunner 
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:803) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE] 
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:784) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE] 
    at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:771) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE] 
    at com.example.AmqpTestClientApplication.main(AmqpTestClientApplication.java:14) [classes/:na] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_91] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_91] 
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_91] 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na] 
Caused by: java.lang.IllegalStateException: receive is not supported, because no pollable reply channel has been configured 
    at org.springframework.util.Assert.state(Assert.java:392) ~[spring-core-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.integration.gateway.MessagingGatewaySupport.receive(MessagingGatewaySupport.java:380) ~[spring-integration-core-4.2.8.RELEASE.jar:na] 
    at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:416) ~[spring-integration-core-4.2.8.RELEASE.jar:na] 
    at org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:382) ~[spring-integration-core-4.2.8.RELEASE.jar:na] 
    at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:373) ~[spring-integration-core-4.2.8.RELEASE.jar:na] 
    at org.springframework.integration.gateway.GatewayCompletableFutureProxyFactoryBean.invoke(GatewayCompletableFutureProxyFactoryBean.java:64) ~[spring-integration-core-4.2.8.RELEASE.jar:na] 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) ~[spring-aop-4.2.7.RELEASE.jar:4.2.7.RELEASE] 
    at com.sun.proxy.$Proxy44.getStatus(Unknown Source) ~[na:na] 
    at com.example.AmqpTestClientApplication.lambda$commandLineRunner$0(AmqpTestClientApplication.java:20) [classes/:na] 
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:800) [spring-boot-1.3.6.RELEASE.jar:1.3.6.RELEASE] 

Weiß jemand, wie eine Anfrage zu machen, ohne das Senden eine nicht leere Nachricht?

Antwort

0

Eine Gateway-Methode ohne Argumente ist standardmäßig eine Empfangsoperation. siehe Messaging Gateway: Invoking No-Argument Methods.

Sie können etwas wie das Hinzufügen default-payload-expression="''" zum Gateway (ein leerer String) verwenden.

+0

Vielen Dank, es funktioniert perfekt! –

+0

Hey Gary, ich habe keine Erlaubnis, ein Tag zu erstellen, aber du könntest eines für Frühjahr-Integration-amqp erstellen, das ich nicht gefunden habe. –

+0

Wir benötigen keine Kennzeichnung für jedes Federintegrationsmodul; Verwenden Sie einfach Spring-Integration - Sie könnten auch das Spring-Amqp-Tag hinzufügen, aber diese Frage hat wirklich nichts mit amqp/rabbitmq zu tun. –