I'd suggest two ways of dealing with a legacy app like that, one more external and the later less: - run both apps, and as you migrate old services to the new app, simply redirect (using a load balancer) traffic to a given API to one or the other application. Once the old one does not serve any traffic, you can stop running it. This has the downside of less code work - if the old APIs just work, no need to touch them. It does not allow shared state between the apps - which can be a good thing actually (or it may complicate things it the service relied on shared state a lot - bad idea, but this happens of course). - extract the logic from the servlet code into methods that take well defined parameters. Reimplement the routing in akka-http and all into those methods from the new routing layer. This way you don't need to change any logic, except the parameter extracting and routing, so it may be a viable option for medium sized apps.
Hope this helps! On Thu, Jul 2, 2015 at 12:18 PM, Konrad Malawski <[email protected]> wrote: > Hi Filippo, > In order to run servlets you'd have to implement a proper servlet > container. Akka Http does not aim to implement servlet spec. > The reason is that the servlet specification has very strict requirements > on threading etc. which does not fit reactive systems very well. > For example servlets heavily rely on the 1-thread-per-request model, and > even given the new spec version 3.1 in which async servlets are introduced > it is still rather rough and very simple to get wrong (as user), > so it is not something we aim to support (unless there is significant > commercial interest). > > Perhaps it would be possible to hack something together that works "most > of the time" quickly, but at some point you'd bump into that the servlet > code expected something as in accordance to the spec, > yet the bridge is just a simple hack and things would go wrong... > > PS: Spray was able to run *inside* a servlet container, but not *host* > servlets. In that scenario you basically lost all good what spray would > have given you. It is also not something we aim to implement in akka-http - > "why lose all the goodies"? > > > On Thu, Jul 2, 2015 at 12:00 PM, Filippo De Luca <[email protected]> > wrote: > >> Hi, >> I am working on a project that has some legacy code based on the Servlet >> API. I would like to transition to an akka-http based project. My idea >> was to define a route like this: >> >> val route = newRoute ~ legacyRoute >> >> In wich legacy route will wrap the servlets in some way. Is it a doable >> approach and is there anyone has done something like that, maybe with a >> different approach? A route is a RequestContext => RouteResult at the end >> of the day, so I think will be not difficult to wrap the servlet service >> inside that. The complex part I think is to pass an implementation of >> ServletContext, ServletHttpRequest, and ServletHttpResponse. >> >> >> -- >> >>>>>>>>>> Read the docs: http://akka.io/docs/ >> >>>>>>>>>> Check the FAQ: >> http://doc.akka.io/docs/akka/current/additional/faq.html >> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user >> --- >> You received this message because you are subscribed to the Google Groups >> "Akka User List" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/akka-user. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Cheers, > Konrad 'ktoso' Malawski > Akka <http://akka.io/> @ Typesafe <http://typesafe.com/> > -- Cheers, Konrad 'ktoso' Malawski Akka <http://akka.io/> @ Typesafe <http://typesafe.com/> -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
