Older versionVersion 2.7SolutionsHow to add billing to PhenixID Server, using event bridge module

How to add billing to PhenixID Server, using event bridge module

This document describes how to add and enable the event bridge module to PhenixID Server.

Event bridge listens for events and sends them to PCS, based on regex filter.

The reader of this document should have some basic knowledge about PhenixID Server.

System requirements

  • PhenixID Server installed.
  • PhenixID Server must be able to communicate with PCS service. Use the test tool and perform license check to verify communincation.

Overview

The event bridge module is responsible for sending events to PCS.

This document will describe how to add this module to PhenixID Server configuration.

It's also recommended to add logging for billing to local disk in seperate log file. An example of this can be found below.

The following billing events exist:
- EVT_004900 - "Successfully authenticated with Swedish BankID"
- EVT_004901 - "Swedish BankID authentication cancelled"
- EVT_004902 - "Successfully signed with Swedish BankID"

We will make changes to the configuration files phenix-store.json and log4j2.xml, so please make sure to have a backup  of these files.

Instruction

Login to the configuration portal and go to the tab "Advanced".
Now click on the pen next to "Modules" and add the following configuration:

{
    "module": "com.phenixidentity~phenix-events-billing",
    "enabled": "true",
    "id" : "billing",
    "config": {
        "filter": ".*EVT_0049[0-9]{2}.*"
    }
}

Explanation of possible configuration parameters:
filter - Regex filter matching events to bridge (Default: .*)
path - Path to file storing events until successfully bridged (Default: data/events)
poll_intervall - Number of milliseconds between checking for new events (Default: 200)
send_intervall - Number of milliseconds between event bridge send operations (Default: 500)
retry_intervall - Number of milliseconds between retries in case of error (Default: 600000)
logger -
 Name of Log4j logger used for local logging (Default: BILLING)
enableHttp - Http is not used with this module, so this value should always be set to false

To save the configuration press "Stage changes" and then "Commit changes". 


To enable loading of the module, in configuration portal, on the tab "Advanced": 

- Click on the pen to the right of NODE_GROUPS

- Add the module "billing" to module_refs.

- Click Stage Changes and Commit Changes

Add configuration for local billing logging

Configuration for logging is done in the file /config/log4j2.xml.

Add the following configuration for local logging.

<RollingFile
    name="BILLING"
    fileName="logs/billing.log"
    filePattern="logs/billing.%date{yyyy-MM-dd}.log"
    append="true">
    <PatternLayout pattern="%d [%c{1}]  %p: %m%n"/>
    <Policies>
        <TimeBasedTriggeringPolicy interval="1"/>
    </Policies>
</RollingFile>

<Logger name="BILLING" level="INFO" additivity="false">
        <AppenderRef ref="BILLING"/>
</Logger>

The file log4j2.xml should now look similar to this:

<Configuration monitorInterval="30">
    <Appenders>
        <Console name="CONSOLE" target="SYSTEM_OUT">
            <PatternLayout pattern="%d [%c{1}]  %p: %m%n"/>
        </Console>
        <RollingFile
                name="FILE"
                fileName="logs/server.log"
                filePattern="logs/server.%date{yyyy-MM-dd}.log"
                append="true">
            <PatternLayout pattern="%d [%c{1}]  %p: %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1"/>
            </Policies>
        </RollingFile>
        <RollingFile
                name="EVENT"
                fileName="logs/event.log"
                filePattern="logs/event.%date{yyyy-MM-dd}.log"
                append="true">
            <PatternLayout pattern="%d [%c{1}]  %p: %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1"/>
            </Policies>
        </RollingFile>
		<RollingFile
                name="BILLING"
                fileName="logs/billing.log"
                filePattern="logs/billing.%date{yyyy-MM-dd}.log"
                append="true">
            <PatternLayout pattern="%d [%c{1}]  %p: %m%n"/>
            <Policies>
                <TimeBasedTriggeringPolicy interval="1"/>
            </Policies>
        </RollingFile>
    </Appenders>
    <Loggers>
        <AsyncLogger name="com.phenixidentity" level="INFO"/>
        <AsyncLogger name="io.netty" level="WARN"/>
        <AsyncLogger name="com.hazelcast" level="WARN"/>
        <AsyncLogger name="org.vertx" level="WARN"/>
        <AsyncLogger name="com.orientechnologies" level="WARN"/>
        <Logger name="EVENT" level="INFO" additivity="false">
            <AppenderRef ref="EVENT"/>
        </Logger>
		<Logger name="BILLING" level="INFO" additivity="false">
            <AppenderRef ref="BILLING"/>
        </Logger>
        <Root level="WARN">
            <AppenderRef ref="FILE"/>
        </Root>
    </Loggers>
</Configuration>