Writing a custom connector

Good time of the day, Community.

I’ve just started the path of learning Camunda, and have a question, for which I’m struggling to find any actual information - the Connectors!

I’m running the basic embedded Camunda as part of Spring Boot app. My current goal is to write a custom Connector by a simple “extend” from the http-connector.

I believe I got the right set of dependencies,

        <dependency>
            <groupId>org.camunda.connect</groupId>
            <artifactId>camunda-connect-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.camunda.bpm</groupId>
            <artifactId>camunda-engine-plugin-spin</artifactId>
        </dependency>

        <dependency>
            <groupId>org.camunda.spin</groupId>
            <artifactId>camunda-spin-dataformat-all</artifactId>
        </dependency>

        <dependency>
            <groupId>org.camunda.bpm</groupId>
            <artifactId>camunda-engine-plugin-connect</artifactId>
        </dependency>

        <dependency>
            <groupId>org.camunda.connect</groupId>
            <artifactId>camunda-connect-connectors-all</artifactId>
        </dependency>

And I’m basically doing the

package com.example.workflow.connector.v2;

import org.camunda.connect.httpclient.HttpConnector;
import org.camunda.connect.httpclient.HttpConnectorProvider;
import org.camunda.connect.httpclient.impl.HttpConnectorProviderImpl;
import org.camunda.connect.spi.ConnectorProvider;

public class OmnissiahConnectorProvider extends HttpConnectorProviderImpl implements ConnectorProvider {

    @Override
    public String getConnectorId() {
        System.out.println("+++++++++++++++++++++++++++++++++++++++++++");
        return "omissiah-connector";
    }

    @Override
    public HttpConnector createConnectorInstance() {
        return new OmnissiahHttpConnector();
    }
}

At this stage I believe I’m passing the initial validation of the bpmn, but when it comes to action, I get an error, stating that no connector by the name “omnissiah-connector” exists.

Currently it’s a simple “extends”, but the idea is to have some predefined stuff (like URL) being kept on the side of the connector.

Would be grateful for some advice.

Hi @Draakzward and welcome to the community,

The embedded engine for Spring boot uses Spring as an injecion framework.
Have you tried adding the @Component annotation to your class? This way, Spring Boot will handle the injection.
Please let me know if this works.

Hi,

Thank you for your reply.

Sadly, it didn’t help.

package com.example.workflow.connector.v2;

import org.camunda.connect.httpclient.HttpConnector;
import org.camunda.connect.httpclient.HttpConnectorProvider;
import org.camunda.connect.httpclient.impl.HttpConnectorProviderImpl;
import org.camunda.connect.spi.ConnectorProvider;
import org.springframework.stereotype.Component;

@Component
public class OmnissiahConnectorProvider extends HttpConnectorProviderImpl implements ConnectorProvider {

Still get the

An error happened while submitting the task form : No connector found for connector id 'omnissiah-connector'

Maybe I’m missing something in the SpringBootApp class?

import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
//@EnableProcessApplication
public class Application {

  public static void main(String... args) {
    SpringApplication.run(Application.class, args);
  }

}

Hi,

Sorry, for sending you down the wrong way.
I tried it myself: You do not need the @Component annotation.
However, make sure that you follow all steps explained here.
Especially, add a file META-INF/services/org.camunda.connect.spi.ConnectorProvider that lists your custom connector. The content of my file looks like this:

io.camunda.forum.CustomConnectorProviderImpl

And the referenced CustomConnectorProviderImpl looks like this:

package io.camunda.forum;

import org.camunda.connect.httpclient.HttpConnector;
import org.camunda.connect.httpclient.impl.HttpConnectorImpl;
import org.camunda.connect.httpclient.impl.HttpConnectorProviderImpl;

public class CustomConnectorProviderImpl extends HttpConnectorProviderImpl {

  @Override
  public String getConnectorId() {
    return "custom-connector";
  }

  @Override
  public HttpConnector createConnectorInstance() {
    return new HttpConnectorImpl();
  }
}

I hope this helps.

1 Like

I did see this step, but was really hoping that since it’s a spring integration and etc. I wouldn’t be forced to do manual META-INF and everything related.

Thanks, will give it a try.

A step closer, but still something’s missing.

I did see the console “+++++++” printout, which I put into getConnectorId during Spring’s initialization. But still a ENGINE-REST-HTTP500 org.camunda.connect.ConnectorException: No connector found for connector id 'omnissiah-connector'.

Strangely enough I see:
2023-01-11 11:52:23.516 INFO 12574 --- [ main] org.camunda.bpm.connect : CNCT-01004 Discovered provider for connector id 'omissiah-connector' and class 'com.example.workflow.connector.v2.OmnissiahHttpConnector': 'com.example.workflow.connector.v2.OmnissiahConnectorProvider'

Making a new instance (or re-copying the connector name in hopes of a typo) helped.

Thank you for your help :slight_smile:

There is a typo:
Your implementation spells omissiah-connector your task is configured to search for omnissiah-connector (with an N)

1 Like

It wouldn’t be a fun day without having a typo and looking in a completely different direction :smile:

Thank you.

1 Like