camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Redis
Date Mon, 04 Mar 2013 13:18:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/Redis">Redis</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~bvahdat">Babak
Vahdat</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-unchanged" >h2. Redis Component <br></td></tr>
            <tr><td class="diff-changed-lines" >*Available as of Camel <span
class="diff-changed-words">2.11<span class="diff-added-chars"style="background-color:
#dfd;">*</span></span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br>This component allows sending
and receiving messages from [Redis|http://http://redis.io/]. Redis is advanced key-value store
where keys can contain strings, hashes, lists, sets and sorted sets. In addition it provides
pub/sub functionality for inter-app comunications. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="Redis-RedisComponent"></a>Redis Component</h2>
<p><b>Available as of Camel 2.11</b></p>

<p>This component allows sending and receiving messages from <a href="http://http://redis.io/"
class="external-link" rel="nofollow">Redis</a>. Redis is advanced key-value store
where keys can contain strings, hashes, lists, sets and sorted sets. In addition it provides
pub/sub functionality for inter-app comunications.<br/>
Camel provides a producer for executing commands, consumer for subscribing to pub/sub messages
an idempotent repository for filtering out duplicate messages.</p>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Prerequisites</b><br
/>In order to use this component, you must have a Redis server running.</td></tr></table></div>

<h3><a name="Redis-URIFormat"></a>URI Format</h3>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
redis:<span class="code-comment">//host:port[?options]</span>
</pre>
</div></div>
<p>You can append query options to the URI in the following format, <tt>?options=value&amp;option2=value&amp;...</tt></p>

<h3><a name="Redis-URIOptions"></a>URI Options</h3>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Context </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'>host</td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Both </td>
<td class='confluenceTd'> The host where Redis server is running. </td>
</tr>
<tr>
<td class='confluenceTd'>port</td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Both </td>
<td class='confluenceTd'> Redis port number. </td>
</tr>
<tr>
<td class='confluenceTd'>command</td>
<td class='confluenceTd'> <tt>SET</tt> </td>
<td class='confluenceTd'> Both </td>
<td class='confluenceTd'> Default command, which can be overriden by message header.
</td>
</tr>
<tr>
<td class='confluenceTd'>channels</td>
<td class='confluenceTd'> <tt>SET</tt> </td>
<td class='confluenceTd'> Consumer </td>
<td class='confluenceTd'> List of topic names or name patterns to subscibe to. </td>
</tr>
<tr>
<td class='confluenceTd'>redisTemplate</td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Producer </td>
<td class='confluenceTd'> Reference to a pre-configured org.springframework.data.redis.core.RedisTemplate
instance in the Registry. </td>
</tr>
<tr>
<td class='confluenceTd'>connectionFactory</td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Both </td>
<td class='confluenceTd'> Reference to a org.springframework.data.redis.connection.RedisConnectionFactory
instance in the Registry. </td>
</tr>
<tr>
<td class='confluenceTd'>listenerContainer</td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Consumer </td>
<td class='confluenceTd'> Referebce to a org.springframework.data.redis.listener.RedisMessageListenerContainer
instance in the Registry instance in the Registry. </td>
</tr>
<tr>
<td class='confluenceTd'>serializer</td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Consumer </td>
<td class='confluenceTd'> Referebce to a org.springframework.data.redis.serializer.RedisSerializer
instance in the Registry. </td>
</tr>
</tbody></table>
</div>


<h3><a name="Redis-Usage"></a>Usage</h3>
<h4><a name="Redis-MessageheadersevaluatedbytheRedisproducer"></a>Message
headers evaluated by the Redis producer</h4>
<p>The producer issues commads to the server and each command has different set of parameters
with specific types. The result from the command execution is returned in the message body.
</p>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Hash Commands </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Parameters </th>
<th class='confluenceTh'> Result </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>HSET</tt> </td>
<td class='confluenceTd'> Set the string value of a hash field </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Field (String), CamelRedis.Value
(Object) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>HGET</tt> </td>
<td class='confluenceTd'> Get the value of a hash field </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Field (String) </td>
<td class='confluenceTd'> String </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>HSETNX</tt> </td>
<td class='confluenceTd'> Set the value of a hash field, only if the field does not
exist </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Field (String), CamelRedis.Value
(Object) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>HMSET</tt> </td>
<td class='confluenceTd'> Set multiple hash fields to multiple values </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Values(Map&lt;String,
Object&gt;) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>HMGET</tt> </td>
<td class='confluenceTd'> Get the values of all the given hash fields </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Fields (Collection&lt;String&gt;)
</td>
<td class='confluenceTd'> Collection&lt;Object&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>HINCRBY</tt> </td>
<td class='confluenceTd'> Increment the integer value of a hash field by the given number
</td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Field (String), CamelRedis.Value
(Long) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>HEXISTS</tt> </td>
<td class='confluenceTd'> Determine if a hash field exists </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Field (String) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>HDEL</tt> </td>
<td class='confluenceTd'> Delete one or more hash fields </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Field (String) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>HLEN</tt> </td>
<td class='confluenceTd'> Get the number of fields in a hash </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>HKEYS</tt> </td>
<td class='confluenceTd'> Get all the fields in a hash </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Set&lt;String&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>HVALS</tt> </td>
<td class='confluenceTd'> Get all the values in a hash </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Collection&lt;Object&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>HGETALL</tt> </td>
<td class='confluenceTd'> Get all the fields and values in a hash </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Map&lt;String, Object&gt; </td>
</tr>
</tbody></table>
</div>


<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> List Commands </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Parameters </th>
<th class='confluenceTh'> Result </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>RPUSH</tt> </td>
<td class='confluenceTd'> Append one or multiple values to a list </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>RPUSHX</tt> </td>
<td class='confluenceTd'> Append a value to a list, only if the list exists </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>LPUSH</tt> </td>
<td class='confluenceTd'> Prepend one or multiple values to a list </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>LLEN</tt> </td>
<td class='confluenceTd'> Get the length of a list </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Long</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>LRANGE</tt> </td>
<td class='confluenceTd'> Get a range of elements from a list </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Start (Long), CamelRedis.End
(Long) </td>
<td class='confluenceTd'> List&lt;Object&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>LTRIM</tt> </td>
<td class='confluenceTd'> Trim a list to the specified range </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Start (Long), CamelRedis.End
(Long) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>LINDEX</tt> </td>
<td class='confluenceTd'> Get an element from a list by its index </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Index (Long) </td>
<td class='confluenceTd'> String </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>LINSERT</tt> </td>
<td class='confluenceTd'> Insert an element before or after another element in a list
</td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object), CamelRedis.Pivot
(String), CamelRedis.Position (String) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>LSET</tt> </td>
<td class='confluenceTd'> Set the value of an element in a list by its index </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object), CamelRedis.Index
(Long) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>LREM</tt> </td>
<td class='confluenceTd'> Remove elements from a list </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object), CamelRedis.Count
(Long) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>LPOP</tt> </td>
<td class='confluenceTd'> Remove and get the first element in a list </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Object </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>RPOP</tt> </td>
<td class='confluenceTd'> Remove and get the last element in a list </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> String </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>RPOPLPUSH</tt> </td>
<td class='confluenceTd'> Remove the last element in a list, append it to another list
and return it </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Destination (String) </td>
<td class='confluenceTd'> Object </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>BRPOPLPUSH</tt> </td>
<td class='confluenceTd'> Pop a value from a list, push it to another list and return
it; or block until one is available </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Destination (String),
CamelRedis.Timeout (Long) </td>
<td class='confluenceTd'> Object </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>BLPOP</tt> </td>
<td class='confluenceTd'> Remove and get the first element in a list, or block until
one is available </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Timeout (Long) </td>
<td class='confluenceTd'> Object </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>BRPOP</tt> </td>
<td class='confluenceTd'> Remove and get the last element in a list, or block until
one is available </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Timeout (Long) </td>
<td class='confluenceTd'> String </td>
</tr>
</tbody></table>
</div>


