Custom Output Adapters
An output adapter delivers target items from Data Hub to a target system. It implements the AdapterService interface, and uses the publish method to collect all relevant target items, then pushes them into the target system.
If your source system is not SAP Commerce Cloud, and not one of the SAP systems supported by out-of-the-box solutions, you need a custom output adapter. Before beginning on your custom output adapter, certain prerequisites must be in place. The following prerequisites assume that you are performing an end-to-end flow of data through Data Hub.
- Raw, Canonical, and Target data models are defined
- A raw data feed exists to generate canonical items for export
- You understand the target system interface, and it can be accessed from a deployed Data Hub instance (for example REST API, SQL connection)
Your custom adapter must be part of your extension. Your extension includes the data models, defined in extension.xml files, and any custom handlers. By including the adapter in your extension, you ensue it resides in the /opt/datahub/extension-dir/ folder, and keep all components of your integration together.
An implementation of a custom adapter for your unique target system must minimally cover the following:
- Provide a custom implementation of the com.hybris.datahub.adapter.AdapterService. This implementation includes calls to the getTargetSystemType and publish methods. This topic is covered in Custom Output Adapter Basics.
- Provide a method for connection to the target system. The method includes decryption of the target system password, which is encrypted by default in the Data Hub database. You may optionally also provide an implementation of the isTargetSystemAvailable method. Using this method allows you to gracefully handle situations where the target system in unreachable, and avoid unnecessary processing of data if the system is down. Password decryption and target system availability checking are covered in Connecting to the Target System.
- Once connected, you use the publish method to trigger publication, and to handle both INSERT, and DELETE actions. See Using the Publish Method.
- Once publication is under way, you then retrieve and process each target item. The TargetItem class provides helper methods that allow for the lookup of dynamic exportCodes during the publication phase. See Retrieving and Processing Target Items.
- Ensure that you handle any errors during publication, so that item and publication statuses can be reported. This topic is covered in Error Handling.
- Finally, use the completePublication method to report the publication result, including errors, back to Data Hub. For details, see Publication Completion.
By implementing these basic components, you build a robust, custom output adapter. Proceed to the following topics for more details of each output adapter component.