Striim 3.9.4 / 3.9.5 documentation

HazelcastWriter

Writes to Hazelcast maps.

The following describes use of HazelcastWriter with an input stream of a user-defined type. For use with a CDC reader or DatabaseReader input stream of type WAEvent, see Replicating Oracle data to a Hazelcast "hot cache".

property

type

default value

notes

BatchPolicy

java.lang.String

eventCount:10000, Interval:30

This property is used only when the Mode is InitialLoad.

The batch policy includes eventcount and interval (see Setting output names and rollover / upload policies for syntax). Events are buffered locally on the Striim server and sent as a batch to the target every time either of the specified values is exceeded. When the app is stopped, any remaining data in the buffer is discarded. To disable batching, set to EventCount:1,Interval:0.

With the default setting, data will be written every 30 seconds or sooner if the buffer accumulates 10,000 events.

ClusterName

java.lang.String

the Hazelcast cluster group-name value, if required

ConnectionURL

java.lang.String

<IP address>:<port> of the Hazelcast server (cannot be on the same host as Striim)

Maps

java.lang.String

With an input stream of a user-defined type, the name of the Hazelcast map to write to. See the example below.

With an input stream of type WAEvent, <source table 1 name>,<Hazelcast map 1 name>;<source table 2 name>,<Hazelcast map 2 name>;... . For an example, see Replicating Oracle data to a Hazelcast "hot cache".

Mode

java.lang.String

incremental

With an input stream of a user-defined type, do not change the default. See Replicating Oracle data to a Hazelcast "hot cache" for more information.

ORMFile

java.lang.String

fully qualified filename of the Hazelcast object-relational mapping (ORM) file

Password

com.webaction. security. Password

the group-password value corresponding to the group-name value specified in ClusterName

To use HazelcastWriter, you must:

  1. Write a Java class defining the Plain Old Java Objects (POJOs) corresponding to the input stream's type (see http://stackoverflow.com/questions/3527264/how-to-create-a-pojo for more information on POJOs), compile the Java class to a .jar file, copy it to the Striim/lib directory of each Striim server that will run the HazelcastWriter target, and restart the server. If the class is missing, a "ClassNotFound" error will be written to the log.

  2. Write an XML file defining the object-relational mapping to be used to map stream fields to Hazelcast maps (the "ORM file") and save it in a location accessible to the Striim cluster.

The following example assumes the following stream definition:

CREATE TYPE invType (
  SKU String key,
  STOCK String,
  NAME String,
  LAST_UPDATED DateTime);
CREATE STREAM invStream OF invType;

The following Java class defines a POJO corresponding to the stream:

package com.customer.vo;
import java.io.Serializable;
import java.util.Date;
public class ProductInvObject  implements Serializable {

   public long sku = 0;
   public double stock = 0;
   public String name = null;
   public Date lastUpdated = null;

   public ProductInvObject ( ) {    }

   @Override
   public String toString() {
       return "sku : " + sku + ", STOCK:" + stock + ", NAME:" + name + ", LAST_UPDATED:" + lastUpdated  ;
   }
}

The following ORM file maps the input stream fields to Hazelcast maps (see the discussion of data type support below):

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm" version="2.4">

    <entity name="prodcInv" class="com.customer.vo.ProductInvObject" >  
        <table name="MYSCHEMA.INV"/>
        <attributes>
            <id name ="sku" attribute-type="long"  >
                <column nullable="false" name="SKU" />
            </id>
            <basic name="stock" attribute-type="double" >
                <column nullable="false" name="STOCK"  />
            </basic>
            <basic name="name" attribute-type="String" >
                <column  name="NAME" />
            </basic>
            <basic name="lastUpdated"  attribute-type="java.util.Date" >
                <column name="LAST_UPDATED" />
            </basic>
        </attributes>
    </entity>

</entity-mappings>

Data types are converted as specified in the OML file. Supported types on the Hazelcast side are:

  • binary (byte[])

  • Character, char

  • Double, double

  • Float, float

  • int, Integer

  • java.util.Date

  • Long, long

  • Short, short

  • String

Assuming that the ORM file has been saved to Striim/Samples/TypedData2HCast/invObject_orm.xml, the following TQL will write the input stream events to Hazelcast:

CREATE TARGET HazelOut USING HazelcastWriter (
  ConnectionURL: '203.0.1113.50:5702',
  ormFile:"Samples/TypedData2HCast/invObject_orm.xml",
  mode: "incremental",
  maps: 'invCache'
)
INPUT FROM invStream;

If the application crashes, after recovery (see Recovering applications) the Hazelcast map may contain some duplicate events. If Hazelcast crashes, stop the application, restart Hazelcast, then restart the application.