Notifications
Clear all

How to set Event-Based IntegrationSubscriptions for Action.

2 Posts
2 Users
0 Reactions
1,937 Views
0
Topic starter

Iam trying to generate ProductionOrder_OB report through Event-Based IntegrationSubscriptions. I have added the SysIdOutboundInterfaceWriteRequest in order to generate the outbound data. here is my code below

 public void sendOutboundInterfaceWriteRequest(ActionBasedWorkflowContext<ProductionOrder> context) {

    for (ProductionOrder ProdOrder : context.getCurrent().getModels()) {
      ModelDataService modelDataService = Services.get(ModelDataService.class);
      ProductionOrder currentProductionOrder =
        modelDataService.readById(ProductionOrder.class, ProdOrder.getSysId(), context.getPlatformUserContext());

      OutboundMessageService outboundService = Services.get(OutboundMessageService.class);
      
      QueueRef queueRef =
        QueueRefImpl.create(context.getPlatformUserContext().getValueChainId(), null, "Outbox/EXPORT_PRODUCTION_ORDER");

      SysIdOutboundInterfaceWriteRequest sysIdOutboundInterfaceWriteRequest =
        new SysIdOutboundInterfaceWriteRequest(
          "MFG.ProductionOrder_OB",
          "2.0",
          queueRef,
          ListUtil.create(currentProductionOrder.getSysId()),
          null);
      try {
        outboundService.writeSysIdBasedOutbound(sysIdOutboundInterfaceWriteRequest, context.getPlatformUserContext());

      }

      catch (Exception e) {
        LOG.error("Failed to send Production Order", e);
      }
    }
  }

Here is my ProductionOrder_OB

prodOrder OB

I have also set up PLT.MessageRoute_IB.csv, PLT.MessageQue_IB.csv and pLT.MessageDestination_IB.csv. So here, Iam getting OB report even I disable subscription.

Greg Merrill 2021-06-10 23:11:43

It looks like you are explicitly enqueuing to a hardcoded queue. Instead, you should be letting the IntegrationSubscription model drive this. The module code should not even be present. Instead, you should create an IntegrationSubscription record which chooses which events to subscribe to and what queue to deliver to.

See https://docs.onenetwork.com/devnet/latest/platform-user-s-guide/integration/integration-subscriptions/creating-a-new-integration-subscription

bpoudel Topic starter 2021-06-11 21:38:41

Thank you Greg for the suggestion, and I delete the module code as well as hardcoded queue and then create an IntegrationSubscription record which chooses which events to subscribe. That solve my problem.