Skip to main content

Topics

This page focuses on how Java applications create and use topics, also see Topic Structure.

Creating Topics

Use the Topics factory to create topics.

Message TypeHelper
SBETopics.create(SampleMessageDecoder.class, source, group, id)
DTOTopics.create(SampleMessageDto.class, source, group, id)
FlexibleTopics.create(source, group, id)
CustomTopics.create(schemaId, templateId, source, group, id)
RawTopics.create(schemaId, templateId, source, group, id)

SBE and DTO classes generated from the same schema identify the same platform data type. One application can subscribe with a DTO topic while another uses the SBE decoder for the same published data. Therefore the following two topics are equivalent:

Topic dtoTopic = Topics.create(SampleMessageDto.class, Topic.SOURCE_WILDCARD, "samples", "sample-1");
Topic sbeTopic = Topics.create(SampleMessageDecoder.class, Topic.SOURCE_WILDCARD, "samples", "sample-1");

Wildcards

Wildcards can be used when subscribing.

WildcardMeaning
Topic.SOURCE_WILDCARDMatch any source.
Topic.GROUP_WILDCARDMatch any group.
Topic.ID_WILDCARDMatch any id.
// match any SampleMessage where the group = "sample"
Topic topic = Topics.create(
SampleMessageDto.class,
Topic.SOURCE_WILDCARD,
"sample",
Topic.ID_WILDCARD);