Interface TopicMessageId

All Superinterfaces:
Comparable<MessageId>, MessageId, Serializable

public interface TopicMessageId extends MessageId
The MessageId used for a consumer that subscribes multiple topics or partitioned topics.

It's guaranteed that Message.getMessageId() must return a TopicMessageId instance if the Message is received from a consumer that subscribes multiple topics or partitioned topics. The topic name used in APIs related to this class like `getOwnerTopic` and `create` must be the full topic name. For example, "my-topic" is invalid while "persistent://public/default/my-topic" is valid. If the topic is a partitioned topic, the topic name should be the name of the specific partition, e.g. "persistent://public/default/my-topic-partition-0".

  • Method Details

    • getOwnerTopic

      String getOwnerTopic()
      Return the owner topic name of a message.
      Returns:
      the owner topic
    • hasSameBasePartitionedTopic

      boolean hasSameBasePartitionedTopic(String topicName)
      Checks if this message's owner topic and the given topic refer to the same base partitioned topic by comparing their base partitioned topic names.

      For example, persistent://public/default/my-topic-partition-0 matches persistent://public/default/my-topic or any other partition of that topic. Topics sharing only a name prefix (e.g., my-topic vs my-topic-v2) do not match.

      Parameters:
      topicName - a full topic name (non-partitioned, partitioned, or specific partition)
      Returns:
      true if both topics resolve to the same base partitioned topic name
    • create

      static TopicMessageId create(String topic, MessageId messageId)