Pass custom header to service task

Greetings,

We are using Camunda community version 7.12 and are facing a certain challenge with custom headers.

We have a micro service (say M1) making a POST request to the Camunda REST end point to execute a certain WF (say WF1).

When M1 makes the call, it needs to pass a custom header (say H1) as part of the payload. The expectation is that H1 should show up in each of the connector tasks defined within WF1.

Is there a way to introduce a change in the Camunda engine so that the custom header can trickle down to downstream service tasks seamlessly, without having to modify each task?

Thanks in advance for you valuable time and attention.

Best.

Hi @thegeekcentaur,

you can add custom headers: https://docs.camunda.org/manual/7.12/reference/connect/http-connector/#using-the-generic-api and this example: https://github.com/camunda/camunda-bpm-examples/blob/master/servicetask/soap-service/src/main/resources/invokeSoapService.bpmn#L21-L25

But, if you want more control during your service invokation, you should use the external task pattern or a java delegate and program the request with full support of your favorite client framework.

Hope this helps, Ingo

Hi @Ingo_Richtsmeier,

Thanks for your kind response. I have already seen these examples, and my only concern/observation to that was it involves making changes to the WF definitions/BPMNs.

If we are looking at a more controlled implementation, I guess the right way is go external task.

I was also hoping that Java Delegates provides something similar too, but reading https://docs.camunda.org/manual/7.8/user-guide/process-engine/delegation-code/ I feel that this also involves dabbling with the existing WF definitions.

Please advise.
Best.

Hi @thegeekcentaur,

if you want to change the functionality of the connector without changing the process models you could exchange the connector implementation with a custom one: https://docs.camunda.org/manual/7.12/reference/connect/extending-connect/#custom-connector

I’ve never done this and can’t foresee the pitfalls on this path.

On the long term you will gain more flexibility by moving from connector to external service implementation.

The required changes in the process models can be generated with the help of the model api, if you have a lot of process models to maintain. (https://docs.camunda.org/manual/7.12/user-guide/model-api/bpmn-model-api/)

Hope this helps, Ingo

Thanks again @Ingo_Richtsmeier

One last question. Is there a place where I can see a sample project for custom connector, to get started?

Regards.

Hi @thegeekcentaur,

I could not find a working example either.

But this is the original code: https://github.com/camunda/camunda-connect and it conatins a DummyConnector in the test package: https://github.com/camunda/camunda-connect/tree/master/core/src/test/java/org/camunda/connect/dummy

Maybe this can serve as an example?

Hope this helps, Ingo

1 Like

It does. Appreciate all your help. Danke schoen.