Skip to main content

DBReader Module


Database Reader Module

Database Reader module can be used in any application hosted in the ProconTEL 4 environment which is using components pipeline builder. DB Reader allows the application to read information from the database and produce data for the pipeline. Currently, DB Reader works only in polling mode.

Table of Contents

Definition​

Namespace: ProconTel.Components.Communication.DBReader

Assembly: ProconTel.Components.Communication.DBReader.dll

Module Installation​

To install a DBReader module into project, Nuget Package Manager Console can be used:

Install-Package ProconTel.Components.Communication.DBReader -ProjectName <ProjectName>

Nuget package can be found in the repository: https://nexus.macrix.eu/repository/pct2022/

(back to top)

Available Pipeline extensions and configuration methods​

The module provides one extensions method that allows inject DBReader module support to application.

public static TcpConnectionSyntax AddDatabaseReader(new DbReaderConfiguration()
{
ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=XE)));User Id=<USER>;Password=<PASSWORD>>;",
Provider = DbProvider.Oracle,
RetryPolicy = new RetryPolicyConfiguration() { MaxDelayInSeconds = 30, RetryCount = 10 }
});

ConnectionString is used to define details about the database connection.

DbProvider allows you to specify which database the DbReader should connect to. The following databases are currently supported:

DatabaseActive
Oracle[x]
MSSQl[x]
PostgreSQL[x]
MySQL[]

AddDatabaseReader contains a number of optional parameters that can be passed when needed:

ParameterNameDefaultDescription
ReaderNameReaderThe name of the current module, necessary when more than one reader reads data from the database.
TelegramTableNameTCP_TEL_HISTThe name of the Table from which messages should be read.
ReadTelegramTableNameTCP_TEL_HIST_READ_ROWSThe name of the table in which the reader saves the telegrams it has already read.
DataColumnDATAThe name of the column that contains the data.
PollingActivatedtrueFlag whether polling is active.
PollingInterval15000Polling reread time.
PollingComparisonDateColumnModif_LastColumn name that is compared when reading telegrams in polling mode.
ReaderIdColumnREADER_IDThe name of the column where the name of the reader is stored.
TelegramTableIdColumnID_SEQThe name of the column where the telegram ID is stored in Telegram Table.
ReadTelegramTableIdColumnROW_IDThe name of the column where the telegram ID is stored in Read Telegram Table.

(back to top)

Example of usage in code​

This example shows use of the DBReader module in conjunction with Oracle Database. Module opens a connection to the database and reads new messages from Telegram Table. After the message is processed correctly, Reader updates the data in the Read Telegram Table to avoid duplication.

Read messages are sent to the pipeline.

flow.AddDatabaseReader(new DbReaderConfiguration()
{
ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=XE)));User Id=<USER>;Password=<PASSWORD>>;",
Provider = DbProvider.Oracle,
RetryPolicy = new RetryPolicyConfiguration() { MaxDelayInSeconds = 30, RetryCount = 10 }
})
.MapXmlToBinary().UseXsbtRules(opts => opts.XsbtFolderPath = builder.Configuration["Xsbt:XsbtsFolderPath"])
.StartTcpServer(55401).UseXsbtHeaderDefinition(opts => {
opts.XsbtHeaderDefinitionPath = builder.Configuration["Xsbt:HeaderDefinitionPath"];
opts.LenghtFieldName = builder.Configuration["Xsbt:HeaderLenghtFieldName"];
opts.IdFieldName = builder.Configuration["Xsbt:HeaderIdFieldName"];
}).AsCustomerOnly();

(back to top)