I am building a custom processor that publishes a message to an internal system. I am getting an error that the "transfer relationship is not specified", and I haven't been able to figure out why. As far as I can see I am following what I have seen online and in other processors. Here is the code:
public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
FlowFile flowFile = session.get();
if ( flowFile == null ) {
return;
}
final AtomicReference<String> contentsRef = new AtomicReference<>(null);
session.read(flowFile, (inputStream) -> {
final String content = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
contentsRef.set(content);
});
try {
final ValidatedEventStoreProducer producer = initializeProducer(context, session, flowFile);
producer.publishEvent(contentsRef.get(), Topics.IQ_EVENT_GENERAL, TenantId.fromValidated(flowFile.getAttribute("tenantid")));
} catch (Exception exception) {
session.transfer(flowFile, REL_FAILURE);
return;
}
session.transfer(flowFile, REL_SUCCESS);
}
None of the operations return an updated flowFile so it is the right one I am sending. To test that I tried the following code:
public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
FlowFile flowFile = session.get();
if ( flowFile == null ) {
return;
}
session.transfer(flowFile, REL_SUCCESS);
}
and even:
public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
FlowFile flowFile = session.get();
if ( flowFile == null ) {
return;
}
session.remove(flowFile);
}
I still get " transfer relationship not specified".
I have my relationship set up like this:
public static final Relationship REL_SUCCESS = new Relationship.Builder()
.name("success")
.description("Files that are successfully send will be transferred to success")
.build();
public static final Relationship REL_FAILURE = new Relationship.Builder()
.name("failure")
.description("Files that fail to send will transferred to failure")
.build();
These are added to the relationships Set.
If anyone could give me some advice and/or let me know where I'm going wrong I would really appreciate that! Thanks!