Skip to content

Repeated Publish

Backendless supports repeated message processing - a message is published once, but is delivered to subscribers with the specified frequency. Repeated delivery will stop either at the specified time unless it is canceled using the message cancellation API.

Non-blocking API

var channel = "TestChannel",
    message = "Hello, world!",
    pubOps = null;
    deliveryOps = new Backendless.DeliveryOptions({
        // frequency in seconds
        repeatEvery: 10, 

        // expiration timestamp (in milliseconds), eg: after 1 minute
        repeatExpiresAt: (new Date()).getTime() + 60 * 1000 
    });

Backendless.Messaging.publish( channel, message, pubOps, deliveryOps )
 .then( function( response ) {
  })
 .catch( function( error ) {
  });

Blocking API

var channel = "TestChannel",
    message = "Hello, world!",
    pubOps = null,
    deliveryOps = new Backendless.DeliveryOptions({
        // frequency in seconds
        repeatEvery: 10, 

        // expiration timestamp (in milliseconds), eg: after 1 minute
        repeatExpiresAt: (new Date()).getTime() + 60 * 1000 
    });
var response = Backendless.Messaging.publishSync( channel, 
                                                  message, 
                                                  pubOps, 
                                                  deliveryOps );
// message has been published, message status is available via response.status
// if publish failed - error is described in response.errorMessage