<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Set Commands </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Parameters </th>
<th class='confluenceTh'> Result </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>SADD</tt> </td>
<td class='confluenceTd'> Add one or more members to a set </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SMEMBERS</tt> </td>
<td class='confluenceTd'> Get all the members in a set </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Set&lt;Object&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SREM</tt> </td>
<td class='confluenceTd'> Remove one or more members from a set </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SPOP</tt> </td>
<td class='confluenceTd'> Remove and return a random member from a set </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> String </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SMOVE</tt> </td>
<td class='confluenceTd'> Move a member from one set to another </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object), CamelRedis.Destination
(String) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SCARD</tt> </td>
<td class='confluenceTd'> Get the number of members in a set </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SISMEMBER</tt> </td>
<td class='confluenceTd'> Determine if a given value is a member of a set </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SINTER</tt> </td>
<td class='confluenceTd'> Intersect multiple sets </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Keys (String) </td>
<td class='confluenceTd'> Set&lt;Object&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SINTERSTORE</tt> </td>
<td class='confluenceTd'> Intersect multiple sets and store the resulting set in a key
</td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Keys (String), CamelRedis.Destination
(String) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SUNION</tt> </td>
<td class='confluenceTd'> Add multiple sets </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Keys (String) </td>
<td class='confluenceTd'> Set&lt;Object&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SUNIONSTORE</tt> </td>
<td class='confluenceTd'> Add multiple sets and store the resulting set in a key </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Keys (String), CamelRedis.Destination
(String) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SDIFF</tt> </td>
<td class='confluenceTd'> Subtract multiple sets </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Keys (String) </td>
<td class='confluenceTd'> Set&lt;Object&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SDIFFSTORE</tt> </td>
<td class='confluenceTd'> Subtract multiple sets and store the resulting set in a key
</td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Keys (String), CamelRedis.Destination
(String) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SRANDMEMBER</tt> </td>
<td class='confluenceTd'> Get one or multiple random members from a set </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> String </td>
</tr>
</tbody></table>
</div>


