Skip to content

Section 12 - Create a Distibution using IntelliJ

Go back to Getting started guide

In this section we will:

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.

  1. 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>
    
  2. Replace [NAME_OF_MY_DISTRIBUTION] with DISTR_CUSTOMER_EMAIL_ATTACH_CSV_1AM.
  3. Replace [NAME_OF_SCHEMA] with CUSTOMER.
  4. Replace [DISTRIBUTION_DESCRIPTION] with "Distributes all CUSTOMER data, via email and filesystem as a CSV attachhment, every day at 1am".
  5. Replace [COLLECTION_NAME] with CUSTOMER_ALL. Note: As mentioned in Datablock Collections, every schema creates a corresponding Datablock collection. ie. CUSTOMER_ALL datablock collection was implicitly created by CUSTOMER schema.
  6. Replace [CSV_XML_JSON] with CSV to specify that the data needs to be distributed as a CSV file.
  7. 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>
    
  8. Replace <autoTrigger>false</autoTrigger> with <autoTrigger>true</autoTrigger> to enable scheduled auto triggered distribution.

  9. 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>
    
  10. This resulting file is shown below in the next section below.
  11. 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 trigger_distribution.
  12. When you trigger the distribution you will see the message notifying you accordingly. distribution_triggered.
  13. If you are using thew compose script on your local machine, it is very likely that you do not have an email server so the Email data sink will not distribute the file but the Filesystem Data Sink will write the file to your default output file apiro-output as shown below filesystem_distributed_file.

Configuration files

Completed configuration files
  • This is the completed Distribution that uses the previously created Datablock collections and Data 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.