コード例 #1
0
    beforeEach(function(done){
      pub = new Rabbus.Publisher(wascally, {
        exchange: exConfig,
        messageType: msgType1
      });

      var sequencer = new Sequence.Producer({ key: "id" });
      pub.use(sequencer.middleware);

      sub = new Rabbus.Subscriber(wascally, {
        exchange: exConfig,
        queue: qConfig,
        messageType: msgType1,
        routingKeys: msgType1,
      });

      sub.use(function(msg, properties, actions, next){
        results.push(properties.headers["_rabbus_sequence"]);
        next();
      });

      sub.subscribe(function(data){
        done();
      });

      function pubIt(){
        pub.publish({
          id: "qwer-1234a-asdf",
          foo: "bar"
        });
      }

      sub.on("ready", pubIt);
    });
コード例 #2
0
 function pubIt(){
   pub.publish({
     id: "qwer-1234a-asdf",
     foo: "msg 1"
   });
   pub.publish({
     id: "qwer-1234a-asdf",
     foo: "msg 2"
   });
   setTimeout(function(){
     pub.publish({
       id: "qwer-1234a-asdf",
       foo: "msg 3"
     });
   }, 25);
 }
コード例 #3
0
ファイル: publisher.js プロジェクト: fakewaffle/lapin
/*
	Publisher
	@options params
		exchange
		messageType
		autoDelete
 */
function Publisher ( options ) {
	const data = mixins.getProducerOptions( options, 'pub-sub' );

	if ( data instanceof Error ) {
		this.error = data;
	}

	Rabbus.Publisher.call( this, config.rabbit, data );
	this.logger = logger( { 'emitter' : this } );
}
コード例 #4
0
    beforeEach(function(done){
      pub = new Rabbus.Publisher(wascally, {
        exchange: exConfig,
        messageType: msgType1
      });

      var pubSeq = new Sequence.Producer({ key: "id" });
      pub.use(pubSeq.middleware);

      sub = new Rabbus.Subscriber(wascally, {
        exchange: exConfig,
        queue: qConfig,
        messageType: msgType1,
        routingKeys: msgType1,
      });

      //hijack the sequence header and update it with a new id
      var subCount = 0;
      sub.use(function(message, properties, actions, next){
        subCount += 1;
        if (subCount != 3) { 
          return next(); 
        }

        newId = "modified.qwer.1234-asdf." + Date.now().toString();

        var headers = properties.headers;
        var seq = headers["_rabbus_sequence"];
        seq._id = newId;
        seq.number = 1;

        next();
      });

      var subSeq = new Sequence.Consumer({ key: "id" });
      sub.use(subSeq.middleware);

      sub.subscribe(function(data){
        if (subCount === 3){
          done();
        }
      });

      function pubIt(){
        pub.publish({
          id: "qwer-1234a-asdf",
          foo: "msg 1"
        });
        pub.publish({
          id: "qwer-1234a-asdf",
          foo: "msg 2"
        });
        setTimeout(function(){
          pub.publish({
            id: "qwer-1234a-asdf",
            foo: "msg 3"
          });
        }, 25);
      }

      sub.on("ready", pubIt);
    });
コード例 #5
0
 function pubIt(){
   pub.publish({
     id: "qwer-1234a-asdf",
     foo: "bar"
   });
 }