使用RedisMessageTranfomer将消息推送到具有头部redis_command = GET的test的有效负载,以重新启动出站网关并转到下面列出的异常。
<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
http://www.springframework.org/schema/integration/redis http://www.springframework.org/schema/integration/redis/spring-integration-redis.xsd
http://www.springframework.org/schema/integration/ws http://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd
http://www.springframework.org/schema/integration/xml http://www.springframework.org/schema/integration/xml/spring-integration-xml.xsd"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xmlns:int-http="http://www.springframework.org/schema/integration/http"
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
xmlns:int-redis="http://www.springframework.org/schema/integration/redis"
xmlns:int-ws="http://www.springframework.org/schema/integration/ws"
xmlns:si-xml="http://www.springframework.org/schema/integration/xml">
<int-http:inbound-gateway id="omega"
request-channel="channel3" path="/omega" supported-methods="GET,POST"
reply-channel="channel5" />
<int:channel id="channel3">
<int:interceptors>
<int:wire-tap channel="channel3LoggingChannel" />
</int:interceptors>
</int:channel>
<int:logging-channel-adapter id="channel3LoggingChannel"
level="INFO" expression="'*** Channel3 Log ' + headers + ' -> ' + payload">
</int:logging-channel-adapter>
<int:transformer
output-channel="channel4" input-channel="channel3"
ref="redisMessageTransformer"
method="transform">
</int:transformer>
<bean id="redisMessageTransformer"
class="org.springframework.integration.samples.http.RedisMessageTransformer"/>
<int:channel id="channel4">
<int:interceptors>
<int:wire-tap channel="channel4LoggingChannel" />
</int:interceptors>
</int:channel>
<int:logging-channel-adapter id="channel4LoggingChannel"
level="INFO" expression="'*** Channel4 Log ' + headers + ' -> ' + payload">
</int:logging-channel-adapter>
<int-redis:outbound-gateway request-channel="channel4"
reply-channel="channel5" redis-template="redisTemplate"
command-expression="'GET'" />
<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
<constructor-arg ref="redisConnectionFactory"/>
</bean>
<bean id="redisConnectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:use-pool="true" p:host-name="127.0.0.1" p:port="6379" />
<bean
id="stringRedisSerializer"
class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
<bean id="payloadArgumentsStrategy"
class="org.springframework.integration.samples.http.PayloadArgumentsStrategy"/>
<int:channel id="channel5">
<int:interceptors>
<int:wire-tap channel="channel5LoggingChannel" />
</int:interceptors>
</int:channel>
<int:logging-channel-adapter id="channel5LoggingChannel"
level="INFO" expression="'*** Channel5 Log ' + headers + ' -> ' + payload">
</int:logging-channel-adapter>
</beans>
package org.springframework.integration.samples.http;
import org.springframework.integration.redis.support.RedisHeaders;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
public class RedisMessageTransformer {
public Object transform(Object object)
{
Object m = object;
System.out.println("*** object.getClass().getName = " + object.getClass().getName());
m = MessageBuilder.withPayload("test").setHeader(RedisHeaders.COMMAND, "GET").build();
System.out.println("*** m = " + m);
return m;
}
}
例外
<pre> Server Error</pre></p><h3>Caused by:</h3><pre>java.lang.NoSuchMethodError: org.springframework.data.redis.connection.RedisConnection.execute(Ljava/lang/String;[[B)Ljava/lang/Object;
at org.springframework.integration.redis.outbound.RedisOutboundGateway$1.doInRedis(RedisOutboundGateway.java:125)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:162)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:133)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:121)
at org.springframework.integration.redis.outbound.RedisOutboundGateway.handleRequestMessage(RedisOutboundGateway.java:121)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:170)
需要更改什么才能从redis&gt;中获取redis-outboundgateway读取(GET)值?
答案 0 :(得分:0)
org.springframework.data.redis.connection.RedisConnection.execute(Ljava /郎/字符串; [B)Ljava /郎/对象;
H-m ...您使用的是哪个版本的Spring Data Redis?
尝试使用spring-integration-redis-4.0