Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Summary

This example demonstrates:

  • How to define a vdb and transfer data from a SalesForce database. Please note other data source types are also possible

  • How to use Thorntail to configure VDB, configure data sources and run Teiid as a Thorntail uber jar.

Building the Example

The following sections define steps to code and run the example.

Data Source Setup

Since SalesForce is cloud SaaS based service, there is no setup. Just gather your credentials to connect.

Project Setup

Important
This example requires Java 8 JDK or greater and Maven 3.3.x.

The project is a maven project with vdb packaging. This is special packaging developed for Teiid based VDB. The pom.xml is the key file for building a Throntail based application. To enable vdb packing you need to add following to your pom.xml

<packaging>vdb</packaging>

<build>
	<plugins>
      <plugin>
        <groupId>org.teiid</groupId>
        <artifactId>vdb-maven-plugin</artifactId>
        <version>1.1</version>
      </plugin>
	</plugins>
</build>

This project also requires the thorntail-maven-plugin to build a uber jar with -thorntail.jar extension, for that add the following

<build>
	<plugins>
      <plugin>
        <groupId>io.thorntail</groupId>
        <artifactId>thorntail-maven-plugin</artifactId>
        <version>${version.thorntail}</version>
      </plugin>
	</plugins>
</build>

This project also depends on following dependencies, namely Teiid and Salesforce translators

<!-- This adds dependency on Teiid Fraction in Thorntail -->
<dependency>
  <groupId>io.thorntail</groupId>
  <artifactId>teiid</artifactId>
</dependency>

<!-- This adds dependency for Teiid's JDBC translator -->
<dependency>
  <groupId>io.thorntail</groupId>
  <artifactId>teiid-salesforce-41</artifactId>
</dependency>

if you want your Teiid instance to expose OData API, then add the following dependency

<dependency>
  <groupId>io.thorntail</groupId>
  <artifactId>odata</artifactId>
</dependency>

That completes the defining the pom.xml, for complete pom.xml see the example. Now we need to define the VDB.

VDB Setup

Thorntail based Teiid currently only supports XML/DDL based VDBS with -vdb.xml extension. Develop your VDB completely using Designer perhaps or simply using a text editor, once done place the VDB file in src/main/vdb folder.

Data Source Configuration

Data Source configuration is defined by Thorntail. You can see more information about this at http://docs.wildfly-thorntail.io/2018.5.0/#_resource_adapters

This example provides a sample data configuration file in src/main/resources directory with name project-defaults.yml with content

swarm:
  resource-adapters:
    resource-adapters:
      sfDS:
        module: org.jboss.teiid.resource-adapter.salesforce-41
        transaction-support: NoTransaction
        connection-definitions:
          sfDS:
            class-name: org.teiid.resource.adapter.salesforce.SalesForceManagedConnectionFactory
            jndi-name: java:/sfDS
            enabled: true
            use-java-context: true
            config-properties:
              URL:
                value: https://login.salesforce.com/services/Soap/u/40.0
              username:
                value: user
              password:
                value: pass
Important
Make sure jndi-name configured here matches with that of what you defined in the VDB’s salesforce model.

Now development/configuration is done.

Build and Run the project

you can build the project by issuing the following the command

mvn clean package

this should build the project and if everything went well then it will create a jar file with -thorntail.jar file in the target directory. You can run the application by running

java -jar target/salesforce-as-datasource-1.0.0-thorntail.jar

You should hit an authentication error from salesforce if you have not changed the username/password in the project yaml.

You may pass values in the command line as well

java -jar target/salesforce-as-datasource-1.0.0-thorntail.jar -Dswarm.resource-adapters.resource-adapters.sfDS.connection-definitions.sfDS.config-properties.username=foo

Query Demonstrations

Now you can use any SQL client tools like SQuirreL or your own Java application and use Teiid JDBC driver and connect to the saleforce VDB and issue commands like (see simpleclient project for sample java code for client)

select * from account;

and see results as

CST01002	Joseph	Smith
CST01003	Nicholas	Ferguson
CST01004	Jane	Aire
CST01005	Charles	Jones
CST01006	Virginia	Jefferson
CST01007	Ralph	Bacon

If you enabled the OData, then you can use your browser and visit

http://localhost:8080/odata4/salesforce.1/sf/account?$format=json

You will see results like

[{
  "SSN":"CST01002",
  "FIRSTNAME":"Joseph",
  "LASTNAME":"Smith",
  "ST_ADDRESS":"1234 Main Street",
  "APT_NUMBER":"Apartment 56",
  "CITY":"New York",
  "STATE":"New York",
  "ZIPCODE":"10174",
  "PHONE":"(646)555-1776"
},
{
  "SSN":"CST01003",
  "FIRSTNAME":"Nicholas",
  "LASTNAME":"Ferguson",
  "ST_ADDRESS":"202 Palomino Drive",
  "APT_NUMBER":null,
  "CITY":"Pittsburgh",
  "STATE":"Pennsylvania",
  "ZIPCODE":"15071",
  "PHONE":"(412)555-4327"
}]