0

I'm developing an embedded Jetty app that needs to provide a rest interface for running processing jobs that last for an extended period of time (10-20 min). Additional complexity is the processing app is written in Python.

My current direction is to separate the platform into two sections:

  • Jetty server handling processing requests and populating a db with the requests.
  • Background Python job watching the db for new processing jobs, then running the processing as required.

My question is - can I realistically do this all under the Jetty server in Java, instead of having two separate processes? If so could you give me any pointers on how?

I can handle calling the Python processing module from Java using ProcessBuilder but I'm unsure on how to have embedded Jetty and separate processing service under a singe Java app at the same time.

Dusted
  • 123
  • 2
  • 10
  • To be honest, it's probably better for maintainability to keep them separate. The current buzzword is "microservices", and while they're not a panacea, this seems like the sort of scenario where you have two logically distinct components that there's no particular reason to fix. That said, if the only purpose of the database is as a rendezvous between the two, something like a message queue might make more sense. – chrylis -cautiouslyoptimistic- Oct 28 '15 at 08:15
  • So, all you want is the ability to kick off the Python side from Java? You are not asking about doing the "backend" processing entirely in Java (Having no Python piece at all), right? – Joakim Erdfelt Oct 28 '15 at 13:21
  • Yes - I can kick off Python processes from Java but am unsure how to combine this effectively with the embedded Jetty server I'm running - if that is the best way to go. @chrylis - like the msg queue idea, I'll look into it. – Dusted Oct 28 '15 at 19:14
  • Jython could be an answer for you if your goal is single process. See http://stackoverflow.com/questions/8898765/calling-python-in-java. Jython and CPython are different things tough and there are limitations with Jython. See https://www.safaribooksonline.com/library/view/jython-essentials/9781449397364/apd.html for details. – JJF Oct 30 '15 at 13:26

0 Answers0