I want to create a custom node for ActiveMQ queue/topic

Just wanted to say that I’m totally impressed with the work and collaboration that is happening here in this thread. This is exactly how this whole thing should work!

Well done!

3 Likes

Hey Ricardo it’s me again :face_with_hand_over_mouth:
Here what’s happened,
After I add amqplib to package.json the error gone and work fine
I add another module ‘mqtt’ the same way but it said module not found :sob:

I move to other device and start over
I added both of them to package.json and run “dev” fine
Now for both n8n editor said module not found :sob::sob:

So what’s wrong???
The package.json inside nodes_base (same level as nodes folder)

@Alhussein looks like you are not installing the package. I just tested and worked for me. Do the following:

Go to the nodes-base directory and run

  • npm install --save amqplib

  • npm install --save mqtt

Then add the require/import were want to use them.

Then go back to the project root directory and run

  • lerna bootstrap --hoist

  • npm run build

  • npm run dev

that should do it. If this does work simply get back to me.

1 Like

I’m also impresse by collaboration and the project it self, really it’s highly positive energy here :smiling_face_with_three_hearts::smiling_face_with_three_hearts::heart_eyes::heart_eyes::v::v:
In addition to the design of this forum which is amazing :smiling_face_with_three_hearts::smiling_face_with_three_hearts:

1 Like

Hey Ricardo, @jan :face_with_hand_over_mouth:
Here’s other issue
I made trigger nodes for both amqplib & mqtt and they work fine, but when coming to sender I made it execute node and also try executeSingle but strange thing happened, each code executed well except the the code inside connect function for both libraries even simple console.log and no error shown up so it ignore the desired instructions (publish which lie inside connect) , I found it strange :rofl::sob::broken_heart:
I tried a lot but I failed to figure it out :face_with_hand_over_mouth:

client = ExampleLib.connect(host, options, function()
client.on(‘connect’, function() {
//Every code here get ignored :frowning:
//the code is running fine when running in nodejs
})

And other confusion for me and it’s not directly related to n8n, how to use these libraries in typescript way??

Hey @Alhussein, not sure if I understand fully. You did the triggers and it’s working fined but then you created a regular node to send data events I guess. is that right?

Probably the code inside connect it’s not executed cuz the execute function it’s retuning before you connect to amqplib/mqtt.

Can you share the code so that I can have a quick look at it?

1 Like

You understood me well, and i’m sure the issue is that the execute function is returned before or during amqp/mqtt connection because code is running fine in normal nodejs code :slight_smile: and this case happened with both library in execute node, below is screenshot
and noticed that closeFunction is disabled, how to using it in right way?

yeah, the close function it’s disabled cuz it’s not being used. Try changing send() for await send(). Also, I encourage you to use execute instead of executeSingle as it might be deprecated in the future.

Let me know.

I change send() to await send()
now all code executed but msg didn’t send to queue whereas the same code sending msg fine in nodejs :frowning:

here is a new code

Hard to help you by just looking at the code. Push it to public repository so that I can clone and have a look.

Was checking the package and looks like if you set the env variable below it will output error to the console. Maybe like that you can find out the error.

LOG_ERRORS=true

Sorry I didn’t understand what you mean :face_with_hand_over_mouth:
anyway I didn’t change any configuration file or env variables… all defaults.

If you set the env variable and the library errors you will be able to see the errors on the console and find out why it’s not working. I believe right now the code runs, do not send the message and do not error right?

1 Like

Exactly and that’s what makes me mad :slight_smile:
Also if I mess with any parameter it raised an error.
So what exactly should I do???
simply just: “export LOG_ERRORS=true” or what?
I try to at n8n documentation but unfortunately I didn’t find what I’m looking for.

yes, do that and then run the project again, hopefully you should see the error on the console. You are not gonna find anything about that on the docs cuz your issue is with node/amqp not with n8n.

I did “export LOG_ERRORS=true” and then “npm run dev”
but no difference, no error show up. :frowning:

I see. Well then in order to help you I need you to push to a public repo or private where you can give me access so that I can clone it a test it.