Stream and Topic Operations Summary

Provides a summary of stream topic operations and the interface, class, or method used for the operation.

The following stream and topic operations is not an inclusive list, but a sampling. For detailed information, see the following libraries:

Table 1. Summary of Stream and Topic operations
Operation Interface/Method Used
Creating streams

StreamDescriptor is used to set the attributes for streams that you plan to create.

Admin.createStream(String streamPathAndName, StreamDescriptor desc) - create the stream.

Editing stream attributes

StreamDescriptor is used to edit the stream's attribute values.

Admin.editStream(String streamPathAndName, StreamDescriptor desc) - set or modify the stream's attribute values.

Retrieving the default timestamp type on a stream
StreamDescriptor.getDefaultTimestampType() - retrieves the default timestamp type on the stream.
NOTE
This method is new as of 6.0.1
Sets the default timestamp type on a stream
StreamDescriptor.setDefaultTimestampType(TimestampType logAppendTime) - sets the default timestamp type on the stream.
NOTE
TimestampType Enum is new as of 6.0.1
Deleting streams Admin.deleteStream(String streamPathAndName)
Determining stream existence Admin.streamExists(String streamPathAndName) - determines whether a stream exists or not. Returns: true | false
NOTE
This method is new as of 6.0.1
Creating topics
Admin.createTopic(String streamPathAndName, String topicName, TopicDescriptor desc) is used when creating a topic with the defaults for partitions and timestamp type.
NOTE
TopicDescriptor is new as of 6.0.1

Admin.createTopic(String streamPathAndName, String topicName) is used when accepting the default number of partitions.

Admin.createTopic(String streamPathAndName, String topicName, int npartitions) - creates a topic with a specific number of partitions.

NOTE
If you do not specify the number of partitions for a stream topic, the default number of partitions is inherited from the stream.
Editing topics
Admin.editTopic(String streamPathAndName, String topicName, TopicDescriptor desc) - sets the partitions and timestamp type attributes of a topic.
NOTE
TopicDescriptor is new as of 6.0.1

Admin.editTopic(String streamPathAndName, String topicName, int npartitions)

Retrieving topic attributes Admin.getTopicDescriptor(String streamPathAndName, String topicName) - retrieves topic attributes.
NOTE
This method is new as of 6.0.1
Deleting topics Admin.deleteTopic(String streamPathAndName, String topicName) - deletes topics.
Listing topics Admin.listTopics(String streamPathAndName) - lists all topics in a stream.
NOTE
This method is new as of 6.0.1
Counting topics Admin.countTopics(String streamPathAndName) - counts the number of topics in a stream.
Gets/Sets topic timestamp type TopicDescriptor is used to retrieve the timestamp type attribute value of a topic.
NOTE
TopicDescriptor is new as of 6.0.1

TopicDescriptor.getTimestampType() - retrieves the default timestamp type of a topic.

TopicDescriptor.setTimestampType(TimestampType timestampType) - sets the default timestamp type of a topic.

Gets/Sets topic partitions TopicDescriptor is used to retrieve the partition attribute value of a topic.
NOTE
TopicDescriptor is new as of 6.0.1

TopicDescriptor.getPartitions() - retrieves the partitions of a topic.

TopicDescriptor.setParitions(int numPartitions) - sets the partitions of a topic.

Enabling and tuning log compaction TopicDescriptor is used to enable and tune log compaction at the stream-level.
  • setCompact(boolean compact) - sets log compaction.
  • getCompact() - returns true if log compaction is set on the stream.
  • setMinCompactionLagMS(long ts) - set the lag time (in milliseconds) that a message should remain uncompacted.
  • getMinCompactionLagMS() - retrieves the value of the lag time.
  • setDeleteRetentionMS(long ts) - sets the time (in milliseconds) for which deleted records are retained.
  • getDeleteRetentionMS() - returns the time value of which deleted records are retained.
In addition, the Admin interface is used with the following method to set compaction at the topic-level:
  • compactTopic(java.lang.String streamPath, java.lang.String topicName)
Enabling an Idempotent Producer The Producer interface along with the ProducerConfig class is used to enable idempotence (exact-once message delivery semantics) publishing.