All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cds.services.messaging.TopicMessageEventContext Maven / Gradle / Ivy

There is a newer version: 3.4.1
Show newest version
/**************************************************************************
 * (C) 2019-2024 SAP SE or an SAP affiliate company. All rights reserved. *
 **************************************************************************/
package com.sap.cds.services.messaging;

import java.util.Map;

import com.sap.cds.services.EventContext;
import com.sap.cds.services.EventName;

/**
 * Describes the topic message of the {@link MessagingService}
 */
@EventName("*")
public interface TopicMessageEventContext extends EventContext {

	/**
	 * Creates a new {@link TopicMessageEventContext}
	 *
	 * @param topic destination topic
	 *
	 * @return the {@link TopicMessageEventContext}
	 */
	static TopicMessageEventContext create(String topic) {
		TopicMessageEventContext context = EventContext.create(topic, null).as(TopicMessageEventContext.class);
		context.setIsInbound(false);
		return context;
	}

	/**
	 * Returns the inbound flag
	 * @return true, if the message has been received from a message broker or false, if it emitted to a message broker.
	 */
	Boolean getIsInbound();

	/**
	 * Sets the inbound flag
	 * @param inbound true, if the message has been received from a message broker or false, if it emitted to a message broker.
	 */
	void setIsInbound(boolean inbound);

	/**
	 * Returns the plain string message. On inbound messages this is set, if the structured flag is not set.
	 * In case of a cloudevents message this is the full cloudevents message as String.
	 *
	 * Note, that either {@link #getData()} or the two maps {@link #getDataMap()} and {@link #getHeadersMap()} are set, never both.
	 *
	 * @return the plain string message
	 * @deprecated Use {@link #getDataMap()} instead.
	 */
	@Deprecated(forRemoval = true, since = "3.0.0")
	String getData();

	/**
	 * Sets the plain string message.
	 * In case of a cloudevents message this is the full cloudevents message as String.
	 *
	 * Note, that either {@link #getData()} or the two maps {@link #getDataMap()} and {@link #getHeadersMap()} can be set, never both.
	 *
	 * @param data the plain string message
	 *
	 * @deprecated Use {@link #setDataMap(Map)} instead.
	 */
	@Deprecated(forRemoval = true, since = "3.0.0")
	void setData(String data);

	/**
	 * Returns the data map. On inbound messages this is set, if the structured flag is set (default).
	 * In case of a cloudevents message the data map corresponds to the map, available under the "data" key.
	 *
	 * Note, that either {@link #getData()} or the two maps {@link #getDataMap()} and {@link #getHeadersMap()} are set, never both.
	 *
	 * @return the data map
	 */
	Map getDataMap();

	/**
	 * Sets the data map.
	 * In case of a cloudevents message the data map corresponds to the map, available under the "data" key.
	 *
	 * Note, that either {@link #getData()} or the two maps {@link #getDataMap()} and {@link #getHeadersMap()} can be set, never both.
	 *
	 * @param data the data map
	 */
	void setDataMap(Map data);

	/**
	 * Returns the headers map. On inbound messages this is set, if the structured flag is set (default).
	 * In case of a cloudevents message the headers map contains all properties of the message, except for "data".
	 *
	 * Note, that either {@link #getData()} or the two maps {@link #getDataMap()} and {@link #getHeadersMap()} are set, never both.
	 *
	 * @return the header map
	 */
	Map getHeadersMap();

	/**
	 * Sets the headers map.
	 * In case of a cloudevents message the headers map contains all properties of the message, except for "data".
	 *
	 * Note, that either {@link #getData()} or the two maps {@link #getDataMap()} and {@link #getHeadersMap()} can be set, never both.
	 *
	 * @param headers the structured header data as a map
	 */
	void setHeadersMap(Map headers);

	/**
	 * Returns the message ID usually generated by the message broker
	 * @return the message ID usually generated by the message broker
	 */
	String getMessageId();

	/**
	 * Sets the message ID
	 * @param id the message ID
	 */
	void setMessageId(String id);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy