HttpConnector custom configuration

Hi! My aim is to add certain headers to every http-request made by camunda. Currently I’m adding those headers manually at every task with http-connector of the process. The class I’ve implemented:

@Configuration
    public class HttpConnectorConfigurator implements ConnectorConfigurator<HttpConnector> {

private static final Logger LOGGER = Logger.getLogger(HttpConnectorConfigurator.class.getSimpleName());

public final static String HEADER_REQUESTER = "requester";

@Override
@Bean
public Class<HttpConnector> getConnectorClass() {
    return HttpConnector.class;
}

private List getHeaders() {
    return Arrays.asList(new BasicHeader(HttpHeaders.AUTHORIZATION, "token"));
}

@Override
@Bean
public void configure(HttpConnector c) {
    CloseableHttpClient client = HttpClients.custom()
            .setMaxConnPerRoute(10)
            .setMaxConnTotal(200)
            .setDefaultHeaders(getHeaders())
            .build();
    ((AbstractHttpConnector) c).setHttpClient(client);
}

}

With this class I keep getting the error:


APPLICATION FAILED TO START


Description:

Parameter 0 of method configure in hi1.configs.HttpConnectorConfigurator required a bean of type ‘org.camunda.connect.httpclient.HttpConnector’ that could not be found.

Action:

Consider defining a bean of type ‘org.camunda.connect.httpclient.HttpConnector’ in your configuration.

The app fails starting after calling method “getConnectorClass”.
What’s wrong and how it can be solved?

As a quick thought this might be related to how the http-connect is invoked. If you are using spring then its likely the spring context is not being invoked. You would need to write a custom java delegate and invoke it through the Delegate Expression implementation of the service task.

Yes, I’m using Spring framework. Following Camunda docs, I made

@Bean
public HttpConnector httpConnector() {
    return Connectors.getConnector("http-connector");
}

With this solution I’m not getting this error anymore. Now I’ve faced up with the problem that my HttpConnector configurations are not applied. In the docs is written:

To enable auto detection of your new configurator please add a file called org.camunda.bpm.connect.spi.ConnectorConfigurator to your resources/META-INF/services directory with class name as content. For more information see the extending Connect section.

How could I perform this instructions for the app based on Spring Framework(with it’s annotations, since META_INF is not commonly used in Spring anymore)?

Hi @Renata_Akhmetshakiro,

with the camunda-spring-boot-starter it’s enough to add the dependency of camunda-engine-plugin-connect to your pom.xml. https://docs.camunda.org/manual/7.10/user-guide/process-engine/connectors/#camunda-connect-core

The engine picks it up at starttime without further configuration.

Hope this helps, Ingo

@Ingo_Richtsmeier hi!

Thank you for reply. The solution you’ve suggested works fine and I’m currently using it. However, recently I’ve faced up with an issue that requires sending dynamically generated token in the header of every http-request from the Camunda Engine. In order to solve this issue I decided to reconfigure the http-connector as it’s explained in the docs and add desired data automatically. And now have those problems I’m explaining above.

The filename is wrong, it should be org.camunda.connect.spi.ConnectorConfigurator. I spent some hours for the wrong filename…