<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Ordered set Commands </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Parameters </th>
<th class='confluenceTh'> Result </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZADD</tt> </td>
<td class='confluenceTd'> Add one or more members to a sorted set, or update its score
if it already exists </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object), CamelRedis.Score
(Double) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZRANGE</tt> </td>
<td class='confluenceTd'> Return a range of members in a sorted set, by index </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Start (Long), CamelRedis.End
(Long), CamelRedis.WithScore (Boolean) </td>
<td class='confluenceTd'> Object </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZREM</tt> </td>
<td class='confluenceTd'> Remove one or more members from a sorted set </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZINCRBY</tt> </td>
<td class='confluenceTd'> Increment the score of a member in a sorted set </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object), CamelRedis.Increment
(Double) </td>
<td class='confluenceTd'> Double </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZRANK</tt> </td>
<td class='confluenceTd'> Determine the index of a member in a sorted set </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZREVRANK</tt> </td>
<td class='confluenceTd'> Determine the index of a member in a sorted set, with scores
ordered from high to low </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZREVRANGE</tt> </td>
<td class='confluenceTd'> Return a range of members in a sorted set, by index, with
scores ordered from high to low </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Start (Long), CamelRedis.End
(Long), CamelRedis.WithScore (Boolean) </td>
<td class='confluenceTd'> Object </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZCARD</tt> </td>
<td class='confluenceTd'> Get the number of members in a sorted set </td>
<td class='confluenceTd'> CamelRedis.Key (String), </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZCOUNT</tt> </td>
<td class='confluenceTd'> Count the members in a sorted set with scores within the given
values </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Min (Double), CamelRedis.Max
(Double) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZRANGEBYSCORE</tt> </td>
<td class='confluenceTd'> Return a range of members in a sorted set, by score </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Min (Double), CamelRedis.Max
(Double) </td>
<td class='confluenceTd'> Set&lt;Object&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZREVRANGEBYSCORE</tt> </td>
<td class='confluenceTd'> Return a range of members in a sorted set, by score, with
scores ordered from high to low </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Min (Double), CamelRedis.Max
(Double) </td>
<td class='confluenceTd'> Set&lt;Object&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZREMRANGEBYRANK</tt> </td>
<td class='confluenceTd'> Remove all members in a sorted set within the given indexes
</td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Start (Long), CamelRedis.End
(Long) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZREMRANGEBYSCORE</tt> </td>
<td class='confluenceTd'> Remove all members in a sorted set within the given scores
</td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Start (Long), CamelRedis.End
(Long) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZUNIONSTORE</tt> </td>
<td class='confluenceTd'> Add multiple sorted sets and store the resulting sorted set
in a new key </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Keys (String), CamelRedis.Destination
(String) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ZINTERSTORE</tt> </td>
<td class='confluenceTd'> Intersect multiple sorted sets and store the resulting sorted
set in a new key </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Keys (String), CamelRedis.Destination
(String) </td>
<td class='confluenceTd'> void </td>
</tr>
</tbody></table>
</div>


