I want to set a key/value pair using camel-redis. I try:

spring-redis://localhost:6379?command=SET&CamelRedis.key=testkey&CamelRedis.value=100

but no joy. I get the error:

There are 2 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{key=testkey, value=100}]

Although there are plenty of examples about how to subscribe etc. I do not find a single example on how to set a key/value pair. How would I do that?

有帮助吗?

解决方案

CamelRedis.Key and CamelRedis.Value (beware they are case sensitive) are message headers not URI parameters

<route>
    <from  uri="direct:intput"/>
    <setHeader headerName="CamelRedis.Key"><constant>testkey</constant></setHeader>
    <setHeader headerName="CamelRedis.Value"><constant>100</constant></setHeader>
    <to uri="spring-redis://localhost:6379?command=SET"/>
</route>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top