waterlinejs / rabbitmq-adapter

RabbitMQ Adapter for Sails and Waterline
Other
17 stars 2 forks source link

Unable to get the messages from queue #7

Open Anandapriyan opened 9 years ago

Anandapriyan commented 9 years ago

Hi i am trying to use rabbitmq in my sails app. when I try to post data in my model after giving the connections adapter I can see the data received in my rabbit queue but the database has not created. I'm using mongo database for my models The connection adapter is - rabbitCluster: { adapter: 'sails-rabbitmq', //my amqp rabbitmq installation url url: 'amqp://localhost', }, MongoDB: { adapter: 'sails-mongo', host: 'localhost', port: 27017, user: '', password: '', database: 'myTest' } inside my model specified the connection as follow connection : ['rabbitCluster','MongoDB'] //in my config/rabbitmq.js file module.exports.rabbitmq = { pkFormat: 'string' }; as I understand we don't need to write create and update controller methods it should work with default CRUD operations provided by sails. but i get no response when i try to create a database entry.

Thanks in advance Anandapriyan

ryanwilliamquinn commented 9 years ago

Hi @Anandapriyan, try setting the persistence: true in your rabbitCluster config object. This persistence flag allows you to have one service push jobs into rabbit, and one or more services (each with persistence: true) to handle actually persisting the models to the database. In your case, you will have the same service push the jobs into rabbit and also manage the persistence.

Let me know if that works for you.

rasekar2000 commented 9 years ago

Hi Ryan @ryanwilliamquinn ,

We both are working in the same project. We have followed the steps explained in https://www.npmjs.com/package/sails-rabbitmq. And When I persist the data in Message DataModel, it gets saved in MongoDB as well as in RabbitMQ ( CloudAMQP.com ). But i am seeing this error message in the sails lift console.

  sails-rabbitmq: waiting for orm hook to load before binding persistence handlers...

Any tips for avoiding this warning message?

As well my subscription program in api/services is not getting invoked.. For testing purpose, invoked this service from a sails controller, yet,

  Message.getSubscribeSocket({ where: { stream: 'random' } })
 .then(function (socket) {
socket.on('data', function (data) {
  var message = JSON.parse(data);
  // see, I told you it was "low-level" 

  // ... 
});
});

https://stackoverflow.com/questions/32012734/how-to-subscribe-sailsjs-rabbitmq-adapter Thanks in advance for your guidance

rasekar2000 commented 9 years ago

Hello Ryan @ryanwilliamquinn ,

Trying to test the Unit & Integration Tests, delivered in this solution, but I am getting the following error.

Install mocha-traceur

@code RajRajen:rabbitmq-adapter-master rajrajen$ npm install mocha-traceur --save-dev (Ref : Write your Mocha- ES6 Test --> http://blog.ibangspacebar.com/write-your-mocha-tests-in-es6/) npm WARN peerDependencies The peer dependency traceur@>= 0.0.79 < 1 included from traceur-runner will no npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly. npm WARN peerDependencies The peer dependency traceur@>= 0.0.61 < 0.1.0 included from traceur-source-maps will no npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly. mocha-traceur@2.1.0 node_modules/mocha-traceur ├── traceur@0.0.91 (commander@2.6.0, semver@2.3.2, rsvp@3.0.21, glob@4.3.5, source-map-support@0.2.10) └── traceur-runner@1.0.2 (glob@4.5.3, traceur@0.0.91, traceur-source-maps@1.0.6)

Adapter.js

By the way , I have setup the following in this adapter.js

/rabbitmq-adapter-master/lib/adapter.js defaults: { //url: 'amqp://localhost', url : 'amqp://cloudamqURL', --> Replaced this with Actual URL schema: false },

mocha ES6

RajRajen:rabbitmq-adapter-master rajrajen$ mocha --compilers js:mocha-traceur --reporter spec test//adapter..js test/.js

@Adapter

getPersistenceConnection

  1) should return the non-rabbitmq connection

2) "after all" hook

0 passing (70ms) 2 failing

1) @Adapter #getPersistenceConnection should return the non-rabbitmq connection: TypeError: undefined is not a function at Context. (test/unit/adapter.test.js:7:44)

2) "after all" hook: TypeError: undefined is not a function at Context. (test/bootstrap.test.js:69:9)

Can you please update if I am on the right way of testing the Mocha ES6. Thanks in advance.

Ps : I think similar to Redis - MakeFile documentation (https://github.com/balderdashy/sails-redis/blob/master/Makefile) , would also be really helpful.