Skip to content
Eric Matelyan edited this page May 31, 2023 · 22 revisions

Vault Spark is a message queue system that allows developers to use the Vault Java SDK to send and receive messages from a durable queue. It can be used to allow for loosely coupled, asynchronous integration within a Vault, between different Vaults, or between Vault and an external system. This example focuses on using Spark Integration Rules to transform data from a source Vault's data model to a target Vault's data and describes an example use case along with sample code that you can use with your Vault to step through the code in the Vault Java SDK Debugger.

Introduction

The vsdk-spark-integration-rules-sample project covers the use of Spark Messaging to propagate messages from one Vault (source) to another Vault (target) using integration rules to map and transform values between the differing data models. The project will step through Vault setup as well as sample code for a message with integration rules and an HTTP Callback.

Setting up Vault to Vault components

You must set up the following components in Vault:

  • Vault Connection records
  • Vault Queues for the inbound and outbound Spark Messages
  • Integrations to organize an integration business process
  • Integration Points to organize full round-trip step in an integration
  • Vault MDL for the Integration Rules
  • Various Vault components for the sample project
  • Vault Reference Lookups

Sample Code

The sample code includes the following parts:

  • A User Action on the Warranties record in the source Vault which sends a message to a target Vault
  • A Spark Message Processor in the target Vault which:
    • Queries the source Vault for integration fields
    • Performs an HTTP Callout to query the source Vault for more information using the Vault API
    • Transforms the data using the integration rules
    • Creates or updates a Claims Warranties record in the target Vault
  • Integration Rules to map source Vault data for use in the target Vault
  • Helper methods for Vault to Vault integrations

You will need two sandbox Vaults for this project.

Business Use Case

Connected Data

A user needs to share data from a Warranty record in one source Vault to a Claims Warranty record in another target Vault. The user should start the data sharing manually by running the Send Warranty user action.

The user needs to be able to tell if a data share is successful from the source and target Vaults through the use of an Integration Status field.

Setup

There are seven main steps required to setup this project:

  1. Create and configure Connection records in the source and target Vaults
  2. Import the Vault Packages (VPKs) to create necessary components
  3. Create and configure the Spark Message Queues
  4. Create and configure Integrations
  5. Create and configure Integration Points
  6. Create and configure the Vault Reference Lookups
  7. Create and configure Integration Rules

The project contains two directories containing Vault packages (VPK) in the "deploy-vpk" directory with the necessary objects and Vault Java SDK code. One is for your source Vault - the Vault where you want to send messages from - and the second one is for your target Vault - the Vault where you want the messages to be delivered.

Create Connections

The Connection object is used to create records that define connections between different Vaults or between a Vault and an external system.

In this use case, we will create Vault to Vault records to link a source Vault to a target Vault.

First, in the source Vault:

  1. Log in and navigate to Admin > Connections and click Create.
  2. Choose the Vault to Vault connection type. Select Continue.
  3. Enter Connection to Warranties in the Name field.
  4. Enter vsdk_connection_to_warranties in the API Name field.
  5. Select your Vault owner as the Authorized Connection User.
  6. Select Save.

Veeva_Vault_Admin_Connections

  1. From the Actions menu of the new connection record, select Download Connection File. You will upload this connection file into the target Vault to authorize a connection back to the source Vault in a later step.

Download_Connection_File

Next, in the target Vault:

  1. Log in and navigate to Admin > Connections and click Create
  2. Choose the Vault to Vault connection type. Select Continue.
  3. Enter Connection to Warranties in the Name field.
  4. Enter vsdk_connection_to_warranties in the API Name field.
  5. Select your Vault owner as the Authorized Connection User.
  6. Click Save.
  7. From the Actions menu of the new Connection record, select Connect from File.
  8. At the prompt, select Choose and locate the connection file you downloaded from your source Vault.
  9. Click Continue.

Connect_From_File ion" />

