简体   繁体   中英

MVC Java SE Application using ActiveMQ for communication

I'm writing a Java desktop application using the MVC pattern without any framework (eg Spring). To decouple the view components from the controllers i would like to use a JMS framework (eg ActiveMQ) for all communication between these layers (ie view requests and controller/model responses), since i don't like the idea that every controller has to know all its corresponding view components (including hierarchies) for receiving and answering view requests. With that the view components still do not know about controllers (which is normal) and the controllers now also do not need to know about its view components, because all messaging would be handled over topic channels, where interested components have listeners registered and therefore receive all relevant requests (controllers) and/or responses (views). Now my question: is this a good idea, just overkill or are there better ways to get this work ?

Thank you!

I think you may very well use ActiveMQ for MVC but it is not required/recommended.

Few reasons -

1) ActiveMQ adds a layer of abstraction which might be heavier/costlier than a little bit sacrifice of abstraction between model-view-controller layers.

2) ActiveMQ (even embedded) needs a careful configuration eg producer flow controls, redelivery, message ordering, message cursors etc. Most of these things are not required for MVC.

3) MVC request and response are usually synchronous with each other which is not the usual case of ActiveMQ request-response. You would most probably need to make it synchronous yourself.

Hence I think it is better to use standard MVC frameworks like Spring here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM