Ubik Batch Server FAQ

From UbikWiki

(Difference between revisions)
(How do I setup logging parameters)
Current revision (14:12, 10 January 2014) (edit) (undo)
(What is the difference between SUPER ADMIN and ADMIN in Mail notifications ?)
 

(40 intermediate revisions not shown.)

Line 1:

Line 1:

[[Category:Ubik Batch Server]]
[[Category:Ubik Batch Server]]
== Administration ==
== Administration ==
-
=== How do I setup logging parameters ===
+
=== What are the available parameters for Database Pool declarations ===
-
Log4j is used as logging framework for the Batch Server, see:
+
Ubik Batch Server uses Apache commons-dbcp implementation, see:
-
* [http://logging.apache.org/log4j/1.2/manual.html Short introduction to log4j]
+
* [http://commons.apache.org/dbcp/configuration.html Configuration parameters description]
-
=== How do I setup Network Interface ===
+
=== What validation Query to Use ===
-
What is network interface:
+
Validation Query is mandatory to ensure that a connection returned to client code is valid.
-
* The ability to have 2 or more IP addresses for the same machine
+
It has the following requirements:
 +
* It must be the most efficient query
 +
* It must return ONE and only ONE row
-
To affect on IP to a batch server, add in <UBIK_SERVER_INSTALL_DIR>/config/config.properties:
+
To declare it, use the Ubik Web Controler or open <INSTALL_DIR>/config/datasource.xml and add or modify for your pool the parameter validationQuery:
-
<source lang="text">
+
<source lang="xml">
-
NETWORK_INTERFACE_HOST_NAME=<IP ADDRESS></source>
+
<parameter>
 +
<name>validationQuery</name>
 +
<value>...</value>
 +
</parameter></source>
-
=== What are the available parameters for Database Pool declarations ===
+
{| class="prettytable"
-
Ubik Batch Server used commons-dbcp implementation, see:
+
| <center>'''Database'''</center>
-
* [http://commons.apache.org/dbcp/configuration.html Configuration parameters description]
+
| <center>'''Query'''</center>
 +
|-
 +
| DB2
 +
| SELECT COUNT(*) FROM SYSIBM.SYSTABLES OR SELECT CURRENT TIMESTAMP FROM SYSIBM.SYSDUMMY1
 +
|-
 +
| DERBY
 +
| values(1)
 +
|-
 +
| HSQLDB
 +
| select 1 from INFORMATION_SCHEMA.SYSTEM_USERS
 +
|-
 +
| Informix
 +
| SELECT COUNT(*) FROM SYSTABLES
 +
|-
 +
| Microsoft SQL Server
 +
| SELECT 1
 +
|-
 +
| MySQL
 +
| SELECT 1
 +
|-
 +
| Oracle
 +
| SELECT 1 FROM DUAL
 +
|-
 +
| PointBase
 +
| SELECT COUNT(*) FROM SYSTABLES
 +
|-
 +
| PostgreSQL
 +
| SELECT 1
 +
|-
 +
| Progress
 +
| SELECT COUNT(*) FROM SYSTABLES
 +
|-
 +
| Sybase
 +
| SELECT 1
 +
|}
=== How do I set a JDBC connection property ===
=== How do I set a JDBC connection property ===
-
Use the Ubik Web Controler or open <INSTALL_DIR>/config/datasource.xml and add or modify for your pool the parameter connectionProperties(Format of the string must be [propertyName=property;]*:
+
Use the Ubik Web Controler or open <INSTALL_DIR>/config/datasource.xml and add
 +
or modify for your pool the parameter connectionProperties(Format of the string must be [propertyName=property;]*:
<source lang="xml">
<source lang="xml">
<parameter>
<parameter>
<name>connectionProperties</name>
<name>connectionProperties</name>
-
<value>currentSchema=TEST</value>
+
<value>currentSchema=TEST;implicitCachingEnabled=true;oracle.jdbc.FreeMemoryOnEnterImplicitCache=true</value>
 +
</parameter>
 +
</source>
 +
 
 +
=== My database type is not correctly detected ===
 +
Open <INSTALL_DIR>/config/config.properties and set HIBERNATE_CONFIGURED_DIALECT:
 +
<source lang="text">
 +
# Force a dialect for Hibernate to override auto detection
 +
# For DB2 : com.ubikingenierie.console.persistance.hibernate.DB2ExtendedDialect(*)
 +
HIBERNATE_CONFIGURED_DIALECT=org.hibernate.dialect.MySQL5InnoDBDialect
 +
</source>
 +
(*) : see [http://opensource.atlassian.com/projects/hibernate/browse/HHH-1753 DB2Dialect.getCurrentTimestampSQLFunctionName() uses Oracle syntax]
 +
 
 +
(*) : Useless since version 5.0.1.0 after upgrade to Hibernate 3.2.6
 +
 
 +
=== After a while, Oracle throws this exception: too many open cursors for pool jdbc/console ===
 +
The Oracle JDBC driver doesn't much like to have its prepared statements cached with Hibernate (see http://www.hibernate.org/120.html#A10 Hibernate Platform Specific Issues).
 +
 
 +
Disable PreparedStatement caching for the connection pool.
 +
 
 +
Use Web Controler JDBC Administration page or
 +
open <INSTALL_DIR>config/datasource.xml, goto ''jdbc/console'' declaration
 +
and modifiy parameter poolPreparedStatements:
 +
<source lang="xml">
 +
<parameter>
 +
<name>poolPreparedStatements</name>
 +
<value>false</value>
</parameter></source>
</parameter></source>
 +
 +
=== I have the following messages in the logs ===
 +
<source lang="text">
 +
11:49:27,464 WARN LoadContexts? fail-safe cleanup (collections)... org.hibernate.engine.loading.CollectionLoadContext@cd7045<rs=org.hsqldb.jdbc.jdbcResultSet@192e6b6>
 +
</source>
 +
 +
Nothing's wrong, it's a small issue that will be resolved in future versions of Hibernate, since it's indirectly a logging issue.
 +
You can hide those messages by adding to <INSTALL_DIR>/config/log.properties:
 +
<source lang="text">log4j.category.org.hibernate.engine.loading.LoadContexts=ERROR</source>
===How do I change the retention period for Batches History in Database ===
===How do I change the retention period for Batches History in Database ===
-
Open the file <INSTALL_DIR>/config/config.properties and change:
+
History of batches execution is saved in the Database, a system batch runs every day to cleanup lines older than CLEANUP_DELAY days.
 +
To setup this parameter, open the file <INSTALL_DIR>/config/config.properties and change:
<source lang="text">
<source lang="text">
# Cleanup delay in days for tables BATCH_HEAD and BATCH_TRT
# Cleanup delay in days for tables BATCH_HEAD and BATCH_TRT

Line 55:

Line 131:

Open the file <INSTALL_DIR>/config/extension-manager.xml and add:
Open the file <INSTALL_DIR>/config/extension-manager.xml and add:
<source lang="text">
<source lang="text">
-
<extension className="com.ubikingenierie.console.si3si.extension.SI3SIExtension" >
+
<extension className="com.ubikingenierie.console.si3si.extension.SI3SIExtension" >
-
</extension></source>
+
</extension></source>
===I get the following message on deployment of a big BAR ===
===I get the following message on deployment of a big BAR ===

Line 63:

Line 139:

</source>
</source>
-
Ensure you use the last JDK 5 available version
+
Ensure you use the last JDK 6 available version
Open <INSTALL_DIR>/bin/setEnv.bat or <INSTALL_DIR>/bin/setenv.cfg and set correctly the PermGen space using JAVA_OPTS:
Open <INSTALL_DIR>/bin/setEnv.bat or <INSTALL_DIR>/bin/setenv.cfg and set correctly the PermGen space using JAVA_OPTS:
<source lang="text">
<source lang="text">
-XX:MaxPermSize=128M
-XX:MaxPermSize=128M
 +
-XX:+CMSClassUnloadingEnabled
 +
-XX:+CMSPermGenSweepingEnabled
</source>
</source>
-
=== My database type is not correctly detected ===
+
=== How do I setup logging parameters ===
-
Open <INSTALL_DIR>/config/config.properties and set HIBERNATE_CONFIGURED_DIALECT:
+
Log4j is used as logging framework for the Batch Server, see:
-
<source lang="text">
+
* [http://logging.apache.org/log4j/1.2/manual.html Short introduction to log4j]
-
# Force a dialect for Hibernate to override auto detection
+
-
# For DB2 : com.ubikingenierie.console.persistance.hibernate.DB2ExtendedDialect(*)
+
-
HIBERNATE_CONFIGURED_DIALECT=org.hibernate.dialect.MySQL5InnoDBDialect
+
-
</source>
+
-
(*) : see [http://opensource.atlassian.com/projects/hibernate/browse/HHH-1753 DB2Dialect.getCurrentTimestampSQLFunctionName() uses Oracle syntax]
+
-
=== After a while, Oracle throws this exception: too many open cursors for pool jdbc/console ===
+
=== How do I setup Network Interface ===
-
The Oracle JDBC driver doesn't much like to have its prepared statements cached with Hibernate (see [http://www.hibernate.org/120.html#A10 Hibernate Platform Specific Issues).
+
What is network interface:
 +
* The ability to have 2 or more IP addresses for the same machine
-
Disable PreparedStatement caching for the connection pool.
+
To affect an IP to a batch server, add in <UBIK_SERVER_INSTALL_DIR>/config/config.properties:
-
Use Web Controler JDBC Administration page or
+
-
open <INSTALL_DIR>config/datasource.xml, goto ''jdbc/console'' declaration
+
-
and modifiy parameter poolPreparedStatements:
+
-
<source lang="xml">
+
-
<parameter>
+
-
<name>poolPreparedStatements</name>
+
-
<value>false</value>
+
-
</parameter></source>
+
-
 
+
-
=== I have the following messages in the logs ===
+
<source lang="text">
<source lang="text">
-
11:49:27,464 WARN LoadContexts? fail-safe cleanup (collections)... org.hibernate.engine.loading.CollectionLoadContext@cd7045<rs=org.hsqldb.jdbc.jdbcResultSet@192e6b6>
+
NETWORK_INTERFACE_HOST_NAME=<IP ADDRESS></source>
-
</source>
+
 
-
Nothing's wrong, it's a small issue that will be resolved in future versions of Hibernate, since it's indirectly a logging issue.
 
-
You can hide those messages by adding to <INSTALL_DIR>/config/log.properties:
 
-
<source lang="text">log4j.category.org.hibernate.engine.loading.LoadContexts=ERROR</source>
 
== Deployment ==
== Deployment ==

Line 127:

Line 188:

# Using an Ubik Special Log4j Filter
# Using an Ubik Special Log4j Filter
# Using XML configuration file (Properties files cannot use Filters)
# Using XML configuration file (Properties files cannot use Filters)
-
# Configure an Appender by group and add a Filter "com.ubikingenierie.console.log4j.MDCFilter" with a <param> element which attribute groupName is equal to the logged Group
+
# Configure an Appender by group and add a Filter "com.ubikingenierie.console.log4j.MDCFilter" with a <param> element:
 +
#*<param name="groupName" value="DEMO1"/>
# Add an <appender-ref> under each category
# Add an <appender-ref> under each category

Line 186:

Line 248:

</root>
</root>
</log4j:configuration></source>
</log4j:configuration></source>
 +
 +
=== How to make each Batch log into a different file ? ===
 +
This is done by:
 +
# Using an Ubik Special Log4j Filter
 +
# Using XML configuration file (Properties files cannot use Filters)
 +
# Configure an Appender by group/batch and add a Filter "com.ubikingenierie.console.log4j.MDCFilter" with 2 <param>(s) elements:
 +
#* <param name="groupName" value="DEMO2"/>
 +
#* <param name="batchName" value="ADDRESS_GENERATION_BATCH"/>
 +
# Add an <appender-ref> under each category
 +
 +
Example:
 +
<source lang="xml">
 +
<?xml version="1.0" encoding="UTF-8" ?>
 +
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
 +
<log4j:configuration debug='true' xmlns:log4j='http://jakarta.apache.org/log4j/'>
 +
 +
<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
 +
<param name="File" value="${LOG_ROOT_PATH}/demo-batch/all.log" />
 +
<param name="Append" value="true" />
 +
<param name="MaxFileSize" value="10MB" />
 +
<param name="MaxBackupIndex" value="10" />
 +
<layout class="org.apache.log4j.PatternLayout">
 +
<param name="ConversionPattern" value="%d - %5p - %c: %m%n"/>
 +
</layout>
 +
<!-- Get all other events -->
 +
<filter class="com.ubikingenierie.console.log4j.MDCFilter">
 +
</filter>
 +
</appender>
 +
 +
<appender name="BATCH_DEMO2_ADDRESS_GENERATION_APPENDER" class="org.apache.log4j.RollingFileAppender">
 +
<param name="File" value="${LOG_ROOT_PATH}/demo-batch/address-generation.log" />
 +
<param name="Append" value="true" />
 +
<param name="MaxFileSize" value="10MB" />
 +
<param name="MaxBackupIndex" value="10" />
 +
<layout class="org.apache.log4j.PatternLayout">
 +
<param name="ConversionPattern" value="%d - %5p - %c: %m%n"/>
 +
</layout>
 +
<!-- Special filter with Group name -->
 +
<filter class="com.ubikingenierie.console.log4j.MDCFilter">
 +
<param name="groupName" value="DEMO2"/>
 +
<param name="batchName" value="ADDRESS_GENERATION_BATCH"/>
 +
</filter>
 +
</appender>
 +
 +
<root>
 +
<level value="INFO"/>
 +
<!-- Add appender references -->
 +
<appender-ref ref="BATCH_DEMO2_ADDRESS_GENERATION_APPENDER"/>
 +
<appender-ref ref="FILE"/>
 +
</root>
 +
</log4j:configuration></source>
 +
 +
 +
=== What is the difference between SUPER ADMIN and ADMIN in Mail notifications ? ===
 +
 +
Super Admin:
 +
*They get notified on mail errors
 +
 +
Admin:
 +
*They get notified on every System error:
 +
** Scheduler restore from Database error
 +
** Memory limit reached
 +
** Pool limit reached
 +
** System batches error
 +
** Scheduler delays in execution or scheduler error
 +
** Locked batch errors
 +
** Missed triggers if com.ubikingenierie.console.plugins.MissedBatchesPlugin is configured
 +
** Batch linking errors
 +
** Scheduler Lifecycle events (Start, stopped, paused, resumed)
 +
** Extension registration errors
 +
** Plugin registration errors
 +
*They get notified on batch errors only if no user is configured to receive mails on batch errors
== Development ==
== Development ==
=== How to make my batch send a Mail alert when an exception occurs ===
=== How to make my batch send a Mail alert when an exception occurs ===
-
This is a built-in feature of the Ubik Batch Server, just ensure that your code do not catch silently exceptions
+
This is a built-in feature of the Ubik Batch Server, just ensure that your code does not catch exceptions silently
=== How to modify SQL Query parameters depending on business conditions ===
=== How to modify SQL Query parameters depending on business conditions ===

Line 200:

Line 334:

</source>
</source>
-
=== How to pass data safely between initialize/exec/finalizeBatch ===
+
=== How to pass data safely between executeBeforeData()/executeOnBlock()/executeAfterDataEnd() (initialize/exec/finalizeBatch before 5.0.0.0) ===
You can use BatchExecutionContext object:
You can use BatchExecutionContext object:
<source lang="java">
<source lang="java">

Line 206:

Line 340:

getBatchExecutionContext().getAttribute(...);
getBatchExecutionContext().getAttribute(...);
</source>
</source>
 +
=== How to veto a batch ===
=== How to veto a batch ===
You can veto a batch (stop the execution) in the initialize method invoking method vetoExecution.
You can veto a batch (stop the execution) in the initialize method invoking method vetoExecution.

Line 215:

Line 350:

=== How to check if your batch encountered a problem ===
=== How to check if your batch encountered a problem ===
-
 
+
You can check in the executeAfterDataEnd() method if there was a problem in your batch.
-
You can check in the finalizeBatch method if there was a problem in your treatment.
+
<source lang="java">
<source lang="java">
if (!getBatchExecutionContext().getExceptions().isEmpty())
if (!getBatchExecutionContext().getExceptions().isEmpty())

Line 223:

Line 357:

}
}
</source>
</source>
 +
 +
=== My Batch has trigger dates in the past ===
 +
Ensure coherent Trigge/Batch naming strategy when creating a Batch or Trigger.
 +
A mandatory requirement is that:
 +
* (Batch Group, Batch Name, Trigger Group, Trigger Name)
 +
* (Batch Group, Batch Name) is unique
 +
* (Trigger Group, Trigger Name) is unique
== Authors ==
== Authors ==

Current revision

Contents

Administration

What are the available parameters for Database Pool declarations

Ubik Batch Server uses Apache commons-dbcp implementation, see:

What validation Query to Use

Validation Query is mandatory to ensure that a connection returned to client code is valid. It has the following requirements:

  • It must be the most efficient query
  • It must return ONE and only ONE row

To declare it, use the Ubik Web Controler or open <INSTALL_DIR>/config/datasource.xml and add or modify for your pool the parameter validationQuery:

<parameter>
      <name>validationQuery</name>
      <value>...</value>
</parameter>
Database
Query
DB2 SELECT COUNT(*) FROM SYSIBM.SYSTABLES OR SELECT CURRENT TIMESTAMP FROM SYSIBM.SYSDUMMY1
DERBY values(1)
HSQLDB select 1 from INFORMATION_SCHEMA.SYSTEM_USERS
Informix SELECT COUNT(*) FROM SYSTABLES
Microsoft SQL Server SELECT 1
MySQL SELECT 1
Oracle SELECT 1 FROM DUAL
PointBase SELECT COUNT(*) FROM SYSTABLES
PostgreSQL SELECT 1
Progress SELECT COUNT(*) FROM SYSTABLES
Sybase SELECT 1

How do I set a JDBC connection property

Use the Ubik Web Controler or open <INSTALL_DIR>/config/datasource.xml and add or modify for your pool the parameter connectionProperties(Format of the string must be [propertyName=property;]*:

<parameter>
      <name>connectionProperties</name>
      <value>currentSchema=TEST;implicitCachingEnabled=true;oracle.jdbc.FreeMemoryOnEnterImplicitCache=true</value>
</parameter>

My database type is not correctly detected

Open <INSTALL_DIR>/config/config.properties and set HIBERNATE_CONFIGURED_DIALECT:

# Force a dialect for Hibernate to override auto detection
# For DB2 : com.ubikingenierie.console.persistance.hibernate.DB2ExtendedDialect(*) 
HIBERNATE_CONFIGURED_DIALECT=org.hibernate.dialect.MySQL5InnoDBDialect

(*) : see DB2Dialect.getCurrentTimestampSQLFunctionName() uses Oracle syntax

(*) : Useless since version 5.0.1.0 after upgrade to Hibernate 3.2.6

After a while, Oracle throws this exception: too many open cursors for pool jdbc/console

The Oracle JDBC driver doesn't much like to have its prepared statements cached with Hibernate (see http://www.hibernate.org/120.html#A10 Hibernate Platform Specific Issues).

Disable PreparedStatement caching for the connection pool.

Use Web Controler JDBC Administration page or open <INSTALL_DIR>config/datasource.xml, goto jdbc/console declaration and modifiy parameter poolPreparedStatements:

<parameter>
      <name>poolPreparedStatements</name>
      <value>false</value>
</parameter>

I have the following messages in the logs

11:49:27,464 WARN LoadContexts? fail-safe cleanup (collections)... org.hibernate.engine.loading.CollectionLoadContext@cd7045<rs=org.hsqldb.jdbc.jdbcResultSet@192e6b6>

Nothing's wrong, it's a small issue that will be resolved in future versions of Hibernate, since it's indirectly a logging issue. You can hide those messages by adding to <INSTALL_DIR>/config/log.properties:

log4j.category.org.hibernate.engine.loading.LoadContexts=ERROR

How do I change the retention period for Batches History in Database

History of batches execution is saved in the Database, a system batch runs every day to cleanup lines older than CLEANUP_DELAY days. To setup this parameter, open the file <INSTALL_DIR>/config/config.properties and change:

# Cleanup delay in days for tables BATCH_HEAD and BATCH_TRT
CLEANUP_DELAY=30

How do I setup my mail server parameters

Open the file <INSTALL_DIR>/config/mail.xml and change:

<?xml version="1.0" encoding="UTF-8"?>
<!-- #Release @VERSION@ at @DATE@ -->
<mail>
	<mailHost>smtp.ubik-ingenierie.com</mailHost>
	<mailer>UbikBatch</mailer>
	<mailPort>25</mailPort>
</mail>

How do I declare my custom plugin

Open the file <INSTALL_DIR>/config/plugin-manager.xml and add:

<plug-in className="com.ubikingenierie.console.monitoring.plugin.HealthMonitorPlugin"  
        id="com.ubikingenierie.console.monitoring.plugin.HealthMonitorPlugin">
          <set-property property="propertyOfClass" value="valueToSet"></set-property>
...
          <set-property property="otherValue" value="3000000"></set-property>
</plug-in>

How do I declare my custom extension

Open the file <INSTALL_DIR>/config/extension-manager.xml and add:

<extension className="com.ubikingenierie.console.si3si.extension.SI3SIExtension" >
</extension>

I get the following message on deployment of a big BAR

java.lang.OutOfMemoryError: PermGen space

Ensure you use the last JDK 6 available version Open <INSTALL_DIR>/bin/setEnv.bat or <INSTALL_DIR>/bin/setenv.cfg and set correctly the PermGen space using JAVA_OPTS:

-XX:MaxPermSize=128M
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled

How do I setup logging parameters

Log4j is used as logging framework for the Batch Server, see:

How do I setup Network Interface

What is network interface:

  • The ability to have 2 or more IP addresses for the same machine

To affect an IP to a batch server, add in <UBIK_SERVER_INSTALL_DIR>/config/config.properties:

NETWORK_INTERFACE_HOST_NAME=<IP ADDRESS>


Deployment

My BAR fails to deploy on the Batch server

  • If you have the Ubik Web Controler, go to Deployment > Click on the BAR Name, deployment errors will appear
  • If you don't have it, go to folder <INSTALL_DIR>/batches-deploy-failure and open file <BAR_NAME-version>.bar.failure, it

will contain the main cause of error

  • If you don't find any error, go to log folder

How do I customize mapping with Cold Deployment feature

  • Create in the same folder dedicated to Cold Deployment (identified by property COLD_DEPLOYMENT_DIR

(defaults to <INSTALL_DIR>/batches-cold-deploy)) that contains your BAR a file called <BAR_ID>-binding.xml that will contain the mapping:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bar-resources 
          PUBLIC "-//Ubik-Ingenierie //DTD BAR Binding Resource Configuration 1.0//EN" 
          "http://www.ubik-ingenierie.com/consolebatch/config/bar-binding.dtd">
<bar-resources>
     <bar-resource nameinbar="Logical Name" boundname="Physical Name" />
...
     <bar-resource nameinbar="Logical Name 1" boundname="Physical Name 2" />
</bar-resources>

Configuration

How to make each Batch group log into a different file ?

This is done by:

  1. Using an Ubik Special Log4j Filter
  2. Using XML configuration file (Properties files cannot use Filters)
  3. Configure an Appender by group and add a Filter "com.ubikingenierie.console.log4j.MDCFilter" with a <param> element:
    • <param name="groupName" value="DEMO1"/>
  4. Add an <appender-ref> under each category

Example:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug='true' xmlns:log4j='http://jakarta.apache.org/log4j/'>
 
	<appender name="FILE" class="org.apache.log4j.RollingFileAppender"> 
		<param name="File" value="${LOG_ROOT_PATH}/demo-batch/all.log" /> 
		<param name="Append" value="true" /> 
		<param name="MaxFileSize" value="10MB" />
		<param name="MaxBackupIndex" value="10" />		
		<layout class="org.apache.log4j.PatternLayout"> 
			<param name="ConversionPattern" value="%d - %5p - %c: %m%n"/> 
		</layout> 
		<!-- Get all other events -->
		<filter class="com.ubikingenierie.console.log4j.MDCFilter">
		</filter>
	</appender>
 
	<!-- FILE -->
	<appender name="GROUP_DEMO1_APPENDER" class="org.apache.log4j.RollingFileAppender"> 
		<param name="File" value="${LOG_ROOT_PATH}/demo-batch/group-demo1.log" /> 
		<param name="Append" value="true" /> 
		<param name="MaxFileSize" value="10MB" />
		<param name="MaxBackupIndex" value="10" />		
		<layout class="org.apache.log4j.PatternLayout"> 
			<param name="ConversionPattern" value="%d - %5p - %c: %m%n"/> 
		</layout> 
		<!-- Special filter with Group name -->
		<filter class="com.ubikingenierie.console.log4j.MDCFilter">
			<param name="groupName" value="DEMO1"/>			
		</filter>
	</appender>
 
	<appender name="GROUP_DEMO2_APPENDER" class="org.apache.log4j.RollingFileAppender"> 
		<param name="File" value="${LOG_ROOT_PATH}/demo-batch/group-demo2.log" /> 
		<param name="Append" value="true" /> 
		<param name="MaxFileSize" value="10MB" />
		<param name="MaxBackupIndex" value="10" />		
		<layout class="org.apache.log4j.PatternLayout"> 
			<param name="ConversionPattern" value="%d - %5p - %c: %m%n"/> 
		</layout> 
		<!-- Special filter with Group name -->
		<filter class="com.ubikingenierie.console.log4j.MDCFilter">
			<param name="groupName" value="DEMO2"/>			
		</filter>
	</appender>
 
	<root>
		<level value="INFO"/>
		<!-- Add appender references -->
		<appender-ref ref="GROUP_DEMO2_APPENDER"/> 
		<appender-ref ref="GROUP_DEMO1_APPENDER"/> 
		<appender-ref ref="FILE"/> 
	</root> 
</log4j:configuration>

How to make each Batch log into a different file ?

This is done by:

  1. Using an Ubik Special Log4j Filter
  2. Using XML configuration file (Properties files cannot use Filters)
  3. Configure an Appender by group/batch and add a Filter "com.ubikingenierie.console.log4j.MDCFilter" with 2 <param>(s) elements:
    • <param name="groupName" value="DEMO2"/>
    • <param name="batchName" value="ADDRESS_GENERATION_BATCH"/>
  4. Add an <appender-ref> under each category

Example:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug='true' xmlns:log4j='http://jakarta.apache.org/log4j/'>
 
	<appender name="FILE" class="org.apache.log4j.RollingFileAppender"> 
		<param name="File" value="${LOG_ROOT_PATH}/demo-batch/all.log" /> 
		<param name="Append" value="true" /> 
		<param name="MaxFileSize" value="10MB" />
		<param name="MaxBackupIndex" value="10" />		
		<layout class="org.apache.log4j.PatternLayout"> 
			<param name="ConversionPattern" value="%d - %5p - %c: %m%n"/> 
		</layout> 
		<!-- Get all other events -->
		<filter class="com.ubikingenierie.console.log4j.MDCFilter">
		</filter>
	</appender>
 
	<appender name="BATCH_DEMO2_ADDRESS_GENERATION_APPENDER" class="org.apache.log4j.RollingFileAppender"> 
		<param name="File" value="${LOG_ROOT_PATH}/demo-batch/address-generation.log" /> 
		<param name="Append" value="true" /> 
		<param name="MaxFileSize" value="10MB" />
		<param name="MaxBackupIndex" value="10" />		
		<layout class="org.apache.log4j.PatternLayout"> 
			<param name="ConversionPattern" value="%d - %5p - %c: %m%n"/> 
		</layout> 
		<!-- Special filter with Group name -->
		<filter class="com.ubikingenierie.console.log4j.MDCFilter">
			<param name="groupName" value="DEMO2"/>
			<param name="batchName" value="ADDRESS_GENERATION_BATCH"/>			
		</filter>
	</appender>
 
	<root>
		<level value="INFO"/>
		<!-- Add appender references -->
		<appender-ref ref="BATCH_DEMO2_ADDRESS_GENERATION_APPENDER"/> 
		<appender-ref ref="FILE"/> 
	</root> 
</log4j:configuration>


What is the difference between SUPER ADMIN and ADMIN in Mail notifications ?

Super Admin:

  • They get notified on mail errors

Admin:

  • They get notified on every System error:
    • Scheduler restore from Database error
    • Memory limit reached
    • Pool limit reached
    • System batches error
    • Scheduler delays in execution or scheduler error
    • Locked batch errors
    • Missed triggers if com.ubikingenierie.console.plugins.MissedBatchesPlugin is configured
    • Batch linking errors
    • Scheduler Lifecycle events (Start, stopped, paused, resumed)
    • Extension registration errors
    • Plugin registration errors
  • They get notified on batch errors only if no user is configured to receive mails on batch errors

Development

How to make my batch send a Mail alert when an exception occurs

This is a built-in feature of the Ubik Batch Server, just ensure that your code does not catch exceptions silently

How to modify SQL Query parameters depending on business conditions

Sometimes Sql parameters change depending on some conditions that cannot be computed before execution, to enable this, Ubik Batch server offers a way to do it:

  1. Use SqlParameter in DaoSqlBatchStart or SqlBatchStart
  2. In Traitement#initialize() or BaseBatch#executeBeforeData, modify the parameters using:
getBatchExecutionContext().setSqlBatchStartParameters(new SqlParameter[]{...});

How to pass data safely between executeBeforeData()/executeOnBlock()/executeAfterDataEnd() (initialize/exec/finalizeBatch before 5.0.0.0)

You can use BatchExecutionContext object:

getBatchExecutionContext().setAttribute(...);
getBatchExecutionContext().getAttribute(...);

How to veto a batch

You can veto a batch (stop the execution) in the initialize method invoking method vetoExecution. For example if some conditions for execution are not met.

vetoExecution("NOT A BUG! The treatment has been stopped by batch, functional flag is disabled");

If you want to stop a batch once you are in the exec method, you will have to manage by an applicative way.

How to check if your batch encountered a problem

You can check in the executeAfterDataEnd() method if there was a problem in your batch.

if (!getBatchExecutionContext().getExceptions().isEmpty())
{
    // do something
}

My Batch has trigger dates in the past

Ensure coherent Trigge/Batch naming strategy when creating a Batch or Trigger. A mandatory requirement is that:

  • (Batch Group, Batch Name, Trigger Group, Trigger Name)
  • (Batch Group, Batch Name) is unique
  • (Trigger Group, Trigger Name) is unique

Authors

  • Philippe Mouawad

History

  • Page created by Pmouawad, 18 November 2007: New page: === Authors === * Philippe Mouawad === History ===
  • Last modified by Pmouawad, 10 January 2014: /* What is the difference between SUPER ADMIN and ADMIN in Mail notifications ? */
Personal tools