Hi,
I am using a pre-built distribution of Camunda BPM 7.7.0 on Windows 10 and I am having trouble getting a ConnectorConfigurator for the HTTPConnector working.
The goal of my ConnectorConfigurator is to alter the headers for requests sent by the HTTPConnector so that the ‘Authorization’ attribute is controlled via server configuration. The ConnectorConfigurator registers a ConnectorRequestInterceptor which, on invocation, modifies the headers of the request but I am unable to get the ConnectorConfigurator to be detected/registered with the Camunda Engine. Nothing appears in the logs about the loading of the ConnectorConfigurator and the authentication header is not set.
I believe that the part that is causing the issue is this part in the documentation:
Add the configurator’s fully qualified classname to a file named
‘META-INF/services/org.camunda.connect.spi.ConnectorConfigurator’
There are multiple META-INF folders located in the pre-built distribution but I imagine it belongs in the camunda webapp folder: camunda-bpm-tomcat-7.7.0\server\apache-tomcat-8.0.24\webapps\camunda
This directory contains two META-INF folders: \META-INF\services
and \WEB-INF\classes\META-INF\services
I have created org.camunda.connect.spi.ConnectorConfigurator
in both META-INF
containing the following line: org.awesome.camunda.ConnectorConfiguration.HttpConnectorConfigurator
I am building the jar file using IntelliJ IDEA and in the Kotlin language. I have a working Camunda engine plugin written in Kotlin which works wonders to perform REST webservice calls using Retrofit upon certain tasks being started so i am ruling out Kotlin as being an issue. The jar file is being deployed to: camunda-bpm-tomcat-7.7.0\server\apache-tomcat-8.0.24\lib
If anyone could provide any assistance or examples of a working ConnectorConfigurator using a pre-built re-built distribution of Camunda BPM 7.7.0 that would be fantastic. There doesn’t appear to be any similar issues in the forums or the old google groups section.
Code:
package org.awesome.camunda.ConnectorConfiguration
import org.camunda.connect.httpclient.HttpConnector
import org.camunda.connect.httpclient.impl.AbstractHttpRequest
import org.camunda.connect.httpclient.impl.HttpRequestImpl
import org.camunda.connect.httpclient.impl.HttpRequestInvocation
import org.camunda.connect.spi.ConnectorConfigurator
import org.camunda.connect.spi.ConnectorInvocation
import org.camunda.connect.spi.ConnectorRequestInterceptor
import java.util.logging.Logger
class HttpConnectorConfigurator : ConnectorConfigurator<HttpConnector>
{
private final var LOGGER: Logger = Logger.getLogger(this.javaClass.name);
override fun configure(httpConnector: HttpConnector) {
LOGGER.info("HttpConnectorConfigurator - configure");
httpConnector.addRequestInterceptor(HttpConnectorRequestInterceptor());
}
override fun getConnectorClass(): Class<HttpConnector> {
LOGGER.info("HttpConnectorConfigurator - getConnectorClass");
return HttpConnector::class.java
}
}
class HttpConnectorRequestInterceptor : ConnectorRequestInterceptor
{
private final var LOGGER: Logger = Logger.getLogger(this.javaClass.name);
override fun handleInvocation(connectorInvocation: ConnectorInvocation): Any {
LOGGER.info("HttpConnectorRequestInterceptor - handleInvocation");
if(connectorInvocation is HttpRequestInvocation)
{
val request = connectorInvocation.target;
if(request is HttpRequestBase)
{
request.addHeader("Authorization", "test");
}
}
return connectorInvocation.proceed()
}
}