You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by doug5791 <to...@uwgb.edu> on 2014/03/17 21:17:43 UTC

Camel-Hazelcast: Adding values into a Map

I am dealing with data in a route where the body of the exchange is a single
string. I have been able to add this string from the body of the exchange to
the Hazelcast grid, however, I would like to add the string to a Map instead
of a list. The documentation I found  here
<http://camel.apache.org/hazelcast-component.html#HazelcastComponent-map>  
does not show a clear example of how information from a "real" exchange is
added to the Map; only a template example.

Using the below route does not add the string values to the map: (probably
because there is no key?)

from("consumer:test")
.setHeader(HazelcastConstants.OPERATION,
constant(HazelcastConstants.PUT_OPERATION))
.toF("hazelcast:%shmap", HazelcastConstants.MAP_PREFIX);

Any ideas on how to provide a key for the value going into the map? Assuming
that is the issue.

Thanks ahead of time,
-Doug



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Hazelcast-Adding-values-into-a-Map-tp5749002.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel-Hazelcast: Adding values into a Map

Posted by Stephan Burkard <sb...@gmail.com>.
On the page you mentioned is an example request that is done with a
producer template:

template.sendBodyAndHeader("direct:[put|get|update|delete|query]",
"my-foo", HazelcastConstants.OBJECT_ID, "4711");

my-foo => message body
HazelcastConstants.OBJECT_ID => message header name
4711 => message header value

So, to add the map key to your message you need to do

.setHeader(HazelcastConstants.OBJECT_ID, yourMapKey)


Stephan



On Mon, Mar 17, 2014 at 9:17 PM, doug5791 <to...@uwgb.edu> wrote:

> I am dealing with data in a route where the body of the exchange is a
> single
> string. I have been able to add this string from the body of the exchange
> to
> the Hazelcast grid, however, I would like to add the string to a Map
> instead
> of a list. The documentation I found  here
> <http://camel.apache.org/hazelcast-component.html#HazelcastComponent-map>
> does not show a clear example of how information from a "real" exchange is
> added to the Map; only a template example.
>
> Using the below route does not add the string values to the map: (probably
> because there is no key?)
>
> from("consumer:test")
> .setHeader(HazelcastConstants.OPERATION,
> constant(HazelcastConstants.PUT_OPERATION))
> .toF("hazelcast:%shmap", HazelcastConstants.MAP_PREFIX);
>
> Any ideas on how to provide a key for the value going into the map?
> Assuming
> that is the issue.
>
> Thanks ahead of time,
> -Doug
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-Hazelcast-Adding-values-into-a-Map-tp5749002.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>