Reputation: 129
I am trying to create a custom REST API in Camunda. My Camunda application is standalone and I want to create a custom REST API to complete task and send response.
I created a separate REST Project to create an endpoint which an external application can call and complete a task and get response back.
When I run this project, I get the following error .
Field engine in com.camunda.custom.rest.endpoint.service.TaskCompletionService required a bean of type 'org.camunda.bpm.engine.ProcessEngine' that could not be found.
I have another project where I have Camunda standalone application and I want my custom REST endpoint to act on the task of the workflow defined under this project:
My REST endpoint should look like this :
http://localhost:8088/engine-rest/api/completeTask
My questions are :
Please let me know what am I doing wrong in my approach ? Or is there any better approach to create a custom rest endpoint in Camunda ?
This is how I am trying to trigger the API from postman.
Thanks
Upvotes: 0
Views: 1459
Reputation: 7583
A) The custom rest API needs to make use of the process engine. It can only do so if it is running in the same Spring context as the process engine. Currently you have two complete separate Spring Boot projects. You can fix this in different ways.
B) Camunda and Spring use different frameworks to expose REST services. Camunda uses a standard JAX-RS implementation, so it can also work without Spring. Spring uses its own implementation provided by Spring MVC (see Difference between JAX-RS and Spring Rest)
engine-rest is the context under which the process engine exposes its JAX-RS based REST api. You cannot mix Spring endpoints under the same context.
In this example I am using a Maven multi-module project and extending the Camunda JAX-RS REST api with a custom service https://github.com/rob2universe/camunda-custom-rest-endpoint/tree/main
However, if you are writing a custom Facade, you may not plan to expose the Camunda REST API to clients at all. IN that case it would be better to keep your custom services under a separate context, so you can only expose that context and not allow access to the Camunda REST API from outside.
Upvotes: 1