JBoss.orgCommunity Documentation

Chapter 15. Integration

15.1. Overview
15.2. Persistent storage
15.2.1. Database: JPA and Hibernate
15.2.2. XML: XStream
15.2.3. XML: JAXB
15.3. SOA and ESB
15.3.1. Camel and Karaf
15.4. Other environments
15.4.1. JBoss modules, WildFly and JBoss EAP
15.4.2. OSGi
15.4.3. Android
15.5. Integration with human planners (politics)

OptaPlanner's input and output data (the planning problem and the best solution) are plain old JavaBeans (POJO's), so integration with other Java technologies is straightforward. For example:

Camel is an enterprise integration framework which includes support for OptaPlanner (starting from Camel 2.13). It can expose OptaPlanner as a REST service, a SOAP service, a JMS service, ...

Read the documentation for the camel-optaplanner component. That component works in Karaf too.

To deploy an OptaPlanner web application on WildFly, simply include the optaplanner dependency jars in the war file's WEB-INF/lib directory (just like any other dependency) as shown in the optaplanner-webexamples-*.war. However, in this approach the war file can easily grow to several MB in size, which is fine for a one-time deployment, but too heavyweight for frequent redeployments (especially over a slow network connection).

The remedy is to use deliver the optaplanner jars in a JBoss module to WildFly and create a skinny war. Let's create an Optaplanner module called org.optaplanner:

Important

Because of WildFly's class loading, the method SolverFactory.createFromXmlResource() might not find the solver configuration and throw an IllegalArgumentException. Instead use:

        SolverFactory solverFactory = SolverFactory.createFromXmlInputStream(
                getClass().getClassLoader().getResourceAsStream(
                        "org/optaplanner/examples/nqueens/solver/nqueensSolverConfig.xml"));

A good OptaPlanner implementation beats any good human planner for non-trivial datasets. Many human planners fail to accept this, often because they feel threatened by an automated system.

But despite that, OptaPlanner can benefit from a human planner as supervisor:

Therefore, it's often a good idea to involve the human planner in your project.