You are viewing the documentation for Blueriq 17. Documentation for other versions is available in our documentation directory.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Next »

WORK IN PROGRESS

This page applies to you when you want a different data storage for the persistence-API than the default which is provided in the Customerdata service

The default implementation for the persistence-API is the Customerdata service. This page provides information about implementing a custom data storage for the Customerdata service by extending the existing Customerdata service. This is suitable in case of an different database or different database scheme.

Please note that the Customerdata service is written in Java and Spring. Because of this extending the Customerdata Service with custom implementation also requires you to use Java and Spring. Also maven is used as build tool.

Custom components

 

For creating this custom data store implementation two components of the existing Customerdata service need to be replaced with a custom implementation.

  • blueriq-customerdata-sql-store-service → custom data store implementation
  • blueriq-customerdata-sql-store-application → custom War application

 

blueriq-customerdata-sql-store-service

The blueriq-customerdata-sql-store-service is a Hibernate implementation which stores the data in the database. For storing the data in a different database or different data structure you need to replace this part with your own implementation which handles the data storage using blueriq-customerdata-api-v1.

blueriq-customerdata-sql-store-application

The blueriq-customerdata-sql-store-application packages a war file for deployment on a application server. When you create a custom data store implementation you need to package a new war containing the needed components(see: Custom war implementation).

 

// TODO JAVADOC of the api on confluence (warning)

blueriq-customerdata-api-v1

When you are implementing a custom data store you need to implement some interfaces from the blueriq-customerdata-api-v1 and use the model classes of the api-v1.

The blueriq-customerdata-api-v1 consists out of the following packages:

  • com.blueriq.customerdata.api.v1.event
  • com.blueriq.customerdata.api.v1.exception
  • com.blueriq.customerdata.api.v1.expression
  • com.blueriq.customerdata.api.v1.model
  • com.blueriq.customerdata.api.v1.model.event
  • com.blueriq.customerdata.api.v1.order
  • com.blueriq.customerdata.api.v1.repository
  • com.blueriq.customerdata.api.v1.select

Packages com.blueriq.customerdata.api.v1.event and com.blueriq.customerdata.api.v1.model.event are not needed for a custom data store implementation.

The following packages are needed for filtering, ordering and selecting data: com.blueriq.customerdata.api.v1.expression, com.blueriq.customerdata.api.v1.order and com.blueriq.customerdata.api.v1.select.

In the com.blueriq.customerdata.api.v1.repository package you will find the interface needed retrieving, storing and deleting the data using the expression, model, order and select packages as input. The model package is also used as return results for some operations. for more information see: LINK.

// TODO: describe what is put on the queue (AggregateModel is still published on the queue, refer to queue documentation)

Example project

There are multiple ways how you can create your custom implementation, there is no fixed way to do this. In order to get you started you can download an example project with an example implementation that just logs the operations called.

 Maven structure:

  • example-custom-customerdata
    • example-customerdata-parent 
    • example-customerdata-data-store-service
    • example-customerdata-data-store-application
    • example-customerdata-data-store-standalone

Example-customerdata-parent

The project parent definition contains the required Customerdata Service dependencies.

Customerdata Service dependencies
<!-- Required Customerdata Service dependencies -->
<dependency>
  <groupId>com.blueriq</groupId>
  <artifactId>blueriq-customerdata-parent</artifactId>
  <version>${com.blueriq.customerdata.version}</version>
  <type>pom</type>
  <scope>import</scope>
</dependency>
<dependency>
  <groupId>com.blueriq</groupId>
  <artifactId>blueriq-customerdata-api-v1</artifactId>
  <version>${com.blueriq.customerdata.version}</version>
</dependency>

Example-customerdata-data-store-service

This part is meant for the custom implementation. In the example it contains a config and an example implementation of the IAggregateRepository that just logs every action and returns defaults where needed. See: Creating a custom data store implementation for information.

Example-customerdata-data-store-application

Here a war file gets packaged for deployment on a application server. Please see Creating a custom war implementation for more information about this module.

Example-customerdata-data-store-standalone

This is and standalone Spring-boot application which is running on embedded Tomcat. Not required, but added for easy local development.

Creating a custom data store implementation

// TODO describe whats needed with example

properties from existing implementation

Create your own implementation for the data-storage

replace the sql-store implementation:

  • how is it picked up? (config/component scan)
  • transactionManager:
    • must be of type platformTransactionManager and is required.
    • cannot have the name's 'chainedTransactionManager' OR 'rabbitTransactionManager' because these names are reserved.
    •  Also you need to provide the correct Order precedence. We advise you to use @Order(10) // DatabaseTransaction is higher in order than the RabbitTransaction in the transactionChain
    • describe why the order needs to be higher
  • AggregateModel data field is now an xml representation of an aggregate

Creating a custom WAR implementation

In order to use your custom implementation it needs to be deployed to an application server. To be able to do that you need to package a WAR(Web application ARchive).

Because we use Spring-boot the WAR application should contain a class that initializes the web application. When you look at the example project provided above you will find the class:com.blueriq.example.customerdata.data.store.application.config.CustomerdataDataStoreApplicationConfig.java
In order to start the Customerdata service Spring-boot application correctly you will need to add two application.sources:

  • CustomerdataOdataServiceConfig.class: this is the Main config of the Customerdata Service.

  • The second application.source is your custom Configuration class(with the @Configuration annotation) for initializing your custom data store implementation. In the example below it is CustomDataStoreConfig.class: because in the provided example project this is the custom config.

CustomerdataDataStoreApplicationConfig.java
public class CustomerdataDataStoreApplicationConfig extends SpringBootServletInitializer {

  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(CustomerdataOdataServiceConfig.class, CustomDataStoreConfig.class);
  }

}

Deployment on JBoss-eap(6.4 and 7)

If you are deploying you WAR application on JBoss-eap you will need to add an additional deployment information to the WEB-INF. In the provided example there is already an jboss-web.xml to provide a context-root(<context-root>customerdata</context-root>). There is also and deployment-structure.xml provided which contains the needed deployment-structure for the example to work on JBoss-eap-6.4. If you want to deploy the war of the example on JBoss-eap-7 you will need to modify the deployment-structure.xml, see comments in the provided deployment-structure.xml for details.

Depending on your custom data store implementation it can be necessary to modify the deployment-structure.xml because of conflicting library's.

Test

For the Aggregate functionality in the Blueriq Runtime it is important that the behavior of the Customerdata Service with a custom data store implementation is the same as the Original Customerdata Service. There are Ready-API (regression) tests available to test the Persistence-API. These test are data storage independent. Please contact support if you wish to use the Ready-API regression test to verify your custom implementation.

  • No labels