Skip to content

Commit

Permalink
👌 IMPROVE: Add Snowflake connector
Browse files Browse the repository at this point in the history
  • Loading branch information
jpontdia committed Nov 16, 2023
1 parent bb39293 commit 8f57349
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 7 deletions.
53 changes: 49 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
<parent>
<groupId>078efef1-d139-48ed-92f5-f8d4a0592374</groupId>
<artifactId>common-parent-pom</artifactId>
<version>1.0.30</version>
<version>1.0.33</version>
<relativePath/>
</parent>

<groupId>078efef1-d139-48ed-92f5-f8d4a0592374</groupId>
<artifactId>common-core</artifactId>
<version>1.0.25</version>
<version>1.0.27</version>
<packaging>mule-application</packaging>
<name>common-core</name>
<description>Shared Mule library that provides reusable flows, resources and configuration settings common for all applications</description>

<properties>
<!-- Exchange documentation -->
<fields key="sourceCode">https://github.com/jpontdia/mule-common-core</fields>
<fields key="sourceCode">https://github.com/jpontdia/common-core</fields>
<categories key="Asset type">Common</categories>
<tags>Common, Salesfoce, OpenTelemetry</tags>
<tags>Common, Salesforce, OpenTelemetry, Snowflake, SQLServer, Email</tags>
</properties>

<build>
Expand All @@ -31,19 +31,64 @@
<extensions>true</extensions>
<configuration>
<classifier>mule-plugin</classifier>
<sharedLibraries>
<sharedLibrary>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</sharedLibrary>
<sharedLibrary>
<groupId>net.snowflake</groupId>
<artifactId>snowflake-jdbc</artifactId>
</sharedLibrary>
</sharedLibraries>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>

<!-- Salesforce connector -->
<dependency>
<groupId>com.mulesoft.connectors</groupId>
<artifactId>mule-salesforce-connector</artifactId>
<classifier>mule-plugin</classifier>
</dependency>

<!-- Mule extension that provides functionality to send and receive emails through POP3, IMAP and SMTP -->
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-email-connector</artifactId>
<classifier>mule-plugin</classifier>
</dependency>

<!-- Database connectors -->
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-db-connector</artifactId>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>com.mulesoft.connectors</groupId>
<artifactId>mule4-snowflake-connector</artifactId>
<classifier>mule-plugin</classifier>
</dependency>

<!-- Database drivers -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc_auth</artifactId>
<type>dll</type>
</dependency>
<dependency>
<groupId>net.snowflake</groupId>
<artifactId>snowflake-jdbc</artifactId>
</dependency>

<!-- OpenTelemetry connector -->
<dependency>
<groupId>078efef1-d139-48ed-92f5-f8d4a0592374</groupId>
Expand Down
28 changes: 28 additions & 0 deletions src/main/mule/global-configuration-snowflake.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:snowflake="http://www.mulesoft.org/schema/mule/snowflake"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/snowflake
http://www.mulesoft.org/schema/mule/snowflake/current/mule-snowflake.xsd">

<configuration-properties
doc:name="Configuration properties"
file="common-config.yaml" />

<snowflake:snowflake-config doc:name="Snowflake Config" name="Snowflake_Config">
<snowflake:snowflake-connection
accountName="${snowflake.accountname}"
warehouse="${snowflake.warehouse}"
database="${snowflake.database}"
schema="${snowflake.schema}"
user="${snowflake.user}"
password="${snowflake.password}"
role="${snowflake.role}" />
</snowflake:snowflake-config>

</mule>
29 changes: 29 additions & 0 deletions src/main/mule/global-configuration-sqlserver.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>

<mule
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:db="http://www.mulesoft.org/schema/mule/db"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/db
http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
">

<configuration-properties
doc:name="Configuration properties"
file="common-config.yaml" />

<db:config name="MSSQL_Server_Config"
doc:name="Database Config"
doc:description="This is used to connect to the on-prem Microsoft SQL Server">
<db:mssql-connection
host="${mssql.prd.host}"
user="${mssql.prd.user}"
password='${mssql.prd.pass}'
databaseName="${mssql.prd.name}" />
</db:config>

</mule>
24 changes: 24 additions & 0 deletions src/main/mule/global-configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,28 @@
serviceName="${otel.servicename}"
additionalTags="env=${env}"
collectorEndpoint="${otel.collectorendpoint}"/>

<tls:context name="TLS_Context"
doc:name="TLS Context"
doc:description="This connector is used to secure HTTP connectors with TLS 1.2 security and encryption. This is necessary for communications between mule apps and other services outside Anypoint but also is just another layer of security between the services hosted on Anypoint">
<tls:key-store type="jks"
path="${jks.path}"
keyPassword="${jks.keypassword}"
password="${jks.keypassword}" />
</tls:context>

<email:smtp-config name="Email_SMTP_Config"
doc:name="Email SMTP"
doc:description="This is all of the configuration settings that are needed to send emails with the Mulesoft email account from the mule app for the email item make sure you set the advanced `mail.smtp.starttls.enable` inline attribute to `true`"
from="${email.user}">
<email:smtp-connection host="${email.host}"
port="${email.port}"
user="${email.user}"
password="${email.pass}">
<email:properties>
<email:property key="mail.smtp.starttls.enable"
value="true" />
</email:properties>
</email:smtp-connection>
</email:smtp-config>
</mule>
27 changes: 24 additions & 3 deletions src/main/resources/global-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Default environment
env: local

# Java Keystore for SSL and TLS-Context
jks:
keypassword: 'myKeypassword'
path: 'myJksPath'

# Listening port of the serivce
httpprotocol: "HTTPS"
http:
port: "8081"
https:
port: "8082"

# Salesfoce Connection
salesforce:
Expand All @@ -24,6 +32,20 @@ otel:
logzio.token: "MyToken"
logzio.url: "MyUrl"

# Email
email:
host: 'outlook.office365.com'
port: '587'
user: 'myUser'
pass: 'myPass'

# SQL Server
mssql:
host: 'myHost'
user: 'myUser'
pass: 'myPAss'
name: 'master'

# Service messages
messages:
backend-error: "There was a problem while trying to access the backend repository"
Expand All @@ -33,10 +55,9 @@ messages:
apikit-406: "Not acceptable"
apikit-415: "Unsupported media type"
apikit-501: "Not Implemented"
one-query-filter: "At least one query filter must be sent other than maxRecords or pagination parameters"
record-delete-success: "The record was deleted successfully"
record-delete-error: "The record cannot be deleted; it doesn´t exist or has relationships with other resources"
record-create-success: "The record was created successfully"
record-create-error: "There was a problem while creating the record"
record-exists: "The record already exists"


record-exists: "The record already exists"

0 comments on commit 8f57349

Please sign in to comment.