Package org.mockserver.async.subscribe
Interface MessageSubscriber
- All Known Implementing Classes:
KafkaMessageSubscriber,MqttMessageSubscriber
public interface MessageSubscriber
Subscribes to a message broker channel and records received messages for
later retrieval/verification — the consumer counterpart of
MessagePublisher.
Implementations exist for Kafka (KafkaMessageSubscriber) and
MQTT (MqttMessageSubscriber).
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Clear all recorded messages and stop all subscriptions.Return all messages recorded across all channels.getRecordedMessages(String channel) Return all messages recorded on the given channel since subscription started (or since the last reset).voidStart subscribing to the given channel.voidunsubscribe(String channel) Stop subscribing to the given channel.
-
Method Details
-
subscribe
Start subscribing to the given channel. Messages will be recorded internally and are retrievable viagetRecordedMessages(String).- Parameters:
channel- the channel/topic to subscribe to
-
unsubscribe
Stop subscribing to the given channel. -
getRecordedMessages
Return all messages recorded on the given channel since subscription started (or since the last reset). -
getAllRecordedMessages
List<RecordedMessage> getAllRecordedMessages()Return all messages recorded across all channels. -
close
void close()Clear all recorded messages and stop all subscriptions.
-