Writing own custom rest api's using jersey

We have setup a camunda workflow engine as a microservice by adding camunda spring boot starters for rest/webapps etc.

We are facing slowness in camunda provided tasklist rest api to query for historic tasks based with filters(process variables).

So we decided to write a sql join query to fetch historic tasks with filters by writing own jersey rest endpoints.

How can we achieve that? Is that possible?

You can absolutely do that. To add custom jersey resources just add a Spring Configuration Bean like this:

@Component
@ApplicationPath("/somecustom/api")
public class SpringBootResourceConfig extends CamundaJerseyResourceConfig {
@Override
protected void registerAdditionalResources() {
        // add all custom resources here
	register(SomeCustomResource.class);
	}
}
1 Like

@egil thanks for your reply.

shall i register my new controller class(rest api) in the registerAdditionalResources() method?

I tried the approach you specified. its not working for me. Below is my code.

@Path(value = "/hello")
public class HelloController {
  @GET
  @Path(value = "/message")
  @Produces(MediaType.TEXT_PLAIN)
  public Response getProcessEngines(@HeaderParam("Authorization") String authorization) {        
    return Response.ok("welcome").build();
  }
}

@Component
@ApplicationPath("/custom")
@Slf4j
public class JerseyConfig extends CamundaJerseyResourceConfig {
  @Override
  protected void registerAdditionalResources() {    
    register(HelloController.class);
  }
}

I was getting 401 Unauthorized exception.

@egil its working now. fixed the issue.

1 Like

Good to hear. Cheers! :slight_smile:

Have a good one!

It throws: The resource configuration is not modifiable in this context. error