I’m very interested in n8n and would like to use it for my next project.
We are using ActiveMQ for events and currently we have to write listeners/connectors to many systems manually.
n8n seems like a good fit.
I’m interested to write a custom node that can connect and react to ActiveMQ events and contribute the node to the n8n community.
Before I start I wanted to ask if there are any limitations to how custom nodes work why there are no other queue-connectors yet.
Do they have timeout limitations? Is it not possible to keep a connection open to a queue for a long time?
Thanks for any input or hints that could help me in developing such a connector.
Great to have you here! Happy to hear that you are interested in n8n and thinking about using it.
The reason that there are no queue connectors yet is just a lack of time. Implementing them should be not complicated. There are no known limitations in n8n which should cause any problems.
You just have to implement the “trigger” function. This is the function which gets called when a workflow gets activated. There you can create the connection. Then every time a message gets received simply the this.emit function can be called with the message.
The function itself returns than simply the closeFunction which gets called when the workflow gets deactivated or n8n gets shut down (there you can close the connection to the queue). Additionally, also the manualTriggerFunction could be implemented but does not make much sense in this case. That function sends some example data when in development mode but in your case, it would not be needed as you would like to wait for an actual event and its data when testing/developing a workflow.
Hope that helps! If you have any other questions simply get back to me!
For the request/http library that is a very hard rule. As I do really not see a reason to have multiple libraries that do the same.
For other libraries that is a little bit different. If it is possible to avoid I prefer to not add them if it does not have any disadvantages and the additional work involved is reasonable. But it does also not make sense to reinvent the wheel. So, in this case, I can see why adding an external dependency makes sense. Especially does it seem like one that does not have many dependencies by itself.
Yes, that would probably be best. Here is also a guide on how to create a node for n8n and how to set it up:
Yes, some nodes use already external dependencies. Want to however remove in the long-term some of them again. Like for example the “googleapis” as it should all be possible directly via REST. It is however still there as it was one of the first nodes I ever created for n8n and so it stayed behind. And because the library was now already there anyway, I also reused it in the Google Drive node.
I would probably move host & port into the credentials and make them required. After all, it is a unit and they belong together. Even though host and port do not have to get saved encrypted it makes it easier for the user to define all of that once and then simply select them instead of having to define them again and again. The credentials can there also be imagined as connections to make it convenient for the users. Also if the host will change in the future will they have to change it only once in the credentials and not separate on every node in every workflow.
You are right, the “manualTriggerFunction” does not make sense here and can simply be omitted.
I think the linter is to set up to complain if callback functions are defined like this: function(a) { ... }. You should therefore normally use the short syntax (a) => {...}. But you can check by running npm run lint. The same when defining “port: port,” in line 98. The short form port, should be used.
Those are at least the things that jumped in my eye without downloading and testing it.
Thanks a lot for your work! Looking forward adding it to n8n!
Uh strange. Thought it was In the package.json. Sadly not in front of my computer. So can not check. But you should be able to add it manually with npm I tslint
We need nodes for send/trigger to Rabbitmq also @jan said that the AMQP Sender & AMQP Trigger are designed to work with ActiveMQ, So why you do just use them??
I really enjoy your talking @jan & @leonardlin
Hey @leonardlin it’s me again
I follow the step as possible as I can
I try to use ‘ampqlib’ and ‘amqp-ts’ external library to connect to rabbitmq but I faced an error which is say: amqplib not found
here what I did:
1- Install n8n-node-dev
2- clone n8n source code from github
3- run lerna bootstrap --hoist in the n8n folder
4- n8n-node-dev new >> node >> till created
5- I require amqplib and used it to simply just send msg to queue (the code is working as nodejs program)
6- I add amqplib to package.json file in n8n/packages/nodes-base/ folder
7- npm run build and npm run start fine
8- new node appear on ui editor fine, but when executed said that amqplib isn’t found
I try to use npm install I messed up
So what I missed here ???
How to add an external library to n8n code??
is it just simply added the desired library to package.json inside nodes-base folder??
thanks in advance
Thanks so much @RicardoE105 It work fine now…
Yesterday I did as you said but I didn’t know why it’s wont work…
Thanks Again @RicardoE105, @jan, and @leonardlin
I really appreciate your Quick replies