lib/exchange-machine.js
function(message) {
      let publishTimeout = message.timeout || options.publishTimeout || message.connectionPublishTimeout || 0;
      logger.silly(`Publish called in state ${this.state}`);
      return new Promise((resolve, reject) => {
        let timeout;
        let timedOut;
        if(publishTimeout > 0) {
          timeout = setTimeout(() => {
            timedOut = true;
            reject(new Error('Publish took longer than configured timeout'));
            this.removeDeferred(reject);
          }, publishTimeout);
        }
        const onPublished = () => {
          resolve();
          this.removeDeferred(reject);
        };
        const onRejected = (err) => {
          reject(err);
          this.removeDeferred(reject);
        };
        let op = () => {
          if(timeout) {
            clearTimeout(timeout);
            timeout = null;
          }
          if(!timedOut) {
            return this.channel.publish(message)
              .then(onPublished, onRejected);
          }
          return Promise.resolve();
        };
        this.deferred.push(reject);
        this.handle('publish', op);
      });
    }
function(message) {
      let publishTimeout = message.timeout || options.publishTimeout || message.connectionPublishTimeout || 0;
      logger.silly(`Publish called in state ${this.state}`);
      return new Promise((resolve, reject) => {
        let timeout;
        let timedOut;
        if(publishTimeout > 0) {
          timeout = setTimeout(() => {
            timedOut = true;
            reject(new Error('Publish took longer than configured timeout'));
            this.removeDeferred(reject);
          }, publishTimeout);
        }
        const onPublished = () => {
          resolve();
          this.removeDeferred(reject);
        };
        const onRejected = (err) => {
          reject(err);
          this.removeDeferred(reject);
        };
        let op = () => {
          if(timeout) {
            clearTimeout(timeout);
            timeout = null;
          }
          if(!timedOut) {
            return this.channel.publish(message)
              .then(onPublished, onRejected);
          }
          return Promise.resolve();
        };
        this.deferred.push(reject);
        this.handle('publish', op);
      });
    }
function ( message ) { let publishTimeout = message . timeout || options . publishTimeout || message . connectionPublishTimeout || 0 ; logger . silly ( ` ${ this . state } ` ) ; return new Promise ( ( resolve , reject ) => { let timeout ; let timedOut ; if ( publishTimeout > 0 ) { timeout = setTimeout ( ( ) => { timedOut = true ; reject ( new Error ( 'Publish took longer than configured timeout' ) ) ; this . removeDeferred ( reject ) ; } , publishTimeout ) ; } const onPublished = ( ) => { resolve ( ) ; this . removeDeferred ( reject ) ; } ; const onRejected = ( err ) => { reject ( err ) ; this . removeDeferred ( reject ) ; } ; let op = ( ) => { if ( timeout ) { clearTimeout ( timeout ) ; timeout = null ; } if ( ! timedOut ) { return this . channel . publish ( message ) . then ( onPublished , onRejected ) ; } return Promise . resolve ( ) ; } ; this . deferred . push ( reject ) ; this . handle ( 'publish' , op ) ; } ) ; }
Publish a message to the exchange

@public
@memberOf ExchangeMachine.prototype
@param {Object} message - the message to publish, passed to Exchange.publish
@param {Number} message.timeout - the time to wait before abandoning the publish
@returns {Promise} a promise that is fulfilled when publication is complete
Publish a message to the exchange