2.4. External Materialization and Red Hat JBoss Data Grid
Red Hat JBoss Data Grid can be used as an external materialized data source system in order to improve query result performance. You can use a JDBC data source for the same reason.
Note
You can also define the materialization through a dynamic VDB. To learn how, look at the
[EAP_HOME]/quickstarts/jdg7.1-remote-cache-materialization
quick start.
Important
When DDL metadata changes, the only way to promote the change is restart the Red Hat JBoss Data Grid instance. This also impacts VDB versioning.
Important
You cannot query a cache if it contains multiple pojos.
2.4.1. Materializing a View
Prerequisites
You must have two caches and the
in Red Hat JBoss Data Grid. (The only needs to be created once because it is shared across all the materializations stored in the Red Hat JBoss Data Grid instance.)- Using Teiid Designer, click on a view that is to be materialized.
Note
Make sure the view has a primary key defined as the Red Hat JBoss Data Grid source table needs one for updates. Otherwise, you will need to manually create a primary key on each of the new JDG source tables. - Right-click on the view and click-> .
- Enter theand cache names.Optionally, you can change themodel name and the directory in which the model is saved.
Note
Red Hat JBoss Data Grid restricts the name of the source model because the protobuf code is based on the Java package naming constraints. The model name becomes the package name in the.proto
file. This is due to a limitation in the way that the protobuf is defined. Because Red Hat JBoss Data Grid uses Java, the package name must follow the Java package naming standards. Dashes, for instance, are not allowed. - Click.
- To control the materialization process, update the materialized view extension properties on the above selected view:
- MATVIEW_TTL - to set the refresh rate, in milliseconds
If the materialization management status table is used, then set the following extension properties:- ALLOW_MATVIEW_MANAGEMENT = true
- MATVIEW_STATUS_TABLE = {status table name}
- Create the VDB, using the models needed for materialization.For the JDGSource model, be sure the JNDI is mapped to the JDG data source. Also, enable native queries. To do this, create a translator override for the infinispan-hotrod translator. Click theproperty and set the value to .
- Deploy the VDB.