Approve the Connections

To activate the connection between your two Vaults you must approve the connection on both Vaults:

  1. Log into your source Vault.
  2. Navigate to Admin > Connections
  3. Click on your newly created connection, which should be called Connection to Warranties.
  4. In the green Review Connection prompt (see screen shot), click Complete.
  5. In the pop-up, select Approve Connection and click Complete.
  6. Repeat steps 1 through 5 on your target Vault.

Approve_Connection g" label="Approve Connection" />

Approve_Modal nection"/>

After a successful upload of the connection file, the connections in both Vaults should have a Lifecycle State of "Active" and the "Remote Vault Details" section should be populated.

The connection between Vaults is now validated and ready for use!

Import Vault Packages

You must deploy the VPKs to your Vault prior to debugging these use cases.

Download the Project

  1. Clone or download the sample Maven project vSDK Spark Integration Rules Sample from GitHub.
  2. Run through the Getting Started guide to set up your deployment environment.

Source Vault: Deploy the Required Components

  1. Navigate to Admin > Settings.

  2. Click Edit.

  3. In the Configuration Management section, ensure that the Allow Inbound Packages checkbox is selected.

  4. Navigate to Admin > Deployment > Inbound Packages, click Import, and select the following file:

    Object components: <PROJECT_DIRECTORY>\deploy-vpk\source-vault\vsdk-spark-integration-rules-source-components-1.vpk.

  5. From the Actions menu, select Review & Deploy. Vault displays a list of all code components in the package.

  6. Review the prompts and click Next. Click Finish to deploy the package. You will receive an email when the deployment is complete. Any warnings in the deployment logs can be ignored.

  7. In Admin > Deployment > Inbound Packages, click Import and select the following file:

    Object components: <PROJECT_DIRECTORY>\deploy-vpk\source-vault\vsdk-spark-integration-rules-source-components-2.vpk.

  8. From the Actions menu, select Review & Deploy. Vault displays a list of all code components in the package.

  9. Review the prompts and then click Next then Finish to deploy the package. You will receive an email when the deployment is complete.

Once the packages have been deployed, you will want to review the configuration and understand the normal behavior so you can observe the effects of the sample code. Any warnings in the deployment logs can be ignored.

Target Vault: Deploy the Required Code & Components

  1. Navigate to Admin > Settings.

  2. Click the Edit button in the upper right.

  3. In the Configuration Management section, ensure that the Allow Inbound Packages checkbox is selected.

  4. Navigate to Admin > Deployment > Inbound Packages and click Import, then select the following file:

    Object components and Message Processor code: <PROJECT_DIRECTORY>\deploy-vpk\target-vault\vsdk-spark-integration-rules-target-components.vpk

  5. From the Actions menu, select Review & Deploy. Vault displays a list of all components in the package.

  6. Review the prompts to deploy the package. You will receive an email when the deployment is complete.

Below is a rundown of the included components.

Objects

Source Vault:

  • Warranty (vsdk_warranty__c)
  • Warranty Period (warranty_period__c)
  • Manufacturer (manufacturer__c)
  • Integration Transaction (integration_transaction__c)

Target Vault:

  • Claims Warranty (vsdk_claims_warranty__c)
  • Product Maker (product_maker__c)
Object Actions

Source Vault:

  • Send Warranty (vsdk_warranty__c.send_warranty__c)
Picklists

Source Vault:

  • Send to Claims Status (send_to_claims_status__c)
  • Transaction Status (transaction_status__c)

Target Vault:

  • Integration Status (integration_status__c)
Tabs

Source Vault:

  • Warranties (warranties__c)

Target Vault:

  • Claims Warranties (claims_warranties__c)
Page Layouts

Source Vault:

  • Integration Transaction Detail Page Layout (integration_transaction_detail_page_layo__c)
  • Warranty Period Detail Page Layout (warranty_period_detail_page_layout__c)
  • Manufacturer Detail Page Layout (manufacturer_detail_page_layout__c)
  • Warranty Detail Page Layout (warranty_detail_page_layout__c)

