23 Topic Configurations by Example
This chapter includes the following topics:
- Define a Subscriber Group
Define a durable subscriber group in cache configuration so it exists when the topic is created and retains published values for the group. - Configuring Value Expiry and Upper Bound on Storage Used for Values Retained for a Topic
The following example illustrates how to parameterize apaged-topic-schemeelement so that it can be configured throughtopic-mappinguser-defined parameter macros. - Configuring a Persistent Topic
If persistence is enabled on a Topic and the entire cluster is restarted, the outstanding unconsumed values on the Topic for subscribers, and subscriber group(s) are recovered during persistence recovery operations.
Parent topic: Using Topics
Define a Subscriber Group
<topic-mapping>
<topic-name>topicWithDurableSubscription</topic-name>
<scheme-name>topic-scheme</scheme-name>
<value-type>java.lang.String</value-type>
<subscriber-groups>
<subscriber-group>
<name>durable-subscription</name>
</subscriber-group>
</subscriber-groups>
</topic-mapping>Note:
Since each value published to a Topic is retained until all subscriber(s)/subscriber group(s) have consumed the value, it is important to actively manage subscriber groups. If a statically configured subscriber group is no longer necessary, remove it from thetopic-mapping configuration file. The life
cycle of statically configured and dynamically created subscriber groups should be manage as
described in list subscriber groups and destroy subscriber group.
Parent topic: Topic Configurations by Example
Configuring Value Expiry and Upper Bound on Storage Used for Values Retained for a Topic
The following example illustrates how to parameterize a
paged-topic-scheme element so that it can be configured through
topic-mapping user-defined parameter macros.
See Using User-Defined Parameter Macros for details on how to use this feature with
cache-mapping. The same usage model applies to
topic-mapping.
In the example later in this topic, the
paged-topic-scheme.configurable-topic-scheme.expiry-delay
has a user-defined parameter macro default value of 0; thus, the default
expiry for the Topic values is to never expire. The default high-units
user-defined parameter macro value is 0B; thus, there is no storage limit for
paged-type-scheme.configurable-topic-scheme unless
the referring topic-mapping explicitly defines expiry-delay
and high-units parameters. For this example, the
topic-mapping.initial-params override both expiry-delay
and high-units.
Example 23-1 Configure paged-topic-scheme using User-defined Parameter Macros
<cache-config>
<topic-scheme-mapping>
<topic-mapping>
<topic-name>topic</topic-name>
<scheme-name>configurable-topic-scheme</scheme-name>
<init-params>
<init-param><param-name>high-units</param-name><param-value>2G</param-value></init-param>
<init-param><param-name>expiry-delay</param-name><param-value>12h</param-value></init-param>
</init-params>
</topic-mapping>
</topic-scheme-mapping>
<caching-schemes>
<paged-topic-scheme>
<scheme-name>configurable-topic-scheme</scheme-name>
<service-name>DistributedTopicService</service-name>
<storage>on-heap</storage>
<expiry-delay>{expiry-delay 0}</expiry-delay>
<high-units>{high-units 0B}</high-units>
</paged-topic-scheme>
</caching-schemes>
</cache-config>
Parent topic: Topic Configurations by Example
Configuring a Persistent Topic
The following is a sample configuration that enables configuring persistent Topics.
Example 23-2 Configuring transient and persistent topic-mappings with same topic scheme
<cache-config>
<topic-scheme-mapping>
<topic-mapping>
<topic-name>persistent-topic-*</topic-name>
<scheme-name>persistent-topic-scheme</scheme-name>
</topic-mapping>
<topic-mapping>
<topic-name>transient-topic-*</topic-name>
<scheme-name>persistent-topic-scheme</scheme-name>
<init-params>
<init-param><param-name>transient</param-name><param-value>true</param-value></init-param>
</init-params>
</topic-mapping>
</topic-scheme-mapping>
<caching-schemes>
<paged-topic-scheme>
<scheme-name>persistent-topic-scheme</scheme-name>
<service-name>DistributedTopicService</service-name>
<storage>on-heap</storage>
<transient>{transient false}</transient>
<persistence><environment>default-active</environment></persistence>
<partitioned-quorum-policy-scheme>
<recover-quorum>{recover-quorum 0}</recover-quorum>
</partitioned-quorum-policy-scheme>
<autostart>true</autostart>
<expiry-delay>{expiry-delay 0}</expiry-delay>
<high-units>{high-units 0B}</high-units>
</paged-topic-scheme>
</caching-schemes>
</cache-config>
In Example 23-2, all Topic names starting with prefix
persistent-topic- are persistent Topics. All Topic names starting with
prefix transient-topic- are transient Topics. If
paged-topic-scheme subelement transient is
false and a persistence.environment is defined, the
Topic is persistent. When the transient subelement is set to
true, the unconsumed values of the Topic is not recovered during
persistence recovery operations when a cluster is completely restarted. This example uses
one of the predefined persistence environments, default-active, for the
value of paged-topic-scheme.persistence.environment. See Overview of the Pre-Defined Persistence Environment
for details. Configuration of the recover-quorum subelement is discussed in
Using Quorum for Persistence Recovery. If no value is
provided for recover-quorum in a
topic-mapping.initial-param, the default of 0 results in the predefined
Using the Dynamic Recovery Quorum Policy being
used.
Parent topic: Topic Configurations by Example