Flow removal
| Sample application For a flow management sample application refer to the IPF reference application. |
The IPF flow manager tracks the messages that have been processed by IPF applications and allows the replay of these messages for failure recovery or testing purposes. For a complete overview of the IPF flow manager functionality refer to the flow management section of the IPF reference.
Depending on the number of messages tracked the flow manager the flow management database may reach a critical size. Besides options for manual database backups and cleanups IPF also provides a service that purges flows from the flow management database whose age exceeds a certain limit. For example, you can configure the flow purge service to remove all flows from the flow management database that are older than 30 days. Purge schedules are configured with cron expressions. All settings are persistent and purge jobs are re-activated automatically after JVM restarts or crashes.
JMX interface
To configure and interact with the flow purge service, any JMX client can be used. This section explains it based on the JConsole from the Java SDK 6. In order to use the flow removal functionality with the JConsole you must put the commons-flow-<version>.jar file on its classpath. This is explained in section JConsole extension of the flow management chapter. The flow purge service is available via the FlowPurger MBean under the org.openehealth.ipf/service folder on the MBeans tab.
The FlowPurger MBean has the following attributes
| Attribute | Default | Description |
|---|---|---|
| Application | See Configuration | Name of the integration application. Flow purge operations are scoped by application name. |
| DoNotePurgeErrorFlows | false | Set to true if you don't want that flows with status ERROR shall be removed from the database. |
| PurgeFlowOlderThan | 30d | Flows older than the given value will be removed from the database. The default is 30 days (30d). Valid units are seconds (s), minutes (m), hours (h) and days. |
| PurgeSchedule | 0 0 1 * * ? | A cron expression that defines when purge operations are executed. Here's a small tutorial on cron expressions. By default, the schedule is to run a purge operation every day at 1:00 am. |
| PurgeScheduled | false | A read-only attribute that indicates whether the purge scheduler is activated. By default the scheduler is not activated. Below, it will be explained how to activate it. |
The operations schedule, unschedule and execute, provided by the FlowPurger MBean, are described in the following table.
| Operation | Description |
|---|---|
| schedule | Activates the flow purge scheduler for the current application. Once the flow purger has been activated the PurgeScheduled attribute is set to true. |
| unschedule | Deactivates the flow purge scheduler for the current application. Once the flow purger has been deactivated the PurgeScheduled attribute is set to false. |
| execute | Runs a single flow purge operation immediatly for the current application. This operation doesn't influence the PurgeScheduled attribute and can be used for manual (i.e. non-scheduled) flow database cleanups. |
Configuration
The configuration of the FlowPurger MBean is shown in the following Spring application context XML snippet. This configuration is made as part of a complete flow manager configuration.
<bean class="org.springframework.jmx.export.MBeanExporter" lazy-init="false"> <property name="autodetect" value="false"/> <property name="assembler" ref="assembler"/> <property name="namingStrategy" ref="namingStrategy"/> <property name="beans"> <map> <entry key="org.openehealth.ipf.platform:type=service,name=FlowPurger" value-ref="flowPurgerMBean" /> </map> </property> </bean> <bean id="flowPurgerMBean" class="org.openehealth.ipf.commons.flow.jmx.FlowPurgerMBean"> <property name="application" value="tutorial" /> </bean>
The application property value is the default value for the Application MBean property. The latter configuration will configure the FlowPurger MBean with default settings of internaly used Quartz scheduler. You can override these properties by additional configuration of the FlowPurger MBean. For example the following XML snippet sets the threadCount value of Quartz schedulers threadPool to 1 (using defaults would configure the value of 10):
<bean id="flowPurgerMBean" class="org.openehealth.ipf.commons.flow.jmx.FlowPurgerMBean"> <property name="application" value="tutorial" /> <property name="scheduler" ref="purgerScheduler" /> </bean> <bean id="purgerScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false"> <property name="schedulerName" value="FlowPurgerScheduler" /> <property name="quartzProperties"> <props> <prop key="org.quartz.threadPool.threadCount">1</prop> </props> </property> </bean>
