Hi everyone,
In our project, we need to create one IB in our module, set some derive fields and then programmatically we need to process data from another IB
we need to send it to another interface from other module in such a way that it gets processed by its existing workflow, processor, and validation logic, as if it were received via a peer or external system.
We’re currently writing processor in our module and using QueueResourceClient.enqueueMessage() and setting interface, interfaceVersion, valueChainId, and other metadata manually.
Question: Is this the recommended approach for triggering one IB from another? Or is there a more native framework-supported utility/helper method (like a built-in service or helper class) that handles this kind of IB-to-IB message handoff more gracefully?
Would love to hear how others have done this or if there's something we might be missing.
Thanks in advance!
@javamk - The other option is to use In-Container P2PI Routing. Documentation links at the bottom. Basically you could have your first IB processor generate a new CSV file with the derived fields set, then enqueue this file as outbound to pass to the second IB. Typically P2PI sets a Platform Instance to send the file to, however, In-Container P2PI Routing allows you to set the destinationQueue and destinationInterface without the destinationPlatformInstance, keeping the file within the same instance.
https://docs.onenetwork.com/NeoHelp/devnet/In-Container_P2PI_Routing.html
https://docs.onenetwork.com/NeoHelp/devnet/Transactional_In-container_P2PI_Routing.html
@jcourter First of all, thank you for your earlier explanation I'm working on a scenario where a custom IB (HCPT.MyCustomProcessor) processes a payload and then internally calls a standard IB (PLT.EntRoleType_IB) using enqueueMessage().
In the processor, I'm transforming the data and enqueuing the message to PLT.EntRoleType_IB like this:
enqueueMessage(
payload.toString(),
"PLT.EntRoleType_IB", // IB name
"1.0", // Version
"UploadInboundInterfaceCsvFiles", // Queue name
context
);
return TaskResult.SUCCEED;
here is the enqueueMessage() method:
private void enqueueMessage(String payload, String inboundInterface, String interfaceVersion, String queueName, PlatformUserContext context) throws CsvTransformException {
try {
MessageQueueService messageQueueService = Services.get(MessageQueueService.class);
QueueRefImpl queueRef = new QueueRefImpl();
queueRef.setName(queueName);
queueRef.setVcID(context.getValueChainId());
queueRef.setEnterpriseName(context.getRoleEnterpriseName());
Message msg = messageQueueService.newMessage();
msg.setOwningQueueRef(queueRef);
msg.setInboundInterface(inboundInterface);
msg.setInboundInterfaceVersion(interfaceVersion);
msg.setInboundQueueRef(queueRef);
msg.setSender("ONE");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
msg.setClientFileName("PLT_EntRoleType_IB_v1.0.csv_" + sdf.format(Calendar.getInstance().getTime()));
InputStream inputStream = new ByteArrayInputStream(payload.getBytes(Charset.forName("UTF-8")));
StreamUtil.transfer(inputStream, msg.writePayload(), true);
messageQueueService.enqueue(msg, context);
} catch (Exception e) {
throw new CsvTransformException("Error while enqueueing EntRoleType_IB message: " + e.getMessage(), e);
}
}
This works fine unless PLT.EntRoleType_IB fails.
If PLT.EntRoleType_IB has an error, it logs the failure.
But my HCPT IB still shows as successful, even though the downstream IB failed.
I want my HCPT IB to also fail when PLT fails, and show the same error message.
@javamk - Looking at your processor logic, you are returning TaskResult.SUCCEED no matter what happens when enqueuing the file for PLT.EntRoleType_IB. Instead of always returning TaskResult.SUCCEED, can you derive the return value based on the outcome of your PLT.EntRoleType_IB processing? If PLT.EntRoleType_IB fails or has an error, return the the error or mark as a failure for your HCPT IB.