gpt4 book ai didi

RabbitMQ 上的 Spring 集成和 AMQP 抛出异常 Method handleToken(byte[]) 找不到

转载 作者:行者123 更新时间:2023-12-02 08:26:11 25 4
gpt4 key购买 nike

这是我的上下文配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/integration/amqp http://www.springframework.org/schema/integration/amqp/spring-integration-amqp.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">


<rabbit:connection-factory id="connectionFactory" host="localhost"/>

<rabbit:template id="amqpTemplate" connection-factory="connectionFactory"/>

<rabbit:queue name="upload-queue"/>


<rabbit:admin connection-factory="connectionFactory"/>

<rabbit:topic-exchange name="infrastructure-exchange">
<rabbit:bindings>
<rabbit:binding queue="upload-queue" pattern="ru.interosite.*"/>
</rabbit:bindings>
</rabbit:topic-exchange>


<int-amqp:outbound-channel-adapter
channel="toRabbit"
routing-key="ru.interosite.1"
amqp-template="amqpTemplate"
exchange-name="infrastructure-exchange"/>

<int-amqp:inbound-channel-adapter
channel="fromRabbit"
queue-names="upload-queue"
connection-factory="connectionFactory"
/>


<int:gateway id="infrastructureGateway" service-interface="com.dropbyke.web.api.service.InfrastructureGateway"/>

<int:channel id="toRabbit"/>
<int:channel id="fromRabbit"/>


<bean id="testInfrastructureServiceImpl" class="com.dropbyke.web.api.service.TestInfrastructureServiceImpl"/>

<int:service-activator input-channel="fromRabbit" ref="testInfrastructureServiceImpl" method="handleToken" />

<!-- A Spring Integration adapter that routes messages sent to the helloWorldChannel to the bean named "helloServiceImpl"'s hello() method -->
<!--<int:outbound-channel-adapter channel="fromRabbit" ref="testInfrastructureServiceImpl" method="handleToken"/>-->


</beans>

这是网关接口(interface):

public interface InfrastructureGateway {

@Gateway(requestChannel = "toRabbit")
void doUpload(UserTokenDTO tokenDTO);

}

应该处理调用的消息端点:

@MessageEndpoint
public class TestInfrastructureServiceImpl implements TestInfrastructureService {

public void handleToken( UserTokenDTO tokenDTO) {
System.out.println("Handle user token " + tokenDTO.getToken());

}

}

因此,当我调用网关的 doUpload 方法时,我收到此错误消息:

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 8): Method call: Method handleToken(byte[]) cannot be found on com.dropbyke.web.api.service.TestInfrastructureServiceImpl type

如果我排除兔子部分,那么一切正常。我应该怎么做才能让它与 Rabbit 一起工作?我应该实现一些从 byte[] 到我的域对象 UserTokenDTO 的转换器吗?

最佳答案

正如 nicolas-labrot 建议的那样,我必须使我的 UserTokenDTO 成为可序列化的。之后一切正常。

关于RabbitMQ 上的 Spring 集成和 AMQP 抛出异常 Method handleToken(byte[]) 找不到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29567260/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com