Interface MessagePublisher

All Known Implementing Classes:
KafkaMessagePublisher, MqttMessagePublisher

public interface MessagePublisher
Publishes a message payload to a named channel (topic).

Implementations exist for Kafka (KafkaMessagePublisher) and MQTT (MqttMessagePublisher).

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Release any resources held by this publisher (producer connections, etc.).
    void
    publish(String channel, String payload)
    Publish the given payload to the specified channel with no key or headers.
    default void
    publish(String channel, String key, String payload, Map<String,String> headers)
    Publish the given payload with an optional key and headers.
    default void
    publish(String channel, String payload, PublishOptions options)
    Publish the given payload with per-message options derived from AsyncAPI bindings.
  • Method Details

    • publish

      void publish(String channel, String payload)
      Publish the given payload to the specified channel with no key or headers.
      Parameters:
      channel - the channel / topic name
      payload - the message payload (typically JSON)
    • publish

      default void publish(String channel, String key, String payload, Map<String,String> headers)
      Publish the given payload with an optional key and headers. Default implementation delegates to publish(String, String), ignoring key and headers — implementations that support them override this.
      Parameters:
      channel - the channel / topic name
      key - the message key (may be null)
      payload - the message payload (typically JSON)
      headers - optional headers (may be null)
    • publish

      default void publish(String channel, String payload, PublishOptions options)
      Publish the given payload with per-message options derived from AsyncAPI bindings. Default implementation delegates to publish(String, String), ignoring the options — implementations that support them override this.
      Parameters:
      channel - the channel / topic name
      payload - the message payload (typically JSON)
      options - per-message publish options (may be null)
    • close

      void close()
      Release any resources held by this publisher (producer connections, etc.).