15.2.2. Setting Up Remote Integration

You can set up integration with a remote Activiti engine, as described in the following steps.

  1. Download and install OpenIDM, as described in the Installation Guide.

  2. Download and unzip the Activiti zip file (activiti-5.10.zip) from Activiti Downloads page.

  3. Edit the Activiti configuration file to avoid a port conflict with OpenIDM. OpenIDM runs on port 8080 by default. Edit the file so that Activiti Explorer runs on port 9090 (by replacing each instance of 8080 with 9090). The following example uses sed on a UNIX system to replace all instances of 8080 with 9090.

    $ cd /path/to/activiti/setup/
    $ sed -i.bak 's/8080/9090/g' build.xml
        
    [Note] Note

    There is currently a bug in the Activiti demo which might mean that all port replacements are not made. If you cannot access Activiti Explorer (in the next step) after making this change, also edit the following file to find and replace each instance of 8080 with 9090: /path/to/activiti/apps/apache-tomcat-6.0.32/conf/server.xml.

  4. Set up the default Activiti demo.

    $ cd /path/to/activiti/setup/
    $ ant demo.start
        
  5. In a browser, check that Activiti Explorer is running (on localhost:9090/activiti-explorer). Log in with the default userid kermit and password kermit. If all is well, log out.

  6. Configure Tomcat to operate with OpenIDM.

    1. Stop Tomcat.

      $ cd /path/to/activiti/setup/
      $ ant tomcat.stop 
            
    2. Copy the OpenIDM remote workflow WAR file to the Tomcat webapps folder.

      $ cd /path/to/openidm/bin/workflow
      $ cp openidm-workflow-remote-.war \
       /path/to/activiti/apps/apache-tomcat-6.0.32/webapps/
            
    3. Copy the OpenIDM workflow Activiti demo jar file to the Tomcat Activiti Explorer library.

      $ cd /path/to/openidm/bin/workflow/
      $ cp openidm-workflow-activiti--jar-with-dependencies.jar \
       /path/to/activiti/apps/apache-tomcat-6.0.32/webapps/activiti-explorer/WEB-INF/lib/
            
    4. Edit the Activiti Explorer configuration file to be able to use the OpenIDM extensions.

      $ cd /path/to/activiti/
      $ vi apps/apache-tomcat-6.0.32/webapps/activiti-explorer/WEB-INF/applicationContext.xml
            

      Replace the processEngineConfiguration with the OpenIDM extended configuration. So remove this section:

             <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
              <property name="dataSource" ref="dataSource" />
              <property name="transactionManager" ref="transactionManager" />
              <property name="databaseSchemaUpdate" value="true" />
              <property name="jobExecutorActivate" value="true" />
              <property name="customFormTypes">
               <list>
                <ref bean="userFormType"/>
               </list>
              </property>
             </bean>
            

      and replace it with this section:

            <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
             <property name="dataSource" ref="dataSource" />
             <property name="transactionManager" ref="transactionManager" />
             <property name="databaseSchemaUpdate" value="true" />
             <property name="jobExecutorActivate" value="true" />
             <property name="customFormTypes">
               <list>
                <ref bean="userFormType"/>
               </list>
              </property>
            <property name="customSessionFactories">
              <list>
                <bean class="org.forgerock.openidm.workflow.activiti.impl.session.OpenIDMSessionFactory">
                  <property name="url" value="http://localhost:8080/openidm/"/>
                  <property name="user" value="openidm-admin"/>
                  <property name="password" value="openidm-admin"/>
                </bean>
              </list>
            </property>
            <property name="resolverFactories">
              <list>
                <bean class="org.forgerock.openidm.workflow.activiti.impl.OpenIDMResolverFactory"></bean>
                <bean class="org.activiti.engine.impl.scripting.VariableScopeResolverFactory"></bean>
                <bean class="org.activiti.engine.impl.scripting.BeansResolverFactory"></bean>
              </list>
            </property>
            <property name="expressionManager">
              <bean class="org.forgerock.openidm.workflow.activiti.impl.OpenIDMExpressionManager"> </bean>
            </property>
           </bean>
            
    5. Restart Tomcat.

      $ cd /path/to/activiti/setup/
      $ ant tomcat.start 
           
    6. Check that Activiti Explorer is running on localhost:9090/activiti-explorer, as you did in the previous section.

  7. Configure OpenIDM to use the remote Activiti engine instead of the local, bundled Activiti engine.

    1. Copy the workflow.json configuration file to the OpenIDM configuration directory.

      $ cd /path/to/openidm/
      $ cp samples/misc/workflow.json conf/
            
    2. Edit the workflow configuration file to specify the remote Activiti engine.

      $ vi conf/workflow.json
            

      Ensure that the url, username, and password fields contain the values that correspond to your remote Activiti engine.

      {
         "enabled" : true,
         "location" : "remote",
         "engine" : {
             "url" : "http://localhost:9090/openidm-workflow-remote-2.1.0/",
             "username" : "youractivitiuser",
             "password" : "youractivitipassword"
         }
      }
            
  8. Start up OpenIDM.

    $ cd /path/to/openidm/
    $ ./startup.sh
       
  9. Test the integration by sending the following CURL request to list the available workflows:

    $ curl
     --header "X-OpenIDM-Username: openidm-admin"
     --header "X-OpenIDM-Password: openidm-admin"
     --request GET 
     "http://localhost:8080/openidm/workflow/processdefinition?_queryId=query-all-ids"
        
  10. Log in to the Activiti Explorer of the remote Activiti engine (with the default username (kermit) and password (kermit).

  11. Install the sample workflow (example.bpmn20.xml).

    1. In Activiti Explorer, click Manage.

    2. From the Deployments menu, select Upload New.

    3. Navigate to the sample workflow (/path/to/openidm/samples /misc/example.bpmn20.xml)

  12. Verify the integration by sending the following CURL request:

    $ curl
     --header "X-OpenIDM-Username: openidm-admin"
     --header "X-OpenIDM-Password: openidm-admin"
     --request POST
     "http://localhost:8080/openidm/workflow/processinstance?_action=createProcessInstance"
     --data '{"_key":"osgiProcess"}'
        

    The request should return a process ID, similar to the following:

    {
      "_id":"614",
      "processInstanceId":"614",
      "status":"ended",
      "businessKey":null,
      "processDefinitionId":"osgiProcess:7:603"
    }
        

    This request starts the osgiProcess and writes the list of installed workflows to the Tomcat server log file (/path/to/activiti/apps/ apache-tomcat-6.0.32/logs/catalina.out).

  13. Test the integration with Activiti Explorer.

    1. Click Processes and select Osgi Process from the list of process definitions.

    2. Click Start Process.

    3. Check the output in the Tomcat server log file ( /path/to/activiti/apps/apache-tomcat-6.0.32/logs/catalina.out. The list of installed workflows is written to the log file.