Target Vault:

  • Product Maker Detail Page Layout (product_maker_detail_page_layout__c)
  • Claims Warranty Detail Page Layout (claims_warranty_detail_page_layout__c)
Code

Source Vault:

  • Record Action: com.veeva.vault.custom.actions.vSdkSendWarrantyUserAction.java

Target Vault:

  • Message Processor: com.veeva.vault.custom.processors.vSDKIntRuleMessageProcessor.java
  • User Defined Class: com.veeva.vault.custom.udc.vSDKIntRulesETLWarranties
  • User Defined Class: com.veeva.vault.custom.udc.vSDKIntRulesHelper

Create Queues

Queue_Config

Target Vault Queue

You must configure the target Vault queue first:

  1. In the target Vault, log in and navigate to Admin > Connections > Spark Queues and click Create.
  2. Set the following values:
    • Label: vSDK Warranty In Queue
    • Name: vsdk_warranty_in_queue
    • Queue Type: Inbound
    • Message Processor: com.veeva.vault.custom.processors.vSDKIntRuleMessageProcessor
    • Message Processor User: <Vault Owner>
  3. Click Save
  4. On the new Queue, scroll down to the Queue Connections section and click Create.
  5. Select the vsdk_connection_to_warranties and click Save.

Source Vault Queue

Next, configure the source Vault queue:

  1. In the source Vault, log in and navigate to Admin > Connections > Spark Queues and click Create.
  2. Set the following values:
    • Label: vSDK Warranty Out Queue
    • Name: vsdk_warranty_out_queue
    • Queue Type: Outbound
  3. Click Save
  4. On the new Queue, scroll down to the Queue Connections section and click Create.
  5. Select the vsdk_connection_to_warranties.
  6. For Deliver to Queue, select the vsdk_warranty_in_queue__c.
  7. Click Save.

Create Integration

Integrations are a way to organize the business process supported by the Spark integration. It gives non-coders in the Vault Admin UI insight into the configuration and goals of an integration. We recommended using descriptive naming that indicates to a non-technical viewer what an integration is used for.

Source Vault - Create the 'Warranties' integration

  1. Navigate to Admin > Connections.
  2. Select Connection to Warranties.
  3. Expand the Integrations section and click Create.
  4. Set the following values:
    • Name: Warranties
    • Integration API Name: warranties__c
    • Status: Active
  5. Click Save.

Source_-_Create_Integration

Target Vault - Create the Warranties integration

  1. Navigate to Admin > Connections.
  2. Select Connection to Warranties.
  3. Expand the Integrations section and click Create.
  4. Set the following values:
    • Name: Warranties
    • Integration API Name: warranties__c
    • Status: Active
  5. Click Save.

Create Integration Points

Integration Points are a way to organize a complete round trip of data flows. There are multiple Integration Points for each Integration. This gives a non-coder user in the Vault Admin UI insight into some of the details of an Integration.

Source Vault - Create the outbound Integration Point

  1. Navigate to Admin > Connections.
  2. Select Connection to Warranties.
  3. Expand the Integration section and click on Warranties.
  4. Expand the Integration Points - Inbound and Integration Point - Outbound sections.
    • Note: There is no Inbound Integration Point configured on the Source system. In this demo, data only flows outbound from the source system with no inbound messages.
  5. In the Integration Points - Outbound section, click Create.
  6. Set the following values:
    • Name: Send Warranty
    • Integration Point API Name: send_warranty_c
    • Description: Send Warranty Record
    • Status: Active
  7. Click Save.

Configure_Integration_Points

Target Vault

For the target Vault, we will set up inbound and outbound Connections to support the full round trip required to share data and update the source Vault.

