1

I read this article to push rabbit mq messages from web form application.

Is it correct to push objects directly from web form aspx cs class i.e. calling producer.SendMessage(...) from button_click event OR this should be part of business logic?

Which layer this code should be called from? How to decide this?

Sahil Sharma
  • 3,847
  • 6
  • 48
  • 98
  • Does it throw an exception? No? Then it's correct. Anything beyond that are just recommended patters, which are opinion based and beyond the scope of StackOverflow. – Gusman May 02 '17 at 18:37

1 Answers1

2

If you are doing multi-tiered design, then you are on the right track. Keep the implementation (i.e. calls to RabbitMQ, or databases, or other servers) completely separate from the user interface code. Otherwise, if you have to change things (for example, switching to MSMQ or some other queue product) it'll be much harder to change later on.

Xavier J
  • 4,326
  • 1
  • 14
  • 25
  • So you suggest call to producer.SendMessage(...) to be moved to business layer with dependency injection, correct? – Sahil Sharma May 02 '17 at 18:50
  • As best you can. There's always the possibility that RabbitMQ doesn't suit your needs performance wise, or for a thousand other reasons. In the best approach, your client code shouldn't have any direct dependencies on the library you use to access the queue. – Xavier J May 02 '17 at 18:53