Section 12 - Create a Distibution using IntelliJ
Go back to Getting started guide
In this section we will:
- show how to create an email Data Distirbution
- ensure you understand the concepts explained Datablock Collections
- ensure you understand the concepts explained Data Distributions
-
ensure you understand the concepts explained Email Attach - Data Sink
Description Config Reference
Create a scheduled data Distribution using via UI
Distribute data as CSV using an Email Attachment and Filesystem
TODO
Create a data Distribution using using IntelliJ
Distribute data as CSV using an Email Attachment and Filesystem
Distribution config below distributes all CUSTOMER schema data, via email as a CSV attachhment and also write to the file system, every day at 1am.
- Start creating a file
DISTRIBUTION_CUSTOMERS.xml, copy and paste the configuration below into the file.1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <apiroConf version="1" xmlns="http://apiro.com/apiro/v1/root"> <loadOrder>30</loadOrder> <distributions> <distribution name="[NAME_OF_MY_DISTRIBUTION]" schema="[NAME_OF_SCHEMA]"> <description>[DISTRIBUTION_DESCRIPTION]</description> <dataBlockCollection name="DATABLOCK_COLLECTION" entity="[COLLECTION_NAME]" /> <formatter name="FORMATTER" entity="[CSV_XML_JSON]"/> <dataSinks/> <autoTrigger>false</autoTrigger> <cronTriggers/> </distribution> </distributions> </apiroConf> - Replace
[NAME_OF_MY_DISTRIBUTION]withDISTR_CUSTOMER_EMAIL_ATTACH_CSV_1AM. - Replace
[NAME_OF_SCHEMA]withCUSTOMER. - Replace
[DISTRIBUTION_DESCRIPTION]with "Distributes all CUSTOMER data, via email and filesystem as a CSV attachhment, every day at 1am". - Replace
[COLLECTION_NAME]withCUSTOMER_ALL. Note: As mentioned in Datablock Collections, every schema creates a correspondingDatablock collection. ie.CUSTOMER_ALLdatablock collection was implicitly created byCUSTOMERschema. - Replace
[CSV_XML_JSON]withCSVto specify that the data needs to be distributed as aCSVfile. -
Replace
entity="<dataSinks/>"with the following data sinks that were created in previous sections. This will indicate that the data needs to be distribute via email and also written on the filesystem.1 2 3 4 5 6
<dataSinks> <dataSink name="EMAIL_ATTACH" entity="DATA_SINK_CUSTOMER_EMAIL_ATTACH_CSV_0"/> </dataSinks> <dataSinks> <dataSink name="FILESYSTEM" entity="DATA_SINK_CUSTOMER_FILESYSTEM_0"/> </dataSinks> -
Replace
<autoTrigger>false</autoTrigger>with<autoTrigger>true</autoTrigger>to enable scheduled auto triggered distribution. - Replace the
<cronTrigger/>element:1 2 3 4 5 6 7
<cronTriggers> <cronTrigger> <description>Executes at 1am every day</description> <!--https://freeformatter.com/cron-expression-generator-quartz.html--> <cron>0 0 1 ? * * *</cron> </cronTrigger> </cronTriggers> - This resulting file is shown below in the next section below.
- Once you follow the configuratin instructions at the bottom of this page you will be able to distribute the data by triggering the specific distribution shown in the screenshot below
. - When you trigger the distribution you will see the message notifying you accordingly.
. - If you are using thew
compose scripton your local machine, it is very likely that you do not have an email server so theEmail data sink will not distribute the filebut theFilesystem Data Sinkwill write the file to your default output fileapiro-outputas shown below
.
Configuration files
Completed configuration files
- This is the completed
Distributionthat uses the previously createdDatablock collectionsandData Sinks.1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <apiroConf version="1" xmlns="http://apiro.com/apiro/v1/root"> <loadOrder>30</loadOrder> <distributions> <distribution name="DISTR_CUSTOMER_EMAIL_ATTACH_CSV_1AM_0" schema="CUSTOMER0"> <description>Distributes all CUSTOMER schema data, via email as a CSV attachhment, every day at 1am</description> <dataBlockCollection name="DATABLOCK_COLLECTION" entity="CUSTOMER0_ALL" /> <formatter name="FORMATTER" entity="CSV"/> <dataSinks> <dataSink name="EMAIL_ATTACH" entity="DATA_SINK_CUSTOMER_EMAIL_ATTACH_CSV_0"/> </dataSinks> <dataSinks> <dataSink name="FILESYSTEM" entity="DATA_SINK_CUSTOMER_FILESYSTEM_0"/> </dataSinks> <autoTrigger>false</autoTrigger> <cronTriggers> <cronTrigger> <description>Executes at 1am every day</description> <!--https://freeformatter.com/cron-expression-generator-quartz.html--> <cron>0 0 1 ? * * *</cron> </cronTrigger> </cronTriggers> </distribution> </distributions> </apiroConf>
Deploy config files
Follow these steps Config Deployment to deploy and start using your configuration files.