aws/SnsProvider.js
/**
		 * Publishes a message to a topic. The message will be serialized as JSON.
		 *
		 * @public
		 * @param {string} topicName - The name of the topic to publish to.
		 * @param {Object} payload - The message to publish (which will be serialized as JSON).
		 * @param {Object=} createOptions - Options to use when topic does not exist and must be created.
		 * @returns {Promise}
		 */
Publishes a message to a topic. The message will be serialized as JSON.
@public
@param {string} topicName - The name of the topic to publish to.
@param {Object} payload - The message to publish (which will be serialized as JSON).
@param {Object=} createOptions - Options to use when topic does not exist and must be created.
@returns {Promise}
Publishes a message to a topic . The message will be serialized as JSON . @public @param { string } topicName - The name of the topic to publish to . @param { Object } payload - The message to publish ( which will be serialized as JSON ) . @param { Object = } createOptions - Options to use when topic does not exist and must be created . @returns { Promise }
publish(topicName, payload, createOptions) {
			return Promise.resolve()
				.then(() => {
					assert.argumentIsRequired(topicName, 'topicName', String);
					assert.argumentIsRequired(payload, 'payload', Object);
					checkReady.call(this);
					return this.getTopicArn(topicName, createOptions)
						.then((topicArn) => {
							const qualifiedTopicName = getQualifiedTopicName(this._configuration.prefix, topicName);
							return promise.build(
								(resolveCallback, rejectCallback) => {
									logger.debug('Publishing to SNS topic [', qualifiedTopicName, ']');
									logger.trace(payload);
									this._sns.publish({
										TopicArn: topicArn,
										Message: JSON.stringify(payload)
									}, (error, data) => {
										if (error === null) {
											logger.info('Published to SNS topic [', qualifiedTopicName, ']');
											resolveCallback();
										} else {
											logger.error(error);
											rejectCallback('Failed to publish message to SNS topic.');
										}
									});
								}
							);
						});
				});
		}
publish ( topicName , payload , createOptions ) { return Promise . resolve ( ) . then ( ( ) => { assert . argumentIsRequired ( topicName , 'topicName' , String ) ; assert . argumentIsRequired ( payload , 'payload' , Object ) ; checkReady . call ( this ) ; return this . getTopicArn ( topicName , createOptions ) . then ( ( topicArn ) => { const qualifiedTopicName = getQualifiedTopicName ( this . _configuration . prefix , topicName ) ; return promise . build ( ( resolveCallback , rejectCallback ) => { logger . debug ( 'Publishing to SNS topic [' , qualifiedTopicName , ']' ) ; logger . trace ( payload ) ; this . _sns . publish ( { TopicArn : topicArn , Message : JSON . stringify ( payload ) } , ( error , data ) => { if ( error === null ) { logger . info ( 'Published to SNS topic [' , qualifiedTopicName , ']' ) ; resolveCallback ( ) ; } else { logger . error ( error ) ; rejectCallback ( 'Failed to publish message to SNS topic.' ) ; } } ) ; } ) ; } ) ; } ) ; }
Publishes a message to a topic.
Publishes a message to a topic .