= Hazelcast Topic Component
:doctitle: Hazelcast Topic
:shortname: hazelcast-topic
:artifactid: camel-hazelcast
:description: Send and receive messages to/from Hazelcast distributed topic.
:since: 2.15
:supportlevel: Stable
:tabs-sync-option:
:component-header: Both producer and consumer are supported
//Manually maintained attributes
:group: Hazelcast
:camel-spring-boot-name: hazelcast

*Since Camel {since}*

*{component-header}*

The http://www.hazelcast.com/[Hazelcast] Topic component is one of Camel Hazelcast Components which allows you to access Hazelcast distributed topic.


== Options

// component options: START
include::partial$component-configure-options.adoc[]
include::partial$component-endpoint-options.adoc[]
include::partial$component-endpoint-headers.adoc[]
// component options: END


== Topic producer – to(“hazelcast-topic:foo”)

The topic producer provides only one operation (publish).

=== Example for *publish*:

[source,java]
----------------------------------------------------------------------------------------
from("direct:add")
.setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.PUBLISH))
.toF("hazelcast-%sbar", HazelcastConstants.PUBLISH_OPERATION);
----------------------------------------------------------------------------------------

== Topic consumer – from(“hazelcast-topic:foo”)

The topic consumer provides only one operation (received). This
component is supposed to support multiple consumption as it's expected
when it comes to topics, so you are free to have as many consumers as you
need on the same hazelcast topic.

[source,java]
--------------------------------------------------------------------------------------------
fromF("hazelcast-%sfoo", HazelcastConstants.TOPIC_PREFIX)
  .choice()
    .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.RECEIVED))
      .log("...message received")
    .otherwise()
      .log("...this should never have happened")
--------------------------------------------------------------------------------------------


include::spring-boot:partial$starter.adoc[]
