[#ftl attributes={"generated.type":"blueprint.fragment"}]
[#import "templates:object-commons/common-utils.ftl" as utils]

<!--    NOTE: Don't delete! -->
<!--    It needs for quartz because dataSource doesn't has time to registry in jndi-->
<reference id="cache" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=entaxy.esb.cache)"
           availability="mandatory"/>

<bean id="quartz" class="org.apache.camel.component.quartz.QuartzComponent">
    <property name="schedulerFactory" ref="factory"/>
</bean>

<bean id="factory" class="org.quartz.impl.StdSchedulerFactory">
    <argument>
        <props>
            <prop key="org.quartz.scheduler.instanceName">[=objectId]</prop>
            <prop key="org.quartz.scheduler.instanceId">AUTO</prop>

            <prop key="org.quartz.scheduler.jmx.export">true</prop>
            <prop key="org.quartz.scheduler.rmi.export">false</prop>
            <prop key="org.quartz.scheduler.rmi.proxy">false</prop>
            <prop key="org.quartz.scheduler.wrapJobExecutionInUserTransaction">false</prop>
            <prop key="org.quartz.scheduler.skipUpdateCheck">true</prop>

            <prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</prop>
            <prop key="org.quartz.jobStore.isClustered">true</prop>

            [#--     don't work on two nodes at the same time       --]
[#--            [#if properties.runExclusive?? && properties.runExclusive]--]
[#--            <prop key="org.quartz.jobStore.isClustered">true</prop>--]
[#--                [#else]--]
[#--            <prop key="org.quartz.jobStore.isClustered">false</prop>--]
[#--            [/#if]--]

            <prop key="org.quartz.jobStore.clusterCheckinInterval">5000</prop>
            <prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
            <prop key="org.quartz.jobStore.dataSource">cache</prop>
            <prop key="org.quartz.dataSource.cache.jndiURL">osgi:service/entaxy.esb.cache</prop>

            <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
            <prop key="org.quartz.threadPool.threadCount">10</prop>
            <prop key="org.quartz.threadPool.threadPriority">5</prop>
            <prop key="org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread">true</prop>

            <prop key="org.quartz.jobStore.misfireThreshold">60000</prop>
        </props>
    </argument>
</bean>
[#--кластер--]

<route xmlns="http://camel.apache.org/schema/blueprint" id="[=objectId]">
	[#include "templates:model-quartz/init.ftl"]
    [#if properties.routeProperties??]
    [#list properties.routeProperties as key, value]
    <routeProperty key="[=key]" value="[#if value?is_boolean][=value?c][#else][=value][/#if]" />
    [/#list]
    [/#if]
</route>
