The foundation for re-usable Connector functionality.
An outbound Connector implements OutboundConnectorFunction#execute(OutboundConnectorContext)
to define the connector logic.
@OutboundConnector(
name = "PING",
inputVariables = {"caller"},
type = "io.camunda.example.PingConnector:1"
)
public class PingConnector implements OutboundConnectorFunction {
@Override
public Object execute(OutboundConnectorContext context) throws Exception {
var request = context.bindVariables(PingRequest.class);
var caller = request.getCaller();
return new PingResponse("Pong to " + caller);
}
}
An inbound Connector implements InboundConnectorExecutable#activate(InboundConnectorContext)
and InboundConnectorExecutable#deactivate()
to define the connector logic.
@InboundConnector(
name = "SUBSCRIPTION",
type = "io.camunda.example.SubscriptionConnector:1"
)
public class SubscriptionConnector implements InboundConnectorExecutable {
private MockSubscription subscription; // imitates some real-world subscription
@Override
public void activate(InboundConnectorContext context) throws Exception {
var properties = context.bindProperties(SubscriptionProperties.class);
// subscribe to events
subscription = new MockSubscription(properties.getTopic());
subscription.subscribe(event -> {
var result = context.correlateWithResult(event);
// handleResult(result);
});
}
@Override
public void deactivate() throws Exception {
// unsubscribe from events
subscription.shutdown();
}
}
Connectors expose themselves as a OutboundConnectorFunction
or InboundConnectorExecutable
SPI implementations.
Connector runtimes like Spring Zeebe wrap the function to execute it in various environments.
mvn clean package