Set redis key/value with camel-redis

我是研究僧i 提交于 2019-12-02 02:39:23

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/23119359/set-redis-key-value-with-camel-redis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!