Example: Configuring the RAP Adapter

Set the configuration, publisher, and RDS template files to configure the RAP adapter for communication between RAP and Event Stream Processor.

  1. Set the $RAPOUT_HOME environment variable to $ESP_HOME/adapters/rap_out directory.
  2. Navigate to the $RAPOUT_HOME directory.
  3. Create a project defining the streams you want to publish to RAP, and save it to a file named model.ccl in the $ESP_HOME/bin directory.
  4. Start Event Stream Processor.
    Windows:
    1. Start the example cluster.
      cd %ESP_HOME%\cluster\nodes\node1
        %ESP_HOME%\bin\esp_server --cluster-node node1.xml
    2. Compile CCL to create CCX.
      %ESP_HOME%\bin\esp_compiler -i model.ccl -o model.ccx
    3. Deploy the project on the cluster.
      %ESP_HOME%\bin\esp_cluster_admin" --uri=esp://localhost:19011 --username=sybase --password=sybase --add_project --workspace-name=w1 --project-name=p1 --ccx=model.ccx
    4. Start the deployed project on the cluster.
      %ESP_HOME%\bin\esp_cluster_admin" --uri=esp://localhost:19011 --username=sybase --password=sybase --start_project --workspace-name=w1 --project-name=p1
    UNIX:
    1. Start the example cluster.
      cd $ESP_HOME/cluster/nodes/node1
        $ESP_HOME/bin/esp_server --cluster-node node1.xml
    2. Compile CCL to create CCX.
      $ESP_HOME/bin/esp_compiler -i model.ccl -o model.ccx
    3. Deploy the project on the cluster.
      $ESP_HOME/bin/esp_cluster_admin" --uri=esp://localhost:19011 --username=sybase --password=sybase --add_project --workspace-name=w1 --project-name=p1 --ccx=model.ccx
    4. Start the deployed project on the cluster.
      $ESP_HOME/bin/esp_cluster_admin" --uri=esp://localhost:19011 --username=sybase --password=sybase --start_project --workspace-name=w1 --project-name=p1
  5. In the $RAPOUT_HOME/config directory, modify the espfeedhandler.xml configuration file to specify which Event Stream Processor streams are providing data to RAP. For example, the file below configures the adapter to publish a single stream called Trades:
    <?xml version="1.0" encoding="UTF-8"?>
    <ESPFeedHandler>
            <Logger>
                    <LogLevel>warning</LogLevel>
                    <LogFile>ESPFeedHandler.log</LogFile>
            </Logger>
            <MainCommandControlServer>
           <MainCCHost>127.0.0.1</MainCCHost>
           <MainCCPort>19011</MainCCPort>
           <Workspace>w1</Workspace>
           <Project>p1</Project>
            </MainCommandControlServer>
            <StandbyCommandControlServer>
                    <StandbyCCHost/>
                    <StandbyCCPort/>
            </StandbyCommandControlServer>
            <UseEncryption/>
            <ESPAuthentication>
                    <User></User>
                    <Password></Password>
            </ESPAuthentication>
            <Subscription>
                    <ProjectionSQL></ProjectionSQL>
                    <SubscriptionStream>Trades</SubscriptionStream>
                    <RAPMessageType>69</RAPMessageType>
            </Subscription>
    </ESPFeedHandler>
  6. In $RAPOUT_HOME/config, modify the existing publisher file to specify the multicast address used by the RAP subscriber. For example:
    <?xml version="1.0" encoding="UTF-8"?>
    <Publisher>
            <Logger>
                    <LogLevel>debug</LogLevel>
                    <LogFile>Publisher.log</LogFile>
            </Logger>
        <NumMessageBuffers>1</NumMessageBuffers>
        <NumPacketBuffers>10000</NumPacketBuffers>
            <MessageFlushInterval>1</MessageFlushInterval>
            <LatencyCheckInterval>30</LatencyCheckInterval>
            <AdminChannel>
            <LocalInterface>testmachine</LocalInterface>
            <AdminPort>5002</AdminPort>
            </AdminChannel>
            <ResendChannel>
            <ResendPort>5103</ResendPort>
            </ResendChannel>
    
            <TimeToLive>1</TimeToLive>
    
            <DataStreamChannelList>
            <DataStreamChannel>
                <ChannelName>test2</ChannelName>
                <LocalInterface>127.0.0.1</LocalInterface>
                <IPAddress>224.0.2.0</IPAddress>
                <Port>5050</Port>
            </DataStreamChannel>
            <DataStreamChannel>
                <ChannelName>test1</ChannelName>
                <LocalInterface>127.0.0.1</LocalInterface>
                <IPAddress>224.0.2.0</IPAddress>
                <Port>5800</Port>
            </DataStreamChannel>
            </DataStreamChannelList>
    </Publisher>
    
  7. In $RAPOUT_HOME/templates, create an RDS template for each stream you want to publish to RAP.
    <?xml version="1.0" encoding="UTF-8"?>
    
    <Template xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../template.xsd">
    	<MessageDefnList>
    		<MessageDefn>
    			<MessageDesc>Split Event</MessageDesc>
    			<MessageType>70</MessageType>
    			<DestTableName>rapout2</DestTableName>
    			<FieldDefnList>
                    <FieldDefn>
                        <FieldName>integer</FieldName>
                        <IntegerField>
                            <IntegerDataType>sint32</IntegerDataType>
                        </IntegerField>
                        <DestColumnName>int16</DestColumnName>
                    </FieldDefn>
    		<FieldDefn>
    			<FieldName>string</FieldName>
    			<StringField/>
    			<DestColumnName>string</DestColumnName>
    		</FieldDefn>
                    <FieldDefn>
                        <FieldName>int32</FieldName>
                        <IntegerField>
                            <IntegerDataType>sint32</IntegerDataType>
                        </IntegerField>
                        <DestColumnName>int32test</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>int64</FieldName>
                        <IntegerField>
                            <IntegerDataType>sint64</IntegerDataType>
                        </IntegerField>
                        <DestColumnName>int64test</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>double</FieldName>
                            <DecimalField>
                                <Precision>18</Precision>
                                <Scale>4</Scale>
                            </DecimalField>
                        <DestColumnName>doubletest</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>4</Scale>
                        </DecimalField>
                        <DestColumnName>money_test</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(1)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>1</Scale>
                        </DecimalField>
                        <DestColumnName>money1</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(2)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>2</Scale>
                        </DecimalField>
                        <DestColumnName>money2</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(3)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>3</Scale>
                        </DecimalField>
                        <DestColumnName>money3</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(4)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>4</Scale>
                        </DecimalField>
                        <DestColumnName>money4</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(5)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>5</Scale>
                        </DecimalField>
                        <DestColumnName>money5</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(6)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>6</Scale>
                        </DecimalField>
                        <DestColumnName>money6</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(7)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>7</Scale>
                        </DecimalField>
                        <DestColumnName>money7</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(8)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>8</Scale>
                        </DecimalField>
                        <DestColumnName>money8</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(9)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>9</Scale>
                        </DecimalField>
                        <DestColumnName>money9</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(10)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>10</Scale>
                        </DecimalField>
                        <DestColumnName>money10</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(11)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>11</Scale>
                        </DecimalField>
                        <DestColumnName>money11</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(12)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>12</Scale>
                        </DecimalField>
                        <DestColumnName>money12</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(13)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>13</Scale>
                        </DecimalField>
                        <DestColumnName>money13</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(14)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>14</Scale>
                        </DecimalField>
                        <DestColumnName>money14</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>money(15)</FieldName>
                        <DecimalField>
                            <Precision>18</Precision>
                            <Scale>15</Scale>
                        </DecimalField>
                        <DestColumnName>money15</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>interval</FieldName>
                        <IntegerField>
                            <IntegerDataType>sint64</IntegerDataType>
                        </IntegerField>
                        <DestColumnName>interval</DestColumnName>
                    </FieldDefn>                 
                    <FieldDefn>
                        <FieldName>bigdatetime</FieldName>
                        <DateTime2Field/>
                        <DestColumnName>bigdatetime</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>date</FieldName>
                        <DateTimeField/>
                        <DestColumnName>date_test</DestColumnName>
                    </FieldDefn>
                    <FieldDefn>
                        <FieldName>timestamp</FieldName>
                        <DateTimeField/>
                        <DestColumnName>timestamp_test</DestColumnName>
                    </FieldDefn>
    	</FieldDefnList>
    		</MessageDefn>
    	</MessageDefnList>
    </Template>
    
    Ensure that the template file is copied to the RAP subscriber template directory