Topic Configuration

The following are example topic configurations.

Declarative Configuration:

<hazelcast>
  ...
  <topic name="yourTopicName">
    <global-ordering-enabled>true</global-ordering-enabled>
    <statistics-enabled>true</statistics-enabled>
    <message-listeners>
      <message-listener>MessageListenerImpl</message-listener>
    </message-listeners>
  </topic>
  ...
</hazelcast>

Programmatic Configuration:

TopicConfig topicConfig = new TopicConfig();
topicConfig.setGlobalOrderingEnabled( true );
topicConfig.setStatisticsEnabled( true );
topicConfig.setName( "yourTopicName" );
MessageListener<String> implementation = new MessageListener<String>() {
  @Override
  public void onMessage( Message<String> message ) {
    // process the message
  }
};
topicConfig.addMessageListenerConfig( new ListenerConfig( implementation ) );
HazelcastInstance instance = Hazelcast.newHazelcastInstance()

Topic configuration has the following elements.

  • statistics-enabled: Default is true, meaning statistics are calculated.
  • global-ordering-enabled: Default is false, meaning there is no global order guarantee.
  • message-listeners: Lets you add listeners (listener classes) for the topic messages.

Topic related but not topic specific configuration parameters

  • hazelcast.event.queue.capacity: default value is 1,000,000.
  • hazelcast.event.queue.timeout.millis: default value is 250.
  • hazelcast.event.thread.count: default value is 5.



RELATED INFORMATION

For description of these parameters, please see Global Event Configuration.

tion.