Data source service deploy on runtime

Six Stars

Data source service deploy on runtime

Hello.

I've created datasource.xml file to store many connections and use "specify a data source alias" in studio.

datasource.xml file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0">


    <bean id="ds1" class="com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource">
	<property name="URL" value="..." />
        <property name="user" value="..." />
	<property name="password" value="..." />
    </bean>

    <bean id="dspool1"
        class="org.apache.commons.dbcp.datasources.SharedPoolDataSource" destroy-method="close">
        <property name="connectionPoolDataSource" ref="ds1" />
        <property name="maxActive" value="20" />
        <property name="maxIdle" value="5" />
        <property name="maxWait" value="-1" />
    </bean>

    <service ref="dspool1" interface="javax.sql.DataSource">
        <service-properties>
            <entry key="org.talend.esb.datasource.name" value="name1" />
            <entry key="osgi.jndi.service.name" value="jdbc/name1" />
        </service-properties>
    </service>
.....another service
.....
</blueprint>

And everything works fine when I deploy datasource.xml by placing it in container/deploy.
But I want to start this service on startup runtime.
So I'm creating featureRepository and I don't know how to define this service.
I was able to add and auto start other bundles I needed in this way:

<feature name="dataSourceFeature" version="1.0">
  <bundle>wrap:mvn:commons-dbcp/commons-dbcp/1.4</bundle>
  <bundle>wrap:mvn:com.microsoft.sqlserver/sqljdbc4/4.0</bundle>
</feature>

and then add dataSourceFeature to featuresBoot.

I don't know how to start datasource.xml manually.

When I run on Karaf console bundle:install and put mvn url I've got 
Error executing command: Error installing bundles:
Unable to install bundle mvn:com......./datasource/0.3/xml: org.osgi.framework.BundleException: Error occurred installing a bundle.


Accepted Solutions
Community Manager

Re: Data source service deploy on runtime

I *think* you will need to have the XML file in an artefact repository like Nexus. Then configure your Nexus in the file I mentioned last time. Once you have done that, you should be able to refer to the artefact using MVN


All Replies
Community Manager

Re: Data source service deploy on runtime

Maybe I am misunderstanding the issue here, but if you have added that file to the deploy folder, it will start when the runtime starts automatically

Six Stars

Re: Data source service deploy on runtime

You are right but I dont want to keep festures in deploy. I want to
configure it in festures boot and always on startup get the latest version
from maven repository. And finally place talned esb in docker. So every
time I restart docker Ive got all needed festures in latest version
Community Manager

Re: Data source service deploy on runtime

I see. Do you have the maven repository you are using to hold the datasource.xml listed in this file.....

etc\org.ops4j.pax.url.mvn.cfg

I don't know that this is your problem, but this is my first thought now I understand what you are trying to do. 

 

By the way, what you are doing sounds like an interesting approach. When you get it working, how would you feel about writing a blog on how you have done this? I think this would be a very interesting topic

Six Stars

Re: Data source service deploy on runtime

Yes I've got it.

And as I wrote I can automatically deploy on statrup feature dataSourceFeature, but this feature contains two bundle which are jar files:commons-dbcp and sqljdbc .
The problem is I don't how to define feature containing bunlde with datasource.xml. Because it's xml file?

I don't know even how to do this on console.
I've tried 

bundle:install mvn:com.../datasource/0.3/xml

but I'm getting error:

 

 

Error executing command: Error installing bundles:
        Unable to install bundle mvn:com.../datasource/0.3/xml: org.osgi.framework.BundleException: Error occurred installing a bundle.

That's why I don't know how to create feature and place in it xml file with data sources.

 

Community Manager

Re: Data source service deploy on runtime

I *think* you will need to have the XML file in an artefact repository like Nexus. Then configure your Nexus in the file I mentioned last time. Once you have done that, you should be able to refer to the artefact using MVN

Six Stars

Re: Data source service deploy on runtime

Probably you are right.

Because all maven artifacts are treated as archive I think I must create maven project which create a jar or other archive containing my xml configuration.

Thanks

Community Manager

Re: Data source service deploy on runtime

I think you said that you are using Docker. Here is a Docker-compose.yml for a quick test with Nexus.....

 

version: '3'

services:
      
  nexus-talend:
    image: sonatype/nexus3
    volumes:
      - ./nexus-data:/nexus-data
    ports:
      - "8081:8081"

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read