<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> String Commands </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Parameters </th>
<th class='confluenceTh'> Result </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>SET</tt> </td>
<td class='confluenceTd'> Set the string value of a key </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>GET</tt> </td>
<td class='confluenceTd'> Get the value of a key </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Object </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>STRLEN</tt> </td>
<td class='confluenceTd'> Get the length of the value stored in a key </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>APPEND</tt> </td>
<td class='confluenceTd'> Append a value to a key </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (String) </td>
<td class='confluenceTd'> Integer </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SETBIT</tt> </td>
<td class='confluenceTd'> Sets or clears the bit at offset in the string value stored
at key </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Offset (Long), CamelRedis.Value
(Boolean) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>GETBIT</tt> </td>
<td class='confluenceTd'> Returns the bit value at offset in the string value stored
at key </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Offset (Long) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SETRANGE</tt> </td>
<td class='confluenceTd'> Overwrite part of a string at key starting at the specified
offset </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object), CamelRedis.Offset
(Long) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>GETRANGE</tt> </td>
<td class='confluenceTd'> Get a substring of the string stored at a key </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Start (Long), CamelRedis.End
(Long) </td>
<td class='confluenceTd'> String </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SETNX</tt> </td>
<td class='confluenceTd'> Set the value of a key, only if the key does not exist </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SETEX</tt> </td>
<td class='confluenceTd'> Set the value and expiration of a key </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object), CamelRedis.Timeout
(Long), SECONDS </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>DECRBY</tt> </td>
<td class='confluenceTd'> Decrement the integer value of a key by the given number </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Long) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>DECR</tt> </td>
<td class='confluenceTd'> Decrement the integer value of a key by one </td>
<td class='confluenceTd'> CamelRedis.Key (String),  </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>INCRBY</tt> </td>
<td class='confluenceTd'> Increment the integer value of a key by the given amount </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Long) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>INCR</tt> </td>
<td class='confluenceTd'> Increment the integer value of a key by one </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>MGET</tt> </td>
<td class='confluenceTd'> Get the values of all the given keys </td>
<td class='confluenceTd'> CamelRedis.Fields (Collection&lt;String&gt;) </td>
<td class='confluenceTd'> List&lt;Object&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>MSET</tt> </td>
<td class='confluenceTd'> Set multiple keys to multiple values </td>
<td class='confluenceTd'> CamelRedis.Values(Map&lt;String, Object&gt;) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>MSETNX</tt> </td>
<td class='confluenceTd'> Set multiple keys to multiple values, only if none of the
keys exist </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>GETSET</tt> </td>
<td class='confluenceTd'> Set the string value of a key and return its old value </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (Object) </td>
<td class='confluenceTd'> Object </td>
</tr>
</tbody></table>
</div>


