Datasource tenant configuration
Since CDS 2.1, the customerdata service supports multi-tenant datasources. Enabling multi-tenancy means that calling the API will require sending an additional HTTP header (X-TENANT-ID) with the tenant name. In the configuration of the customerdata service can configure which tenants are allowed to access the API and for each allowed tenant configure a specific datasource. When the customerdata service is not able to retrieve the tenant name or the given tenant name is not allowed to access a HTTP Status 400 (Bad request) is returned and the details are printed in the log.
Info |
---|
We only support multi-tenancy where each tenant uses the same database vendor. You are not able to mix, for example, an Oracle tenant with an Microsoft SQL Server tenant. |
Event publisher tenant configuration
Since CDS 4.4 the customerdata service supports a multi-tenant event publisher. Enabling multi-tenancy means that properties for publishing aggregate event messages to a queue can be configured for each tenant. To enable the event publisher the entity-event-publisher-amqp profile should be active.
Tenant configuration
Code Block |
---|
language | yml |
---|
title | blueriq-customerdata-odata-service-v1.yml or blueriq-customerdata-odata-service-v1.properties |
---|
|
blueriq:
multi-tenancy:
enabled: true
allowed-tenants: <tenant-name-A>,<tenant-name-B>
customerdata:
datasource:
<datasource-name>:
driver-class-name: <driver>
tenants:
<tenant-name-A>:
url: <url>
username: <username>
password: <password>
<tenant-name-B>:
url: <url>
username: <username>
password: <password>
# publisher
aggregate-event:
channel:
amqp:
rabbitmq:
tenants:
google:
host: <host>
port: <port>
virtualHost: <virtualHost>
username: <username>
password: <password>
ssl:
enabled: <enabled>
exchangeName: <exchangeName>
apple:
host: <host>
port: <port>
virtualHost: <virtualHost>
username: <username>
password: <password>
ssl:
enabled: <enabled>
exchangeName: <exchangeName>
|
Example setup
Configuration
Code Block |
---|
language | yml |
---|
title | blueriq-customerdata-odata-service-v1.yml or blueriq-customerdata-odata-service-v1.properties |
---|
|
blueriq:
multi-tenancy:
enabled: true
allowed-tenants: google,apple
customerdata:
datasource:
customer-data-sql-store:
driver-class-name: oracle.jdbc.driver.OracleDriver
tenants:
google:
url: jdbc:oracle:thin:@localhost:1521:orcl
username: google
password: welcome
apple:
url: jdbc:oracle:thin:@localhost:1521:orcl
username: apple
password: welcome
# publisher
aggregate-event:
channel:
amqp:
rabbitmq:
tenants:
google:
host: localhost
port: 5672
virtualHost: Blueriq
username: guest
password: guest
ssl:
enabled: false
exchangeName: customerDataService
apple:
host: localhost
port: 5672
virtualHost: Everest
username: guest
password: guest
ssl:
enabled: false
exchangeName: customerDataService
hibernate:
dialect: org.hibernate.dialect.Oracle12cDialect
hbm2ddl:
auto: validate
id:
new_generator_mappings: true
show_sql: true
use_nationalized_character_data: true
|
HTTP request
Code Block |
---|
language | bash |
---|
title | Example request |
---|
|
GET http://localhost:8080/api/v1/Aggregates HTTP/1.1
Content-Type: application/json
Authorization: Basic Ymx1ZXJpcTp3ZWxjb21l
X-TENANT-ID: google |