This is a first time I am using Hazelcast distributed cache (queue) via apache camel. I created a route builder where I configured a hazelcast-queue endpoint as described in apache camel documentation. Camel route is started but it wasn't connecting to hazelcast (client configuration) instance. it was always starting new hazelcast (in build /embedded) from library.
I tried passing Hazelcast instance (client config) in route setter using hazel constants host, port, HazelcastInstance name, etc.., but all tries were unsuccessful.
- Step 1: I created spring bean for
HazelcastInstance(Client network configuration) - Step 2: Add all apache-camel dependency for Hazelcast
- Step 3: Created
RouteBuilder - Step 4: Override configure method and implemented the following line
Sample code
fromF("hazelcast-%sfoo?queueConsumerMode=Poll", HazelcastConstants.QUEUE_PREFIX)
.setHeader(HazelcastConstants.INSTANCE_HOST, constant("127.0.0.1"))
.setHeader(HazelcastConstants.INSTANCE_PORT, constant(5701))
.setHeader(HazelcastConstants.HAZELCAST_INSTANCE_NAME_PARAM, constant("hazelcastinstance"))
.log("::>: Camel log " + body());
Camel started and listening [10.67.113.160]:5701 instead [127.0.0.1]:5701.