Package com.hazelcast.config
Class TopicConfig
- java.lang.Object
-
- com.hazelcast.config.TopicConfig
-
- All Implemented Interfaces:
NamedConfig
,DataSerializable
,IdentifiedDataSerializable
public class TopicConfig extends java.lang.Object implements IdentifiedDataSerializable, NamedConfig
Contains the configuration for aITopic
.
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_GLOBAL_ORDERING_ENABLED
Default global ordering configuration.
-
Constructor Summary
Constructors Constructor Description TopicConfig()
Creates a TopicConfig.TopicConfig(TopicConfig config)
Creates aTopicConfig
by cloning another TopicConfig.TopicConfig(java.lang.String name)
Creates a TopicConfig with the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TopicConfig
addMessageListenerConfig(ListenerConfig listenerConfig)
Adds a message listener to this topic (listens for when messages are added or removed).boolean
equals(java.lang.Object o)
int
getClassId()
Returns type identifier for this class.int
getFactoryId()
Returns DataSerializableFactory factory ID for this class.java.util.List<ListenerConfig>
getMessageListenerConfigs()
Gets the list of message listeners (listens for when messages are added or removed) for this topic.java.lang.String
getName()
Gets the name of the topic, null if nothing is set.int
hashCode()
boolean
isGlobalOrderingEnabled()
Checks if global ordering is enabled (all nodes listening to the same topic get their messages in the same order), or disabled (nodes get the messages in the order that the messages are published).boolean
isMultiThreadingEnabled()
Checks if multi-threaded processing of incoming messages is enabled or not.boolean
isStatisticsEnabled()
Checks if statistics are enabled for this topic.void
readData(ObjectDataInput in)
Reads fields from the input streamTopicConfig
setGlobalOrderingEnabled(boolean globalOrderingEnabled)
Enable global ordering (all nodes listening to the same topic get their messages in the same order), or disable it (nodes get the messages in the order that the messages are published).TopicConfig
setMessageListenerConfigs(java.util.List<ListenerConfig> listenerConfigs)
Sets the list of message listeners (listens for when messages are added or removed) for this topic.TopicConfig
setMultiThreadingEnabled(boolean multiThreadingEnabled)
Enable multi-threaded message handling.TopicConfig
setName(java.lang.String name)
Sets the name of the topic.TopicConfig
setStatisticsEnabled(boolean statisticsEnabled)
Enables or disables statistics for this topic.java.lang.String
toString()
void
writeData(ObjectDataOutput out)
Writes object fields to output stream
-
-
-
Field Detail
-
DEFAULT_GLOBAL_ORDERING_ENABLED
public static final boolean DEFAULT_GLOBAL_ORDERING_ENABLED
Default global ordering configuration.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TopicConfig
public TopicConfig()
Creates a TopicConfig.
-
TopicConfig
public TopicConfig(java.lang.String name)
Creates a TopicConfig with the given name.- Parameters:
name
- the name of the Topic
-
TopicConfig
public TopicConfig(TopicConfig config)
Creates aTopicConfig
by cloning another TopicConfig.- Parameters:
config
- the TopicConfig to clone
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets the name of the topic, null if nothing is set.- Specified by:
getName
in interfaceNamedConfig
- Returns:
- the name of the topic
-
setName
public TopicConfig setName(java.lang.String name)
Sets the name of the topic.- Specified by:
setName
in interfaceNamedConfig
- Parameters:
name
- the topic name to set- Returns:
- the updated
TopicConfig
- Throws:
java.lang.IllegalArgumentException
- if name isnull
or an empty string
-
isGlobalOrderingEnabled
public boolean isGlobalOrderingEnabled()
Checks if global ordering is enabled (all nodes listening to the same topic get their messages in the same order), or disabled (nodes get the messages in the order that the messages are published).- Returns:
- true if global ordering is enabled, false if disabled
-
setGlobalOrderingEnabled
public TopicConfig setGlobalOrderingEnabled(boolean globalOrderingEnabled)
Enable global ordering (all nodes listening to the same topic get their messages in the same order), or disable it (nodes get the messages in the order that the messages are published).- Parameters:
globalOrderingEnabled
- set totrue
to enable global ordering,false
to disable- Returns:
- the updated TopicConfig
-
isMultiThreadingEnabled
public boolean isMultiThreadingEnabled()
Checks if multi-threaded processing of incoming messages is enabled or not. When disabled only one dedicated thread will handle all topic messages. Otherwise any thread from events thread pool can be used for message handling.- Returns:
true
if multi-threading is enabled,false
if disabled
-
setMultiThreadingEnabled
public TopicConfig setMultiThreadingEnabled(boolean multiThreadingEnabled)
Enable multi-threaded message handling. When enabled any thread from events thread pool can be used for incoming message processing. Otherwise only one dedicated thread will be used to handle topic messages. Note: it can be enabled only in case when global ordering is disabled. Moreover, the local message ordering is not supported in this mode also. This means the messages produced by local publisher can be processed by several threads with no ordering guarantee.- Parameters:
multiThreadingEnabled
- set totrue
to enable multi-threaded message processing,false
to disable- Returns:
- the updated TopicConfig
-
addMessageListenerConfig
public TopicConfig addMessageListenerConfig(ListenerConfig listenerConfig)
Adds a message listener to this topic (listens for when messages are added or removed).- Parameters:
listenerConfig
- the message listener to add to this topic
-
getMessageListenerConfigs
public java.util.List<ListenerConfig> getMessageListenerConfigs()
Gets the list of message listeners (listens for when messages are added or removed) for this topic.- Returns:
- the list of message listeners for this topic
-
setMessageListenerConfigs
public TopicConfig setMessageListenerConfigs(java.util.List<ListenerConfig> listenerConfigs)
Sets the list of message listeners (listens for when messages are added or removed) for this topic.- Parameters:
listenerConfigs
- the list of message listeners for this topic- Returns:
- this updated topic configuration
-
isStatisticsEnabled
public boolean isStatisticsEnabled()
Checks if statistics are enabled for this topic.- Returns:
true
if statistics are enabled,false
otherwise
-
setStatisticsEnabled
public TopicConfig setStatisticsEnabled(boolean statisticsEnabled)
Enables or disables statistics for this topic.- Parameters:
statisticsEnabled
-true
to enable statistics for this topic,false
to disable- Returns:
- the updated TopicConfig
-
equals
public final boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getFactoryId
public int getFactoryId()
Description copied from interface:IdentifiedDataSerializable
Returns DataSerializableFactory factory ID for this class.- Specified by:
getFactoryId
in interfaceIdentifiedDataSerializable
- Returns:
- factory ID
-
getClassId
public int getClassId()
Description copied from interface:IdentifiedDataSerializable
Returns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassId
in interfaceIdentifiedDataSerializable
- Returns:
- type ID
-
writeData
public void writeData(ObjectDataOutput out) throws java.io.IOException
Description copied from interface:DataSerializable
Writes object fields to output stream- Specified by:
writeData
in interfaceDataSerializable
- Parameters:
out
- output- Throws:
java.io.IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the output stream has been closed.
-
readData
public void readData(ObjectDataInput in) throws java.io.IOException
Description copied from interface:DataSerializable
Reads fields from the input stream- Specified by:
readData
in interfaceDataSerializable
- Parameters:
in
- input- Throws:
java.io.IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the input stream has been closed.
-
-