Class BaseInboundFixLenProcessor
java.lang.Object
com.onenetwork.platform.integ.fixlen.BaseInboundFixLenProcessor
- All Implemented Interfaces:
InboundProcessor
public abstract class BaseInboundFixLenProcessor extends java.lang.Object implements InboundProcessor
Implement this class to process an inbound fixed-length format file.
Methods which must be implemented are:
- (Required)
#processFixLenRows(FixLenRow, PlatformUserContext)
- to process the inbound FixedLength file and generate a ModelList - (Required)
#setPrimaryRefTransNo(fileRow,context)
- to set the primaryRefTransNo for the fixLenRow
-
Field Summary
Fields Modifier and Type Field Description protected boolean
allowParseWithErrorRecords
protected boolean
defaultMessageDetailEnabled
protected java.lang.String
metadataFileName
protected java.lang.String
moduleOrEptPrefix
-
Constructor Summary
Constructors Constructor Description BaseInboundFixLenProcessor(java.lang.String moduleOrEptPrefix, java.lang.String metadataFileName)
This constructor is used to set moduleOrEptPrefix and metadataFileName fields which are used for loading the XML rule file.BaseInboundFixLenProcessor(java.lang.String moduleOrEptPrefix, java.lang.String metadataFileName, boolean allowParseWithErrorRecords, boolean defaultMessageDetailEnabled)
This constructor is used to set moduleOrEptPrefix and metadataFileName fields which are used for loading the XML rule file, as well as the field allowParseWithErrorRecords and defaultMessageDetailEnabled. -
Method Summary
Modifier and Type Method Description MessageDetail
createMessageDetailEntry(java.lang.String recordIdentifier, java.lang.String error, java.lang.String primaryRefTransNo, java.lang.String modelType, java.lang.String rawData, Message message, java.util.List<MessageDetail> messageDetails, PlatformUserContext context)
This method creates a messageDetail JAXB for the parameters passed.void
handleResults(TaskResult taskResult, Message message, PlatformUserContext context)
After processing, handles success and error cases, typically by enqueueing a response message.TaskResult
process(Message message, GridTaskContext gridTaskContext, PlatformUserContext context)
Callback from the message queue framework to process an inbound message.abstract ModelList
processFixLenRows(java.util.List<FixLenRow> fixLenRows, Message message, PlatformUserContext context)
Your implementation should convert the given Listto models, write them (e.g. abstract java.lang.String
setPrimaryRefTransNo(FixLenRow fileRow, PlatformUserContext context)
This method must be overridden by subclass processor to provide the implementation for setting the primary transaction reference number.protected ModelList
writeModelList(ModelList modelList, PlatformUserContext userContext)
Provided as a convenience, as the best practice is for your implementation of#processFixLenRows(fixLenRows)
to use this method internally.
-
Field Details
-
moduleOrEptPrefix
protected java.lang.String moduleOrEptPrefix -
metadataFileName
protected java.lang.String metadataFileName -
allowParseWithErrorRecords
protected boolean allowParseWithErrorRecords -
defaultMessageDetailEnabled
protected boolean defaultMessageDetailEnabled
-
-
Constructor Details
-
BaseInboundFixLenProcessor
public BaseInboundFixLenProcessor(java.lang.String moduleOrEptPrefix, java.lang.String metadataFileName)This constructor is used to set moduleOrEptPrefix and metadataFileName fields which are used for loading the XML rule file.- When overriding from a module: If we need to use a metadata file called Order.xml within PlatformTestModule, place the file within the "com.onenetwork.platformtestmodule.integ.fixlen.rules" package and call this constructor from the implementing processor's constructor as super("PTA","Order.xml");
- When overriding from an EPT: Pass the EPT name for moduleOrEptName. For example, if you have an ept named "MyEnt" then place the XML rule file in package "com.onenetwork.myent.integ.fixlen.rules" and call this constructor from the implementing processor's constructor as - super("EPT.MyEnt","Order.xml"); to get the FixLenDef object from the XML rule file within the ept "EPT.MyEnt"
- Parameters:
moduleOrEptPrefix
- module prefix (e.g. ZBKS or EPT.MyEnt)metadataFileName
- this xml file should be in the "integ.fixlen.rules" subpackage of your module or EPT's base java package
-
BaseInboundFixLenProcessor
public BaseInboundFixLenProcessor(java.lang.String moduleOrEptPrefix, java.lang.String metadataFileName, boolean allowParseWithErrorRecords, boolean defaultMessageDetailEnabled)This constructor is used to set moduleOrEptPrefix and metadataFileName fields which are used for loading the XML rule file, as well as the field allowParseWithErrorRecords and defaultMessageDetailEnabled.- The field allowParseWithErrorRecords is by default set as true which means that if some rows have parsing errors, other rows are processed and parsing errors for the error rows are captured in the messageDetail. If allowParseWithErrorRecords value is set to false, then if any one row has parsing error, other rows are also not parsed and processed. The error will be thrown by the Processor.
- The field defaultMessageDetailEnabled is by default set as false which means that messageDetail implementation is to be done by the implementing Processor for the FixLenRow processing. This base processor doesn't provide any implementation for messageDetail for processing FixLenRows in this case. If defaultMessageDetailEnabled value is set to true, then this base processor will be providing a default message detail implementation for processing. If there are any errors thrown from the implementing processor/modelLists, then the base processor sets error message for all the FixLenRows as the returned error message in messageDetail. This is because the base processor does not have any way to determine the error/success case for each FixLenRow. In case there are no error thrown by implementing processor or if modelList has no errors, then messageDetail entries are created for all the FixLenRows without any errors (success)
- Any parsing errors that occurs are still stored in MessageDetail if allowParseWithErrorRecords flag is set to true.
- Parameters:
moduleOrEptPrefix
- module prefix (e.g. ZBKS or EPT.MyEnt)metadataFileName
- this xml file should be in the "integ.fixlen.rules" subpackage of your module or EPT's base java packageallowParseWithErrorRecords
- boolean flag to determine if parsing should continue for other rows if some rows have errors.defaultMessageDetailEnabled
- boolean flag which determines if messageDetail implementation for processing rows will be done by the base processor, or the implementing processor.
-
-
Method Details
-
process
public TaskResult process(Message message, GridTaskContext gridTaskContext, PlatformUserContext context) throws java.lang.ExceptionDescription copied from interface:InboundProcessor
Callback from the message queue framework to process an inbound message.- Specified by:
process
in interfaceInboundProcessor
- Parameters:
message
- Message which needs to be processedgridTaskContext
- GridTaskContext provides information about the grid task associated with the messagecontext
- 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
-
processFixLenRows
public abstract ModelList processFixLenRows(java.util.List<FixLenRow> fixLenRows, Message message, PlatformUserContext context) throws java.lang.ExceptionYour implementation should convert the given Listto models, write them (e.g. using #writeModelList(ModelList)
, and return back the error response as another ModelList.- Parameters:
fixLenRows
- Listto be processed message
- Messagecontext
- PlatformUserContext- Returns:
- ModelList errors
- Throws:
java.lang.Exception
-
setPrimaryRefTransNo
public abstract java.lang.String setPrimaryRefTransNo(FixLenRow fileRow, PlatformUserContext context)This method must be overridden by subclass processor to provide the implementation for setting the primary transaction reference number. This facilitates searching of FixLenRows by transaction reference numbers from the Message detail report page.- Parameters:
fileRow
- FixLenRowcontext
- PlatformUserContext
-
writeModelList
protected ModelList writeModelList(ModelList modelList, PlatformUserContext userContext) throws java.lang.ExceptionProvided as a convenience, as the best practice is for your implementation of#processFixLenRows(fixLenRows)
to use this method internally.- Parameters:
ModelList
- models to write- Returns:
- ModelList response, including any errors
- Throws:
java.lang.Exception
-
createMessageDetailEntry
public MessageDetail createMessageDetailEntry(java.lang.String recordIdentifier, java.lang.String error, java.lang.String primaryRefTransNo, java.lang.String modelType, java.lang.String rawData, Message message, java.util.List<MessageDetail> messageDetails, PlatformUserContext context) throws java.lang.ExceptionThis method creates a messageDetail JAXB for the parameters passed. This can be overrriden by the implementing processor if needed- Parameters:
recordIdentifier
- RecordIdentifier for MessageDetailerror
- ErrorMessage if presentprimaryRefTransNo
- primaryIdentificationNumber for MessageDetailmodelType
- modelTyperawData
- rawData for the recordmessage
- inputMessagemessageDetails
- Listcontext
- userContext- Returns:
- MessageDetail
- Throws:
java.lang.Exception
-
handleResults
public void handleResults(TaskResult taskResult, Message message, PlatformUserContext context) throws java.lang.ExceptionDescription 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 interfaceInboundProcessor
- Parameters:
taskResult
- TaskResult task result fromInboundProcessor.process(Message, GridTaskContext, PlatformUserContext)
message
- Processed Messagecontext
- value chain admin context for the queue's parent value chain- Throws:
java.lang.Exception
-