Class ClientReliableTopicConfig
- All Implemented Interfaces:
NamedConfig
- See Also:
-
ClientReliableTopicProxy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default read batch size.static final TopicOverloadPolicy
The default slow consumer policy. -
Constructor Summary
ConstructorDescriptionClientReliableTopicConfig
(ClientReliableTopicConfig reliableTopicConfig) Create a clone of given reliable topicCreates a new ReliableTopicConfig with default settings. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Gets the Executor that is going to process the events.getName()
Gets the name of the reliable topic.int
Gets the maximum number of items to read in a batch.Gets the TopicOverloadPolicy for this reliable topic.int
hashCode()
setExecutor
(Executor executor) Sets the Executor that is going to process the event.Sets the name or name pattern for this config.setReadBatchSize
(int readBatchSize) Sets the read batch size.setTopicOverloadPolicy
(TopicOverloadPolicy topicOverloadPolicy) Sets the TopicOverloadPolicy for this reliable topic.toString()
-
Field Details
-
DEFAULT_READ_BATCH_SIZE
public static final int DEFAULT_READ_BATCH_SIZEThe default read batch size.- See Also:
-
DEFAULT_TOPIC_OVERLOAD_POLICY
The default slow consumer policy.
-
-
Constructor Details
-
ClientReliableTopicConfig
public ClientReliableTopicConfig() -
ClientReliableTopicConfig
Creates a new ReliableTopicConfig with default settings. -
ClientReliableTopicConfig
Create a clone of given reliable topic- Parameters:
reliableTopicConfig
- topic
-
-
Method Details
-
getName
Gets the name of the reliable topic.- Specified by:
getName
in interfaceNamedConfig
- Returns:
- the name of the reliable topic.
-
setName
Sets the name or name pattern for this config. Must not be modified after this instance is added toClientConfig
.- Specified by:
setName
in interfaceNamedConfig
-
getTopicOverloadPolicy
Gets the TopicOverloadPolicy for this reliable topic.- Returns:
- the TopicOverloadPolicy.
-
setTopicOverloadPolicy
Sets the TopicOverloadPolicy for this reliable topic. Check theTopicOverloadPolicy
for more details about this setting.- Parameters:
topicOverloadPolicy
- the new TopicOverloadPolicy.- Returns:
- the updated reliable topic config.
- Throws:
IllegalArgumentException
- if topicOverloadPolicy is null.
-
getExecutor
Gets the Executor that is going to process the events.If no Executor is selected, then the default
ConcurrencyUtil.getDefaultAsyncExecutor()
is used.- Returns:
- the Executor used to process events.
- See Also:
-
setExecutor
Sets the Executor that is going to process the event.In some cases it is desirable to set a specific Executor. For example, you may want to isolate a certain topic from other topics 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, then the defaultConcurrencyUtil.getDefaultAsyncExecutor()
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
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 maximum read batch size can be influenced using the read batch size.
Apart from influencing the number of messages to retrieve, the
readBatchSize
also determines how many messages will be processed by the thread running theMessageListener
before it returns back to the pool to look for otherMessageListener
s 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. The more work that can be done without retuning to the pool, the smaller the overhead.If the
readBatchSize
is 10 and there are 50 messages available, 10 items are retrieved and processed consecutively before the thread goes back to the pool and helps 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 singleMessageListener
and it can't help out otherMessageListener
s, increase the size of the threadpool so the otherMessageListener
s don't need to wait for a thread, but can be processed in parallel.- Parameters:
readBatchSize
- the maximum number of items to read in a batch- Returns:
- the updated reliable topic config
- Throws:
IllegalArgumentException
- if thereadBatchSize
is smaller than 1
-
toString
-
equals
-
hashCode
public int hashCode()
-