onebeyond / rascal

A config driven wrapper for amqp.node supporting multi-host connections, automatic error recovery, redelivery flood protection, transparent encryption / decryption and channel pooling.
MIT License
451 stars 69 forks source link

Avoid assertQueues - connect without knowing the config of existing queue #184

Closed emcodem closed 2 years ago

emcodem commented 2 years ago

Sorry if i misunderstand the concept but i prefer my Clients not to need to create a queue but instead only use a single existing, permanent queue. Also my clients are not expected to know the exact configuration of the permanent queue, i cannot imagine maintaining a config file locally on tens of clients that reflects the current configuration of the central queue. Currently, without knowledge of the exact configuration of the central queue, clients cannot connect due to the use of assertQueue in Rascal.

For that, one must avoid the assertqueue function but instead only use checkQueue from amqplilb. It seems that rascal does not support this mode of operation. So i removed tasks.assertQueues, from Vhost.js here:

const init = async.compose(tasks.closeChannel, tasks.applyBindings, tasks.purgeQueues, tasks.checkQueues, tasks.assertQueues, tasks.checkExchanges, tasks.assertExchanges, tasks.createChannel, tasks.createConnection, tasks.checkVhost, tasks.assertVhost); Besides obviously removing the ability of the client to create a non existing queue on connect, would you expect any other issues like would rascal not try to reconnect forever when the rabbit host is down or such?

Thanks for the great library btw, just what i needed :D

cressie176 commented 2 years ago

Hi @emcodem,

Thanks for your question. Instead of removing the task you can simply disable the assert task from config. As an additional safety measure I would still check that the queue exists.

{
  "vhosts": {
    "v1": {
      "queues": {
        "q1": {
          "assert": false,
          "check": true
        }
      }
    }
  }
}
emcodem commented 2 years ago

Damn, i should have seen that, it's in assertVhost.js if (!config.assert) return next(null, config, ctx);

Sorry for the confusion. Just a quick follow-up question, is there some additional documentation that i have overseen or is README.md the only one?

cressie176 commented 2 years ago

Hi @emcodem,

Damn, i should have seen that, it's in assertVhost.js

No problem. I like the easy questions!.

is there some additional documentation that i have overseen or is README.md the only one

The only documentation is the README, however it's well worth familiarising yourself with the amqplib channel-api If you understand this, you'll have a much better understanding of what's going on under Rascal's hood.

emcodem commented 2 years ago

Yeah i guess my confusion was mostly cause by not having a list of options that i can pass to the elements in the config. As a beginner with rascal, it is a little unclear where i can check out what elements of the config support which options.

Also, i was probably more looking for a method to suppress the assertqueue instead of a config options but that is something the readme.md definitely mentions : it's config-driven:D Anyway thanks for your splendid help!

cressie176 commented 2 years ago

Understood. The schema might help.

cressie176 commented 2 years ago

You can reference it from your configuration file as described here, then depending on your IDE you should get basic auto complete