This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
My question is more of a design question. I am trying to ascertain if any frameworks can solve my problem. It seems to me that the situation I have should be a common one but I am having a hard time coming up with an elegant solution.
First of all this is not a web application. There is a dumb hardware device that the user interacts with and this device connects to a hardware router which then communicates via UDP messages with a home grown server. This server determines what app should handle the request and invokes the correct app (bundled as a jar) via reflection. More apps are always being added.
Seems to me this server re-invents the wheel and each app must maintain its own session state since the whole process is conversational and the end result depends on user input.
If this were a web app Spring MVC Dispatcher servlet could handle routing to the correct app and spring web flow could maintain the data in the session and handle the conversational aspect of the program, and I would have a browser as a client to render the view rather than a dumb device. (the views are currently just a few lines of text).
I figured that I could use spring integration and JMS to handle splitting, aggregating, transforming and routing the incoming UDP message. But I want to keep the app modular so new apps can easily be added without affecting the others. If I deployed it in a container I could use spring MVC and spring Webflow and just return a few lines of text as a view rather than a JSP, but then how to invoke it and how to add more apps without having a ton of war files. I also thought maybe OSGI could help me here. I really would like a framework that could handle the conversational state factor and manage the session object data for me, like spring web flow does.
Personally, from your description, it says 100% to me to use Spring Integration. When you add a new app, it could be either as simple as updating an xml file for the router to route to a JMS queue that your new application is listening to. Or the message that the new app sends has the name of the JMS Queue in the header of the message that your Spring Integration router reads and it is automatic so you wouldn't have to change the xml in your Spring Integration project. just deploy your new app jar with it listening in to the new JMS Queue and that is all you need.
Thanks I knew their had to be a simpler way than the way it was being done now. One question though:
There is a hardware router that would pass messages back and forth between the software router(spring integration) and the dumb hardware device which the user interacts with. Each app has a lot of app specific data which must be maintained between messages which is why I said it was conversational. So when the app receives its first message it will begin some processing and start adding data to a session object of sorts until it gets to a point where there is a branch and user input is needed. At that point it sounds like I would attach the object with that data as part of the message payload and probably stick the flow I am on in the message header and send it back. Now before it makes it back to the hardware router I have to transform pieces of the object into a byte array which the hardware device can understand (this message tells the hardware what to display, the message type, and what buttons to enable etc etc) problem is the hardware device would not know what to do with that session object I had on the message (it is specific to the app), so it would have to be dumped before I sent it. Webflow has the ability to store stuff like that in a flow scoped variable and it handles it for you. Would I have to write a component to store these session objects (potentially one per user per app) and figure out a way to re-attach it before sending the next message back to the app or is there some mechanism built in for this type of thing?
That last one sounds like an Aggregator to me, and you can either use built in correlation ids, or create your own correlation strategy to handle when the pieces are complete to move to the next step.
I highly recommend getting the MEAP Manning Early Access Program for the book "Spring Integration in Action" by the guys that created Spring Integration. It isn't complete yet, and there are some minor grammar and spelling issues. But you still get a great insight into all the pieces of Spring Integration.