com.hazelcast.config
Class ReliableTopicConfig

java.lang.Object
  extended by com.hazelcast.config.ReliableTopicConfig

@Beta
public class ReliableTopicConfig
extends Object

Configuration for the a reliable ITopic. The reliable topic makes use of the Ringbuffer to store the actual messages. To configure the ringbuffer for a reliable topic, define a ringbuffer in the config with exactly the same name. It is very unlikely that you want to run with the default settings. When a ReliableTopic start, it will always start from the tail+1 item from the RingBuffer. It will not chew its way through all available events but it will wait for the next item being published. In the reliable topic global order is always maintained. So all listeners will observe exactly the same order of sequence of messages.


Field Summary
static int DEFAULT_READ_BATCH_SIZE
          The default read batch size.
static boolean DEFAULT_STATISTICS_ENABLED
          Default value for statistics enabled.
static TopicOverloadPolicy DEFAULT_TOPIC_OVERLOAD_POLICY
          The default slow consumer policy
 
Constructor Summary
ReliableTopicConfig(String name)
          Creates a new ReliableTopicConfig with default settings.
 
Method Summary
 ReliableTopicConfig addMessageListenerConfig(ListenerConfig listenerConfig)
          Adds a ListenerConfig.
 ReliableTopicConfig getAsReadOnly()
          Returns a readonly version of the ReliableTopicConfig.
 Executor getExecutor()
          Gets the Executor that is going to process the events.
 List<ListenerConfig> getMessageListenerConfigs()
          Gets the List of MessageListener configurations.
 String getName()
          Gets the name of the topic.
 int getReadBatchSize()
          Gets the maximum number of items to read in a batch.
 TopicOverloadPolicy getTopicOverloadPolicy()
          Gets the TopicOverloadPolicy
 boolean isStatisticsEnabled()
          Checks if statistics are enabled.
 ReliableTopicConfig setExecutor(Executor executor)
          Sets the Executor that is going to process the event.
 ReliableTopicConfig setReadBatchSize(int readBatchSize)
          Sets the read batch size.
 ReliableTopicConfig setStatisticsEnabled(boolean statisticsEnabled)
          Enabled or disabled statistics.
 ReliableTopicConfig setTopicOverloadPolicy(TopicOverloadPolicy topicOverloadPolicy)
          Sets the TopicOverloadPolicy.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_READ_BATCH_SIZE

public static final int DEFAULT_READ_BATCH_SIZE
The default read batch size.

See Also:
Constant Field Values

DEFAULT_TOPIC_OVERLOAD_POLICY

public static final TopicOverloadPolicy DEFAULT_TOPIC_OVERLOAD_POLICY
The default slow consumer policy


DEFAULT_STATISTICS_ENABLED

public static final boolean DEFAULT_STATISTICS_ENABLED
Default value for statistics enabled.

See Also:
Constant Field Values
Constructor Detail

ReliableTopicConfig

public ReliableTopicConfig(String name)
Creates a new ReliableTopicConfig with default settings.

Method Detail

getName

public String getName()
Gets the name of the topic.

Returns:
the name

getTopicOverloadPolicy

public TopicOverloadPolicy getTopicOverloadPolicy()
Gets the TopicOverloadPolicy

Returns:
the TopicOverloadPolicy.

setTopicOverloadPolicy

public ReliableTopicConfig setTopicOverloadPolicy(TopicOverloadPolicy topicOverloadPolicy)
Sets the TopicOverloadPolicy. Check the TopicOverloadPolicy for more details about this setting.

Parameters:
topicOverloadPolicy - the new TopicOverloadPolicy.
Returns:
the updated config.
Throws:
IllegalArgumentException - if topicOverloadPolicy is null.

getExecutor

public Executor getExecutor()
Gets the Executor that is going to process the events. If no Executor is selected, then the ExecutionService.ASYNC_EXECUTOR is used.

Returns:
the Executor used to process events.
See Also:
setExecutor(java.util.concurrent.Executor)

setExecutor

public ReliableTopicConfig setExecutor(Executor executor)
Sets the Executor that is going to process the event. In some cases it is desirable to set a specific Executor. For example you want to isolate a certain topic from other topic e.g. because it contains long running messages or very high priority messages. A single Executor can be shared between multiple Reliable topics, although it could take more time to process a message. If a single Executor is not shared with other reliable topics, then the Executor only needs to have a single thread.

Parameters:
executor - the Executor. if the executor is null, the ExecutionService.ASYNC_EXECUTOR will be used to process the event.
Returns:
the updated config.

getReadBatchSize

public int getReadBatchSize()
Gets the maximum number of items to read in a batch. Returned value will always be equal or larger than 1.

Returns:
the read batch size.

setReadBatchSize

public ReliableTopicConfig setReadBatchSize(int readBatchSize)
Sets the read batch size. The ReliableTopic tries to read a batch of messages from the ringbuffer. It will get at least one, but if there are more available, then it will try to get more to increase throughput. The minimal read batch size can be influenced using the read batch size. Apart from influencing the number of messages to download, the readBatchSize also determines how many messages will be processed by the thread running the MessageListener before it returns back to the pool to look for other MessageListeners that need to be processed. The problem with returning to the pool and looking for new work is that interacting with an Executor is quite expensive due to contention on the work-queue. So the more work that can be done without retuning to the pool, the smaller the overhead. So if the readBatchSize is 10 and there are 50 messages available, 10 items are retrieved and processed consecutively before the thread is going back to the pool and help out with the processing of other messages. If the readBatchSize is 10 and there are 2 items available, 2 items are retrieved and processed consecutively. If the readBatchSize is an issue because a thread will be busy too long with processing a single MessageListener and can't help out other MessageListener, increase the size of the threadpool so the other MessageListener don't need to wait for a thread, but can be processed in parallel.

Parameters:
readBatchSize - the readBatchSize
Returns:
the updated config.
Throws:
IllegalArgumentException - if readBatchSize is smaller than 1.

isStatisticsEnabled

public boolean isStatisticsEnabled()
Checks if statistics are enabled.

Returns:
true if enabled, false otherwise.

setStatisticsEnabled

public ReliableTopicConfig setStatisticsEnabled(boolean statisticsEnabled)
Enabled or disabled statistics.

Parameters:
statisticsEnabled - if statistics should be enabled
Returns:
the updated config.

getMessageListenerConfigs

public List<ListenerConfig> getMessageListenerConfigs()
Gets the List of MessageListener configurations.

Returns:
list of MessageListener configuration.

addMessageListenerConfig

public ReliableTopicConfig addMessageListenerConfig(ListenerConfig listenerConfig)
Adds a ListenerConfig.

Parameters:
listenerConfig - the ListenerConfig to add.
Returns:
the updated config.
Throws:
NullPointerException - if listenerConfig is null.

getAsReadOnly

public ReliableTopicConfig getAsReadOnly()
Returns a readonly version of the ReliableTopicConfig.

Returns:
a readonly version.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.