Interface MessagingService

All Superinterfaces:
Service

public interface MessagingService extends Service
Messaging service.
  • Field Details

  • Method Details

    • emit

      @Deprecated(forRemoval=true, since="3.0.0") void emit(String topic, String message)
      Deprecated, for removal: This API element is subject to removal in a future version.
      If the service is not configured with the structured flag, the message is sent to the specified topic of this message broker as is.

      If the service is configured with the structured flag (default), the message String is converted into a Map following the rule: {message: message} The Map is then interpreted as data map and passed to emit(String, Map). Usually this results in a final message like: {data: {message: message}}

      Parameters:
      topic - the topic
      message - the message to be sent
    • emit

      void emit(String topic, Map<String,Object> message)
      If the service is not configured with the structured flag, the message Map is serialized to JSON and sent to the specified topic of this message broker as is.

      If the service is configured with the structured flag (default), the message Map is interpreted as data map and passed to emit(String, Map, Map). Usually this results in a final message like: {data: message}

      Parameters:
      topic - the topic
      message - the Map to be serialized to JSON and then sent
    • emit

      void emit(String topic, Map<String,Object> data, Map<String,Object> headers)
      Takes a (cloudevents) message, separated into data and headers and sends it to the specified topic of this message broker. This method produces the same final message, regardless of the structured flag.

      Usually data and headers are combined into a final JSON string message following the rule: {...headers, data: data}. Brokers (e.g. Kafka) that do natively support headers are able to separate headers from data, when using this method.

      Parameters:
      topic - the topic
      data - the data Map
      headers - the headers Map