/AWS1/IF_IOP=>SENDDIRECTMESSAGE()¶
About SendDirectMessage¶
Sends an MQTT message directly to a specific client identified by its client ID.
SendDirectMessage targets a single client ID. The receiving client does not
need to subscribe to the topic, but the receiver's policy must allow iot:Receive on the specified topic.
Requires permission to access the SendDirectMessage action.
For more information about messaging costs, see Amazon Web Services IoT Core pricing.
Method Signature¶
METHODS /AWS1/IF_IOP~SENDDIRECTMESSAGE
IMPORTING
!IV_CLIENTID TYPE /AWS1/IOPCLIENTID OPTIONAL
!IV_TOPIC TYPE /AWS1/IOPTOPIC OPTIONAL
!IV_CONTENTTYPE TYPE /AWS1/IOPCONTENTTYPE OPTIONAL
!IV_RESPONSETOPIC TYPE /AWS1/IOPRESPONSETOPIC OPTIONAL
!IV_CONFIRMATION TYPE /AWS1/IOPCONFIRMATION OPTIONAL
!IV_TIMEOUT TYPE /AWS1/IOPTIMEOUTINSECONDS OPTIONAL
!IV_PAYLOAD TYPE /AWS1/IOPPAYLOAD OPTIONAL
!IV_USERPROPERTIES TYPE /AWS1/IOPSYNTHEDJSONUSERPRPS OPTIONAL
!IV_PAYLOADFORMATINDICATOR TYPE /AWS1/IOPPAYLOADFMTINDICATOR OPTIONAL
!IV_CORRELATIONDATA TYPE /AWS1/IOPCORRELATIONDATA OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_iopsenddirectmsgrsp
RAISING
/AWS1/CX_IOPFORBIDDENEXCEPTION
/AWS1/CX_IOPGATEWAYTIMEOUTEX
/AWS1/CX_IOPINTERNALFAILUREEX
/AWS1/CX_IOPINVALIDREQUESTEX
/AWS1/CX_IOPREQENTTOOLARGEEX
/AWS1/CX_IOPRESOURCENOTFOUNDEX
/AWS1/CX_IOPTHROTTLINGEX
/AWS1/CX_IOPUNAUTHORIZEDEX
/AWS1/CX_IOPCLIENTEXC
/AWS1/CX_IOPSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_clientid TYPE /AWS1/IOPCLIENTID /AWS1/IOPCLIENTID¶
The unique identifier of the MQTT client to send the message to.
Client IDs must not exceed 128 characters and can't start with a dollar sign ($). MQTT client IDs must be URL encoded (percent-encoded) when they contain characters that are not valid in HTTP requests, such as spaces, forward slashes (/), and UTF-8 characters. For more information, see Amazon Web Services IoT Core message broker and protocol limits and quotas.
iv_topic TYPE /AWS1/IOPTOPIC /AWS1/IOPTOPIC¶
The topic of the outbound MQTT Publish message to the receiving client. For more information, see Amazon Web Services IoT Core message broker and protocol limits and quotas.
Optional arguments:¶
iv_contenttype TYPE /AWS1/IOPCONTENTTYPE /AWS1/IOPCONTENTTYPE¶
The MQTT5 content type property forwarded to the receiving client (for example,
application/json).
iv_responsetopic TYPE /AWS1/IOPRESPONSETOPIC /AWS1/IOPRESPONSETOPIC¶
A UTF-8 encoded string that's used as the topic name for a response message. The response topic describes the topic which the receiver should publish to as part of the request-response flow. The topic must not contain wildcard characters. For more information, see Amazon Web Services IoT Core message broker and protocol limits and quotas.
iv_confirmation TYPE /AWS1/IOPCONFIRMATION /AWS1/IOPCONFIRMATION¶
A Boolean value that specifies whether to wait for delivery confirmation from the receiving client.
When set to
true, the API delivers the message at QoS 1 and waits for the client to send a delivery confirmation (PUBACK) before returning a successful response. If delivery confirmation is not received within the specifiedtimeoutperiod, the API returns HTTP 504.When set to
false, the API delivers the message at QoS 0 and returns after Amazon Web Services IoT Core attempts to deliver the message.Valid values:
true|falseDefault value:
false
iv_timeout TYPE /AWS1/IOPTIMEOUTINSECONDS /AWS1/IOPTIMEOUTINSECONDS¶
An integer that represents the maximum time, in seconds, to wait for a delivery confirmation (PUBACK) from the receiving client after the message has been delivered. This parameter is only used when
confirmationis set totrue. Ifconfirmationisfalse, this parameter is ignored.The total API response time may be higher than this value due to internal processing. Set your HTTP client timeout to a value greater than this parameter.
Valid range: 1 to 15 seconds.
Default value:
5seconds.
iv_payload TYPE /AWS1/IOPPAYLOAD /AWS1/IOPPAYLOAD¶
The message body. MQTT accepts text, binary, and empty (null) message payloads.
iv_userproperties TYPE /AWS1/IOPSYNTHEDJSONUSERPRPS /AWS1/IOPSYNTHEDJSONUSERPRPS¶
A JSON string that contains an array of JSON objects. If you don't use Amazon Web Services SDK or CLI, you must encode the JSON string to base64 format before adding it to the HTTP header.
userPropertiesis an HTTP header value in the API.For MQTT 3.1.1 clients, user properties are silently dropped.
The following example
userPropertiesparameter is a JSON string which represents two User Properties. Note that it needs to be base64-encoded:
[{"deviceName": "alpha"}, {"deviceCnt": "45"}]
iv_payloadformatindicator TYPE /AWS1/IOPPAYLOADFMTINDICATOR /AWS1/IOPPAYLOADFMTINDICATOR¶
An
Enumstring value that indicates whether the payload is formatted as UTF-8.payloadFormatIndicatoris an HTTP header value in the API.
iv_correlationdata TYPE /AWS1/IOPCORRELATIONDATA /AWS1/IOPCORRELATIONDATA¶
The base64-encoded binary data used by the sender of the request message to identify which request the response message is for when it's received.
correlationDatais an HTTP header value in the API.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_iopsenddirectmsgrsp /AWS1/CL_IOPSENDDIRECTMSGRSP¶
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->senddirectmessage(
iv_clientid = |string|
iv_confirmation = ABAP_TRUE
iv_contenttype = |string|
iv_correlationdata = |string|
iv_payload = '5347567362473873563239796247513D'
iv_payloadformatindicator = |string|
iv_responsetopic = |string|
iv_timeout = 123
iv_topic = |string|
iv_userproperties = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lv_responsemessage = lo_result->get_message( ).
lv_traceid = lo_result->get_traceid( ).
ENDIF.