Decoupling Spring MVC's Controller from the HTTPServlet

I have been working with Spring for a while now to realize that not all of the incoming requests I receive in my app are HTTP-based. Some requests are email-based, and need email-based responses, others are socket-based (receiving notifications when a value changes in my NOSQL store). All of them, though use more or less the same MVC infrastructure.

Therefore, I thought that maybe rearchitecting the application, in order to remove the coupling between controllers and the HTTP infrastructure will help.

The dispatcher should no longer call controller methods directly, but rather extract the request parameters, and use them to create an abstract message (or event), which it then puts on a message bus. On the other hand, every controller will subscribe its actions (instances of the Action class - an implementation of the Command pattern) for different events.

Since I am quite new to Spring Integration, JMS, and other things like that, I have no idea, which messaging technology to choose. Also, I am pretty sure that an architecture like this has been developed already. Perhaps, I may not even be on the right track.

I accept all kinds of suggestions on how to proceed.

Answers


You are right that messaging solution with a little help of some integration patterns is the "right" way to go.

You are saying that e-mails and some NoSQL database are already hitting your controller? This means there is some translation layer between these systems and your controllers. With Spring integration you would use Mail-Receiving Channel Adapter to process incoming e-mails and TCP and UDP Support for NoSQL notifications. Spring MVC controllers can still be used for "true" web requests, accessing message channel underneath.

Each channel adapter would have a unique set of transformers to translate adapter-specific message into canonic format. At the end messages from each endpoints would be routed to the same message channel.

So indeed, your example is a perfect fit for ESB-like solution. Also check out Mule ESB, which is even more mature and powerful.


Need Your Help

Reading archive using 7-zip

c# .net zip 7zip

I'm trying to find a way to read the contents/ file names of a zipped file, unzip the files and then create a text file with a list of all the files unzipped.

Manually editing debianrules file needed for simple build process?

ubuntu makefile debian packaging debhelper

I'm a newbie trying to build a deb to put into a PPA, following this Ubuntu guide, but I run into troubles with the rules file, where I consult this overview and the Debian Policy Manual. I gather ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.