WPS and PostgreSQL


How to use PostgreSQL for request/response/result storage

the 52°North WPS has built-in capabilities to store each request, the respective response and the result of the process. This can be used e.g. for debugging the service. The default storage mechanism that the 52°North WPS framework uses is a file-based approach, where requests, responses and results are stored as files in a temporary directory. As an alternative, a PostgreSQL database can be used for the same purpose. Here we will show you what needs to be done for this.

Prerequisites

Running PostgreSQL instance. WPS 3.6.2 or later. Note that the PostgreSQL storage currently is not working with WPS 4.0. We are working on a fix.

WPS settings

In the wps_config.xml or wps_config_geotools.xml replace the following lines (they can be found near the end of the file):

      <Database>
         <!-- NOTE: database wipe is only implemented for the FlatFileDatabase (the default) -->
         <!-- enable database wiping base on values below -->
         <Property name="wipe.enabled" active="true">true</Property>
         <!-- scans database every 1 hour -->
         <Property name="wipe.period" active="true">PT1H</Property>
         <!-- deletes files older than 7 days -->
         <Property name="wipe.threshold" active="true">P7D</Property>
      </Database>

with the following (this can be found futher down in the file):

            <Database>
                <Property active="true" name="databaseClass">org.n52.wps.server.database.PostgresDatabase</Property>
                <Property active="true" name="databaseName">postgres</Property>
                <Property active="true" name="databasePath">//localhost:5432</Property>
                <Property active="true" name="username">username</Property>
                <Property active="true" name="password">password</Property>
                <Property active="true" name="saveResultsToDb">false</Property>
                <Property name="wipe.enabled" active="true">true</Property>
                <Property name="wipe.period" active="true">PT1H</Property>
                <Property name="wipe.threshold" active="true">P7D</Property>
            </Database>

Replace the values of the properties databaseName, databasePath, username and password with the respective values from your PostgreSQL database. If you set the property saveResultsToDb to true, also the process results will be stored in the database. Note that this is not suited well for large results. Now you need to download the JDBC driver for PostgreSQL, e.g. from here: pgjdbc driver. Drop the jar file in the WEB-INF/lib folder of your WPS webapp. Thats it, you should be set to store the WPS requests/responses (and results) in your PostgreSQL database.
Topic revision: r2 - 12 Jan 2018, BenjaminPross
Legal Notice | Privacy Statement


This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Wiki? Send feedback