0

我可以将 rabbit mq exchange 与我的node.js server. 但是,如果我从 Rabbit MQ UI 手动删除交换,那么有什么方法可以检查node.js交换是否被删除或connection关闭。

因为在同一交易所发布消息时,node.js崩溃并且我无法exception使用try catch. 我想node.js在处理后重新创建交换exception

exchange.publish(ROUTING_KEY, msg);  //here exchange is already deleted so throwing below error 

    Error: NOT_FOUND - no exchange 'lutron.poc.incoming' in vhost '/'
    at Exchange._onMethod (F:\workspaces\LutronHeroku_GITnew\lutroncloudserverco
nnector\lutroncloudserverconnector\node_modules\amqp\amqp.js:2091:15)
    at Exchange.Channel._onChannelMethod (F:\workspaces\LutronHeroku_GITnew\lutr
oncloudserverconnector\lutroncloudserverconnector\node_modules\amqp\amqp.js:1533
:14)
    at Connection._onMethod (F:\workspaces\LutronHeroku_GITnew\lutroncloudserver
connector\lutroncloudserverconnector\node_modules\amqp\amqp.js:1056:28)
    at AMQPParser.self.addListener.parser.onMethod (F:\workspaces\LutronHeroku_G
ITnew\lutroncloudserverconnector\lutroncloudserverconnector\node_modules\amqp\am
qp.js:895:12)
    at AMQPParser._parseMethodFrame (F:\workspaces\LutronHeroku_GITnew\lutronclo
udserverconnector\lutroncloudserverconnector\node_modules\amqp\amqp.js:449:10)
    at frameEnd (F:\workspaces\LutronHeroku_GITnew\lutroncloudserverconnector\lu
troncloudserverconnector\node_modules\amqp\amqp.js:190:16)
    at frame (F:\workspaces\LutronHeroku_GITnew\lutroncloudserverconnector\lutro
ncloudserverconnector\node_modules\amqp\amqp.js:175:14)
    at AMQPParser.header [as parse] (F:\workspaces\LutronHeroku_GITnew\lutronclo
udserverconnector\lutroncloudserverconnector\node_modules\amqp\amqp.js:162:14)
    at AMQPParser.execute (F:\workspaces\LutronHeroku_GITnew\lutroncloudserverco
nnector\lutroncloudserverconnector\node_modules\amqp\amqp.js:234:21)
    at Connection.<anonymous> (F:\workspaces\LutronHeroku_GITnew\lutroncloudserv
erconnector\lutroncloudserverconnector\node_modules\amqp\amqp.js:932:12)
Server: worker 4028  died; signal null

有没有办法抓住这个exception

4

0 回答 0