java.lang.Object
com.hedera.hashgraph.sdk.TopicMessageQuery
Subscribe to a topic ID's messages from a mirror node. You will receive all messages for the specified topic or
within the defined start and end time.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsetCompletionHandler(Runnable completionHandler) Assign the call back function.setEndTime(Instant endTime) Assign the end time.setErrorHandler(BiConsumer<Throwable, TopicMessage> errorHandler) Assign the error handler does not return a value.setLimit(long limit) Assign the number of messages to return.setMaxAttempts(int maxAttempts) Assign the maximum number of attempts.setMaxBackoff(Duration maxBackoff) The maximum backoff in milliseconds.setRetryHandler(Predicate<Throwable> retryHandler) Assign the retry handler.setStartTime(Instant startTime) Assign the start time.setTopicId(TopicId topicId) Assign the topic id.subscribe(Client client, Consumer<TopicMessage> onNext) Subscribe to the topic.
-
Constructor Details
-
TopicMessageQuery
public TopicMessageQuery()Constructor.
-
-
Method Details
-
setTopicId
Assign the topic id.- Parameters:
topicId- the topic id- Returns:
this
-
setStartTime
Assign the start time.- Parameters:
startTime- the start time- Returns:
this
-
setEndTime
Assign the end time.- Parameters:
endTime- the end time- Returns:
this
-
setLimit
Assign the number of messages to return.- Parameters:
limit- the number of messages to return- Returns:
this
-
setCompletionHandler
Assign the call back function.- Parameters:
completionHandler- the call back function- Returns:
this
-
setErrorHandler
Assign the error handler does not return a value.- Parameters:
errorHandler- the error handler- Returns:
this
-
setMaxAttempts
Assign the maximum number of attempts.- Parameters:
maxAttempts- the max attempts- Returns:
this
-
setMaxBackoff
The maximum backoff in milliseconds.- Parameters:
maxBackoff- the maximum backoff- Returns:
this
-
setRetryHandler
Assign the retry handler.- Parameters:
retryHandler- the retry handler- Returns:
this
-
subscribe
Subscribe to the topic.- Parameters:
client- the configured clientonNext- the consumer- Returns:
- the subscription handle
-