Interface MessagingService

All Superinterfaces:
Service

public interface MessagingService extends Service
Messaging service.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The name of the composite MessagingService
    static final String
    The messaging error event, that allows to handle acknowledgement of a message on the messaging channel
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    emit(String topic, String message)
    If the service is not configured with the structured flag (default), the message is sent to the specified topic of this message broker as is.
    void
    emit(String topic, Map<String,Object> message)
    If the service is not configured with the structured flag (default), the message Map is serialized to JSON and sent to the specified topic of this message broker as is.
    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.

    Methods inherited from interface com.sap.cds.services.Service

    after, after, after, after, before, before, before, before, emit, getName, on, on, on, on
  • Field Details

  • Method Details

    • emit

      void emit(String topic, String message)
      If the service is not configured with the structured flag (default), the message is sent to the specified topic of this message broker as is. If the service is configured with the structured flag, 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 (default), 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, 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