<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Key Commands </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Parameters </th>
<th class='confluenceTh'> Result </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>EXISTS</tt> </td>
<td class='confluenceTd'> Determine if a key exists </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Boolea </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>DEL</tt> </td>
<td class='confluenceTd'> Delete a key </td>
<td class='confluenceTd'> CamelRedis.Keys (String) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>TYPE</tt> </td>
<td class='confluenceTd'> Determine the type stored at key </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> DataType </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>KEYS</tt> </td>
<td class='confluenceTd'> Find all keys matching the given pattern </td>
<td class='confluenceTd'> CamelRedis.Pattern (String) </td>
<td class='confluenceTd'> Collection&lt;String&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>RANDOMKEY</tt> </td>
<td class='confluenceTd'> Return a random key from the keyspace </td>
<td class='confluenceTd'> CamelRedis.Pattern (String), CamelRedis.Value (String) </td>
<td class='confluenceTd'> String </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>RENAME</tt> </td>
<td class='confluenceTd'> Rename a key </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>RENAMENX</tt> </td>
<td class='confluenceTd'> Rename a key, only if the new key does not exist </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Value (String) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>EXPIRE</tt> </td>
<td class='confluenceTd'> Set a key's time to live in seconds </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Timeout (Long) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>SORT</tt> </td>
<td class='confluenceTd'> Sort the elements in a list, set or sorted set </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> List&lt;Object&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>PERSIST</tt> </td>
<td class='confluenceTd'> Remove the expiration from a key </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>EXPIREAT</tt> </td>
<td class='confluenceTd'> Set the expiration for a key as a UNIX timestamp </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Timestamp (Long) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>PEXPIRE</tt> </td>
<td class='confluenceTd'> Set a key's time to live in milliseconds </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Timeout (Long) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>PEXPIREAT</tt> </td>
<td class='confluenceTd'> Set the expiration for a key as a UNIX timestamp specified
in milliseconds </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Timestamp (Long) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>TTL</tt> </td>
<td class='confluenceTd'> Get the time to live for a key </td>
<td class='confluenceTd'> CamelRedis.Key (String) </td>
<td class='confluenceTd'> Long </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>MOVE</tt> </td>
<td class='confluenceTd'> Move a key to another database </td>
<td class='confluenceTd'> CamelRedis.Key (String), CamelRedis.Db (Integer) </td>
<td class='confluenceTd'> Boolean </td>
</tr>
</tbody></table>
</div>


<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Other Command </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Parameters </th>
<th class='confluenceTh'> Result </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>MULTI</tt> </td>
<td class='confluenceTd'> Mark the start of a transaction block </td>
<td class='confluenceTd'> none</td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>DISCARD</tt> </td>
<td class='confluenceTd'> Discard all commands issued after MULTI </td>
<td class='confluenceTd'> none </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>EXEC</tt> </td>
<td class='confluenceTd'> Execute all commands issued after MULTI </td>
<td class='confluenceTd'> none </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>WATCH</tt> </td>
<td class='confluenceTd'> Watch the given keys to determine execution of the MULTI/EXEC
block </td>
<td class='confluenceTd'> CamelRedis.Keys (String) </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>UNWATCH</tt> </td>
<td class='confluenceTd'> Forget about all watched keys </td>
<td class='confluenceTd'> none </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>ECHO</tt> </td>
<td class='confluenceTd'> Echo the given string </td>
<td class='confluenceTd'> CamelRedis.Value (String) </td>
<td class='confluenceTd'> String </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>PING</tt> </td>
<td class='confluenceTd'> Ping the server </td>
<td class='confluenceTd'> none </td>
<td class='confluenceTd'> String </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>QUIT</tt> </td>
<td class='confluenceTd'> Close the connection </td>
<td class='confluenceTd'> none </td>
<td class='confluenceTd'> void </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>PUBLISH</tt> </td>
<td class='confluenceTd'> Post a message to a channel </td>
<td class='confluenceTd'> CamelRedis.Channel (String), CamelRedis.Message (Object) </td>
<td class='confluenceTd'> void </td>
</tr>
</tbody></table>
</div>
</div>

<h4><a name="Redis-Redisconsumer"></a>Redis consumer</h4>
<p>The consumer subscribes to a channel either by channel name using <tt>SUBSCRIBE</tt>
or a string pattern using <tt>PSUBSCRIBE</tt> commands. When a message is sent
to the channel using PUBLISH command, it will be consumed and the message will be available
as Camel message body. The message is also serialized using configured serializer or the default
JdkSerializationRedisSerializer.</p>

<p>Message headers set by the Consumer</p>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Header </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelRedis.Channel</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The channel name, where the message was received. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelRedis.Pattern</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The pattern mathichg the channel, where the message was received.
</td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="Redis-Dependencies"></a>Dependencies</h3>
<p>Maven users will need to add the following dependency to their pom.xml.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>pom.xml</b></div><div class="codeContent
panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-redis<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>${camel-version}<span
class="code-tag">&lt;/version&gt;</span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<p>where <tt>${camel-version</tt>} must be replaced by the actual version
of Camel (2.11 or higher).</p>

<h3><a name="Redis-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Redis">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=30752713&revisedVersion=3&originalVersion=2">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Redis?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message