rudijs / amqp.node-rpc-factory Goto Github PK
View Code? Open in Web Editor NEWNode.js AMQP RPC Consumer and Publisher Factory
License: MIT License
Node.js AMQP RPC Consumer and Publisher Factory
License: MIT License
When publish two requests, two exclusive reply queues should be asserted so that multiple consumers can be supported. However, currently a new reply queue can only be created after the previous reply queue has been deleted. This introduces a bottleneck for web apps.
Hello,
When I send messages to the consumers, I have this error triggered once every two request.
Stack trace:
Publisher: Publishing:
Publisher: IllegalOperationError: Connection closed
at Connection.<anonymous> (/home/koren/dev/dialonce/amqp-tests/node_modules/amqp-rpc-factory/node_modules/amqplib/lib/connection.js:354:11)
at Channel.C.sendImmediately (/home/koren/dev/dialonce/amqp-tests/node_modules/amqp-rpc-factory/node_modules/amqplib/lib/channel.js:63:26)
at Channel.C.sendOrEnqueue (/home/koren/dev/dialonce/amqp-tests/node_modules/amqp-rpc-factory/node_modules/amqplib/lib/channel.js:74:10)
at Channel.C._rpc (/home/koren/dev/dialonce/amqp-tests/node_modules/amqp-rpc-factory/node_modules/amqplib/lib/channel.js:130:8)
at Channel.C.rpc (/home/koren/dev/dialonce/amqp-tests/node_modules/amqp-rpc-factory/node_modules/amqplib/lib/channel_model.js:59:8)
at /home/koren/dev/dialonce/amqp-tests/node_modules/amqp-rpc-factory/node_modules/amqplib/lib/channel_model.js:70:17
at tryCatchReject (/home/koren/dev/dialonce/amqp-tests/node_modules/amqp-rpc-factory/node_modules/amqplib/node_modules/when/lib/makePromise.js:840:30)
at runContinuation1 (/home/koren/dev/dialonce/amqp-tests/node_modules/amqp-rpc-factory/node_modules/amqplib/node_modules/when/lib/makePromise.js:799:4)
at Fulfilled.when (/home/koren/dev/dialonce/amqp-tests/node_modules/amqp-rpc-factory/node_modules/amqplib/node_modules/when/lib/makePromise.js:590:4)
Do you know where it could come from ?
@robraux Hi Rob,
I've noticed a problem with allowing multiple instances of publishers to exist.
I'm using KoaJS (next gen of ExpressJS) and if the consumer is down when the publisher (the webserver) tries to send a message it will create a new persistent connection for every attempt.
For example, the consumer is down, and the web server sends 10 messages, it will create 10 (persistant) connections.
What it needs to do in my case is have 10 failures on the same single connection.
I'm going to dig into this more.
What you've pointed out here in you pull request:
The problem was with Object.create, the resulting object sets a property of a property.
When two instances are created, they shared the same properties (e.g. queue, url, etc.).
This is actually the behavior I need when the publisher is a web server.
Can you elaborate more why you need the publisher to have multiple instances?
Thanks.
Hi,
first of all: thank you for your work.
every time I create an RPC producer call (not standalone), after receiving the rpc it leaves an empy idle queue on rabbitmq. It's not so funny because for example after 400 requests it leaves 400 empty idle queues.
I suggest that you set "autoDelete: true" when creating the queue.
Thank you
In my application I added a hooks factory around consumer and publisher create, but I in the publisher hooks I cannot get the correlation id.
Knowing the correlation id for me it would be escpeially useful for debugging and logging features. In this way I would be able to connect the parts in third party systems.
The concept can be used by JSON messages as well, check my example below:
What do you think about the following concept?
function myHook (msg, props) {
console.log(props.correlationId)
}
var publisherOptions = {
...
beforeHooks: [myHook1, fromJS]
afterHooks: [toJS, myHook2]
}
var consumerOptions = {
...
beforeHooks: [toJS, myHook3]
afterHooks: [myHook4, fromJS]
}
I wanted to send a pr but stucked with the broken tests.
Any chance that you can take a look for the tests with 4.x.x Node.js?
Updating the packages would be also very helpful.
Thanks,
Peter
Hi,
I'm running two publisher with different queues names
I20160725-23:57:05.887(2)? Publisher: Unexpected amqplib connection error handled by domain:Error: read ECONNRESET
I20160725-23:57:05.887(2)? at errnoException (net.js:905:11)
I20160725-23:57:05.888(2)? at TCP.onread (net.js:559:19)
I20160725-23:57:05.888(2)? Publisher: Unexpected amqplib connection error handled by domain:Error: read ECONNRESET
I20160725-23:57:05.889(2)? at errnoException (net.js:905:11)
I20160725-23:57:05.889(2)? at TCP.onread (net.js:559:19)
W20160725-23:57:05.890(2)? (STDERR)
W20160725-23:57:05.890(2)? (STDERR) TypeError: Cannot set property 'domain' of null
W20160725-23:57:05.890(2)? (STDERR) at Domain.remove (domain.js:116:13)
W20160725-23:57:05.890(2)? (STDERR) at Object.<anonymous> (/Users/bruchmann/git/pt/app/node_modules/amqp-rpc-factory/lib/rpc-publisher-factory.js:48:28)
W20160725-23:57:05.890(2)? (STDERR) at Domain.emit (events.js:117:20)
W20160725-23:57:05.890(2)? (STDERR) at ChannelModel.emit (events.js:70:21)
W20160725-23:57:05.891(2)? (STDERR) at Connection.emit (events.js:95:17)
W20160725-23:57:05.891(2)? (STDERR) at Connection.C.onSocketError (/Users/bruchmann/git/pt/app/node_modules/amqplib/lib/connection.js:351:10)
W20160725-23:57:05.891(2)? (STDERR) at Socket.emit (events.js:117:20)
W20160725-23:57:05.891(2)? (STDERR) at net.js:441:14
W20160725-23:57:05.891(2)? (STDERR) at process._tickDomainCallback (node.js:502:13)
from how I understand code this may happen as the publisherDomain is "static" and both publisher receive the error callback as they are in the same domain.
now one of the two publisher may not have published anything so far and therefore the this.currentConnection
is still null, which results in an error.
I guess on thing to fix it would be to do this in the error handling:
this.currentConnection && this.publisherDomain.remove(this.currentConnection);
But actually I think the domain should not be shared via initing it directly on the prototype but instead in the init method as you may have two instances with different rabbit server/urls and therefore the error events should not be shared.
Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.