Camunda 8.5 access Spring Boot application.properties

I have implemented a simple Camunda Connector:

@OutboundConnector(
name = “MYCONNECTOR”,
inputVariables = {
“entityName”},
type = “io.camunda:my-connector:1”)
public class MyConnectorFunction implements OutboundConnectorFunction {

@Value("${some.text.var}")
private String someTextVar;

@Override
public Object execute(OutboundConnectorContext context) {
    try {
        final var connectorRequest = context.bindVariables(MyConnectorRequest.class);
        return "Hello, World: " + someTextVar;
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw new RuntimeException(e);
    }
}

}

I created a JSON template for it, connected it to Camunda Modeler, built and deployed the JAR of this connector in Docker using docker-compose in the connectors image.

I also added an application.properties file to my connector project and defined a property there:

some.text.var=Some Test Var1

As you can see from the code above, I am trying to access this property, but it is always null. Is there any mechanism to access Spring properties from a connector, or some way to view the Spring context?

Hey @Alex3, your connector would need to be on your component scanning path where Spring looks for components. You could then for example inject Springs Environment bean.

Here is an example for a Spring Based Connector Test: connectors/connector-runtime/spring-boot-starter-camunda-connectors/src/test/java/io/camunda/connector/runtime/outbound/SpringBasedOutboundConnectorTest.java at aa994e1ef536054a7ef3a4feb50ae37a0006adf1 · camunda/connectors · GitHub

Hey @sbuettner , thanks for your answer.

I deploy my connector using Docker Compose as part of the connectors bundle. I added a volume like this:

connectors: # https://docs.camunda.io/docs/components/integration-framework/connectors/out-of-the-box-connectors/available-connectors-overview/
image: camunda/connectors-bundle:${CAMUNDA_CONNECTORS_VERSION}
container_name: connectors
ports:
- “8085:8080”
environment:
- ZEEBE_CLIENT_BROKER_GATEWAY-ADDRESS=zeebe:26500
- ZEEBE_CLIENT_SECURITY_PLAINTEXT=true
- ZEEBE_CLIENT_ID=${ZEEBE_CLIENT_ID}

volumes:

  - myconnector.jar:/opt/app/my-connector.jar

How can I activate my connector with this setup so that it becomes part of Spring and is included in ComponentScan?

We have not tried this but in theory you could provide an environment variable to the Connector Runtime that includes your package in the component scan if Spring allows that.