Configure Outbound
  1. Navigate to Admin > Connections.
  2. Select the Connection you created earlier on the source system.
  3. Expand the Integration section and click on Warranties.
  4. Expand the Integration Points - Inbound and Integration Point - Outbound sections.
  5. In the Integration Points - Outbound section, click Create.
  6. Set the following values:
    • Name: Sample Outbound
    • Integration Point API Name: sample_outbound
    • Description: Sample Outbound
    • Status: Active
  7. Click Save.
Configure Inbound
  1. Navigate to Admin > Connections
  2. Select the Connection you created earlier on the source system.
  3. Expand the Integration section and click on Warranties.
  4. Expand the Integration Points - Inbound and Integration Point - Outbound sections.
  5. In the Integration Points - Inbound section, click Create.
  6. Set the following values:
    • Name: Receive Warranty
    • Integration Point API Name: receive_warranty__c
    • Description: Receive Warranty Record
    • Status: Active
  7. Click Save.

Create Reference Lookups

Get Source Lookup IDs

  1. In the source Vault, log in and navigate to Admin > Business Admin > Objects > Manufacturers.
  2. From the Actions menu, select Edit Columns and make sure "ID" is in the Selected Columns list before pressing Save.
  3. From the Actions menu, select Export CSV.
  4. Store the source CSV File as it will contain the Manufacturers object records including the ID fields. It should look like the image shown, but with different IDs:

Source_Manufacturers_CSV "/>

Populate Reference Lookups in the Target

  1. In the target Vault, log in and navigate to Admin > Connections > Connection to Warranties.

  2. Expand the Reference Lookups section.

  3. Click Add.

  4. Set the following values:

    • Select Reference Lookup Type: Object
    • Select Target Object: product_makers__c Create_Reference_Lookups
  5. Click Continue.

  6. Set the Target Key Field to ID (id).

  7. Click Add.

  8. Set the following values:

    • Source Key: Your ID field from the Source CSV file
    • Target Key: The ID associated to the Source Product ID
    • Status: Active Create_Reference_Lookups2

9.Click Save. 10. Repeat steps 7 to 9 for each Manufacturer / Product Maker in the csv source file, changing the Source Key and Target Key values. Connection_Reference_Lookups

Create Integration Rules

Target Vault

  1. Navigate to Admin > Connections
  2. From the Integration Config section, select Integration Rules and click Create.
  3. Set the following values:
    • Label: Warranties
    • Name: warranty_int_rule_1
    • Status: Active
    • Connection: vsdk_connection_to_warranties
    • Integration Point: receive_warranty__c
  4. Click Save.
  5. In the Field Rules section, click Create.
  6. Set the following values:
    • Target Object: Claims Warranties
    • Target Object Field: Source Record (source_record__c)
    • Label: Source Record
    • Name: warranty_field_rule_1
    • Query Object: Warranties
    • Query Object Field: ID (id)
    • Status: Active
  7. Click Save and press warranty_int_rule_1__c in the breadcrumb trail.
  8. Repeat steps 5 to 7 for each of the following Field Rules:
Target Object Target Object Field Label Name Query Object Query Object Field Default Reference Lookup Type Reference Lookup
Claims Warranties Warranty Holder Warranty Holder warranty_field_rule_2__c Warranties Customer Name
Claims Warranties Start Date Start Date warranty_field_rule_3__c Warranties Cover Start Date
Claims Warranties Info Info warranty_field_rule_4__c Created by Vault to Vault integration
Claims Warranties Product Maker Product Maker warranty_field_rule_5__c Warranties Manufacturer Object product_maker__c
Claims Warranties Warranty Plus Cover Warranty Plus Cover warranty_field_rule_6__c Warranties Extended Cover
Claims Warranties Duration Duration warranty_field_rule_7__c Warranty Periods Name

Field_Rules

Next Steps

Data Sync

  • Run the project provides details of how to run the project.
  • Code logic provides a detailed understanding of how the sample components work for data sync.