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

consumers are lost after the app code that creates the broker is stopped #165

Closed outjoker closed 3 years ago

outjoker commented 3 years ago

I have written a nodejs sample app server, which on application init , tries to create a broker with the following sample rascal configuration file

{
  "vhosts":{
    "/":{
      "connection":{
        "url":"amqp://<username>:<password>@localhost:5672",
        "options":{
          "heartbeat":10,
          "connection_timeout":60000
        },
        "retry":{
          "min":1000,
          "max":60000,
          "factor":2,
          "strategy":"exponential"
        },
        "socketOptions":{
          "timeout":10000
        },
        "slashes":true
      },
      "exchanges":[
        "exchange1"
      ],
      "queues":{
        "queue1":{
          "options":{
            "arguments":{
              "x-message-ttl":3600000,
              "x-dead-letter-exchange":"queue2",
              "durable":true
            }
          }
        }
      },
      "bindings":[
        "exchange1[azure] -queue1"
      ],
      "publications":{

      },
      "subscriptions":{
        "subscriber1":{
          "queue":"queue1"
        }
      }
    }
  }
}

after crearing the broker, i have also called the broker.subscribe function to establish the subscriber for the respective queues

i have tested the message flow from publisher to the subscriber and everything is working fine. |

but i have stopped my node app and i see that the consumer that got created for the queue got deleted , i had to re-run the broker.subscribe to get the consumer back when consumer is present image

when the app is stopped

image is there someway using rascal we can check whether the consumers are present or not or if there is someway to get these consumer back?

cressie176 commented 3 years ago

Hi @outjoker,

Thank you for taking to explain the problem. In this case I think the issues is a slight misunderstanding of RabbitMQ terminology. The consumer is your node application, so when it was stopped the RabbitMQ dashboard didn't display it. To continue consuming messages you will need to leave your application running

outjoker commented 3 years ago

that's right @cressie176 my node app was the consumer here and once i stopped it, the dashboard stopped showiing it

cressie176 commented 3 years ago

That's the expected behaviour @outjoker. I'm no longer sure what you are asking.

However, if you just want to monitor whether a queue has consumers, there are various ways but all are outside the scope of Rascal. For example, you could use the RabbitMQ Management Plugin's HTTP API to poll the number of consumers and report it it fell to zero. Popular monitoring tools such as DataDog will have out of the box integrations too.

outjoker commented 3 years ago

thanks @cressie176 for the inputs, will definitely check them out. I will close this issue now as the usecase i am pointing is not within the scope of rascal package