EasyNetQ with asp.net web api as subscriber

前端 未结 1 1626
灰色年华
灰色年华 2020-12-21 04:54

I have to implement a asp.net web api which acts as a subscriber to rabbitMQ. The windows service is going to publish message to the web api services. There will be more tha

1条回答
  •  有刺的猬
    2020-12-21 05:17

    Generally RabbitMQ subscriptions don't work well with IIS hosted applications because you have no control over when the application is running. IIS will recycle, stop and start the app as it sees fit.

    If you must do it, open the connection to RabbitMQ and start subscribing when the application starts, in Global.asax.cs for example, and make sure to dispose of everything properly when it closes.

    You are far better off building a windows service for the subscription and either writing to a shared store that the IIS hosted web service can access, or alternatively self-hosting the API inside the windows service.

    0 讨论(0)
提交回复
热议问题