Cancel Scheduled Message¶
Delayed delivery as well as repeated publish messages can be canceled using the API documented below:
Blocking API
¶
public boolean Backendless.Messaging.cancel( String messageId ) throws BackendlessException;
Non-Blocking API¶
public void Backendless.Messaging.cancel( String messageId,
AsyncCallback<MessageStatus> responder );
where:
Argument | Description |
---|---|
messageId |
ID of the message to cancel. Message ID must be obtained from the MessageStatus object obtained as the result of the Publish methods. |
responder |
contains the ID of a message and its status. If the cancellation is successful, the getStatus() method on the MessageStatus object returns the value of com.backendless.messaging.PublishStatusEnum.CANCELED ). |
Return value¶
Argument | Description |
---|---|
boolean |
true if the scheduled message has been successfully canceled, false otherwise. |
Errors¶
The following errors may occur during the message cancellation API call. See the Error Handling section for details on how to retrieve the error code when the server returns an error:
Error Code |
Description |
---|---|
5040 |
Message has already been canceled or does not exist. |
Example¶
String messageId = // message id can be obtained from the MessageStatus object
// received in the result of the publishing API
Backendless.Messaging.cancel( messageId );