2

I just started using the Optaplanner as a way to do vehicle routing. However I would like to expose the optaplanner as a web service (preferably REST).

Now I've read on several blogs that it can be done with Apache Camel. However finding a decent example seems impossible.

Are there any known examples that I can look at or any tips on how to expose this?

Agilix
  • 182
  • 2
  • 12

1 Answers1

1

There are several ways to expose it as a REST service:

  • RESTEasy: Annotate your domain objects with JAXB annotations (to define the structure of the XML file send over HTTP). Then write a Java class with JAX-RS annotations (to define the available REST methods). RESTEasy has a good reference manual, it focusses on REST and it allows you to tailer to the REST interface exactly as your client would like it. Deploy to a servlet container (WildFly, Jetty, ...).
  • Camel: See camel-optaplanner documentation and then camel's documentation (or book) about REST specifically and deploying camel. Note that the camel-optaplanner module is relative young, but it's unit tested and works.
  • Other REST technologies in the Java ecosystem

Anyway, OptaPlanner doesn't care how you expose it as a REST service (so it doesn't hinder you either):

integration

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • Standard answer that I have seen before but it stil gets me nowhere. Any known working examples with camel or RESTeasy? – Agilix Apr 23 '14 at 08:36
  • 2
    Let's just follow that RESTEasy link to the [RESTEasy examples](https://github.com/resteasy/Resteasy/tree/3.0.7.Final/jaxrs/examples). Those RESTEasy examples show how to go from a REST service to javabeans. The OptaPlanner examples show how to solve a planning problem represented as javabeans. Putting them together isn't rocket science :) – Geoffrey De Smet Apr 24 '14 at 05:55
  • 1
    Thank you Geoffrey, Java isn't really my thing. That why I wanted the WS. Sorry if my last comment sounded harsh. – Agilix Apr 24 '14 at 06:42