I am attempting to implement a subscriber in vue.js using rabbitmq-pubsub
,
however, By doing
var Subscriber = require('rabbitmq-pubsub').Subscriber;
in terminal I see
warning in ./node_modules/_colors@1.0.3@colors/lib/colors.js
127:29-43 Critical dependency: the request of a dependency is an expression
in browser console Is ee
"[WDS] Warnings while compiling."
"./node_modules/_colors@1.0.3@colors/lib/colors.js
127:29-43 Critical dependency: the request of a dependency is an expression
@ ./node_modules/_colors@1.0.3@colors/lib/colors.js
@ ./node_modules/_colors@1.0.3@colors/safe.js
@ ./node_modules/_winston@1.1.2@winston/lib/winston/config.js
@ ./node_modules/_winston@1.1.2@winston/lib/winston.js
@ ./node_modules/_logfilename@0.1.3@logfilename/src/logfilename.js
@ ./node_modules/rabbitmq-pubsub/build/subscriber.js
@ ./node_modules/rabbitmq-pubsub/build/index.js
@ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/SelectServices.vue
@ ./src/components/SelectServices.vue
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://10.9.1.147:8081 webpack/hot/dev-server ./src/main.js"
but when I did this :
var subscriberOptions = {
exchange: 'service_deployment_exchange',
queueName: queue,
url: amqpl_url
};
var subscriber = new Subscriber(subscriberOptions);
function onIncomingMessage(message) {
debug('onIncomingMessage ', message.fields);
console.log(message);
subscriber.ack(message);
//subscriber.nack(message);
};
but when I call the below line in the mounted function in the script element of of my vue single file complonent
subscriber.start(onIncomingMessage)
I get
TypeError: fs.readdirSync is not a function
beside just the warning still showing up in console.
You can't use api of node in browser's code. And I think rabbitmq-pubsub is a node only module.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.