I have created an outbound connector, I needed to autowire service class in the connector, I have removed META_INF.services, its working in my local runtime but its failing when I am using the docker runtime. The connector is not getting hit in docker.
@Component
@OutboundConnector(
name = "custom-email-connector",
inputVariables = {"emailTo", "templateId", "body"},
type = "email-connector")
@NoArgsConstructor(force = true)
public class NotificationConnector implements OutboundConnectorFunction {
private final EmailService emailService;
private final NotificationService notificationService;
public NotificationConnector(EmailService emailService, NotificationService notificationService) {
this.emailService = emailService;
this.notificationService = notificationService;
}
private static final Logger LOGGER = LoggerFactory.getLogger(NotificationConnector.class);
@Override
public Object execute(OutboundConnectorContext context) throws IOException, InterruptedException {
LOGGER.debug("variables {}",context.getJobContext().getVariables());
final var connectorRequest = context.bindVariables(MyConnectorRequest.class);
return executeConnector(connectorRequest);
}
private MyConnectorResult executeConnector(final MyConnectorRequest connectorRequest) throws IOException, InterruptedException {
LOGGER.info("Request received for sending notification with request {}", connectorRequest.toString());
String emailTo = connectorRequest.getEmailTo();
String templateId = connectorRequest.getTemplateId();
Map<String, Object> body = connectorRequest.getBody();
LOGGER.debug("emailTo: {}, templateId {}, body: {}", emailTo, templateId, body);
String responseContent = sendNotification(connectorRequest);
LOGGER.info("response content: {}", responseContent);
return new MyConnectorResult(responseContent);
}
private String contentRenderingServiceCall(MyConnectorRequest request) throws IOException, InterruptedException {
return this.notificationService.notify(request);
}
private String emailServiceCall(String emailId, String content) throws IOException, InterruptedException {
return this.emailService.send(new EmailRequest(emailId, content));
}
private String sendNotification(MyConnectorRequest request) throws IOException, InterruptedException {
String responseContent = contentRenderingServiceCall(request);
return emailServiceCall(request.getEmailTo(), responseContent);
}
}