Permalink
Browse files

added support to define exchange details

  • Loading branch information...
jamescarr committed Mar 29, 2012
1 parent bf8ac34 commit 1ab604760430be861df522d969fdb66b2e927fda
Showing with 9 additions and 2 deletions.
  1. +9 −2 index.js
View
@@ -3,7 +3,6 @@ var amqp = require('amqp')
module.exports = exports = function amqpPlugin(schema, options){
connect(options, function(ex){
schema.post('save', function(){
- console.log('saving')
ex.publish(ex.name+'.update', this)
});
schema.post('remove', function(){
@@ -21,6 +20,14 @@ function connect(options, callback){
}, 5000);
});
conn.on('ready', function(){
- callback(conn.exchange(options.exchange))
+ var e = options.exchange;
+ if(typeof e == 'string'){
+ callback(conn.exchange(e))
+ }
+ else if(typeof e == 'object'){
+ var name = e.name;
+ delete e.name;
+ callback(conn.exchange(name, e))
+ }
});
}

0 comments on commit 1ab6047

Please sign in to comment.