Class AbstractInboundProcessor

java.lang.Object
com.onenetwork.platform.integ.msg.AbstractInboundProcessor
All Implemented Interfaces:
InboundProcessor

public abstract class AbstractInboundProcessor
extends java.lang.Object
implements InboundProcessor
Simplified base class for implementing InboundProcessor. You should implement only processMessage(Message, GridTaskContext, File, PlatformUserContext) to create your processor.
  • Constructor Details

  • Method Details

    • processMessage

      public abstract void processMessage​(Message msg, GridTaskContext gridCtx, java.io.File fileForErrors, PlatformUserContext ctx) throws java.lang.Exception
      Implement this method to process your Message. You should read the content of the Message via Message.readPayload(), and denote any errors in the File denoted by fileForErrors. A suitable success or error Message will be enqueued to an "outbox" based on whether you recorded anything in fileForErrors or not.
      Parameters:
      msg - Message to be processed
      gridCtx - context of the GridTask which caused
      fileForErrors - if there are any processing errors, capture them in this file
      ctx - processing context
      Throws:
      java.lang.Exception
    • process

      public TaskResult process​(Message msg, GridTaskContext gridCtx, PlatformUserContext ctx) throws java.lang.Exception
      Description copied from interface: InboundProcessor
      Callback from the message queue framework to process an inbound message.
      Specified by:
      process in interface InboundProcessor
      Parameters:
      msg - Message which needs to be processed
      gridCtx - GridTaskContext provides information about the grid task associated with the message
      ctx - value chain admin context for the queue's parent value chain
      Returns:
      TaskResult indicates whether processing succeeded or failed, and whether to retry
      Throws:
      java.lang.Exception
    • getErrorsFile

      public static java.io.File getErrorsFile​(Message msg)
      Deprecated.
      Use getErrorsResource(Message) to get error storage resource which is independent of storage repository
      Returns the path used to store an error file for this processor for the given Message
    • getErrorsResource

      public static SharedStorageServiceResource getErrorsResource​(Message msg)
    • handleResults

      public void handleResults​(TaskResult result, Message msg, PlatformUserContext ctx) throws java.lang.Exception
      Description copied from interface: InboundProcessor
      After processing, handles success and error cases, typically by enqueueing a response message.

      The general contract for Platform's supported processors is:
      If TaskResult is SUCCEED and there are no upload errors, empty success message will be enqueued to success queue If TaskResult is SUCCEED or FAILD and there are upload errors (.results file is not empty), error message will be enqueued to error queue with payloadRef pointing to error file For scenarios where extra handling is required on errors before enqueueing, override this method in the implementation class

      Specified by:
      handleResults in interface InboundProcessor
      Parameters:
      result - TaskResult task result from InboundProcessor.process(Message, GridTaskContext, PlatformUserContext)
      msg - Processed Message
      ctx - value chain admin context for the queue's parent value chain
      Throws:
      java.lang.Exception
    • createNeoNotification

      public static void createNeoNotification​(java.lang.String fileName, boolean hasErrors, PlatformUserContext userCtx)