RoutingDataSource与石英作业

时间:2014-10-07 13:04:22

标签: java hibernate quartz-scheduler

我有一个使用2个数据库的RoutingDataSource。我想让我的一些石英作业使用一个DB和其他DB的其他作业。

我在SPring4中使用Hibnernate4的XML配置。

我的石英豆

<bean id="emailJob" class="com.resolution.scheduler.service.quartz.EmailJob"
        autowire="byName" />

    <bean id="emailJobProxy" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="target" ref="emailJob" />
        <property name="proxyInterfaces" value="java.lang.Runnable" />
        <property name="interceptorNames" value="hibernateInterceptor" />
    </bean>

    <bean id="uniqueEmailJobDetail"
        class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
        <property name="jobClass"
            value="com.kili.StatefulQuartzJob" />
        <property name="jobDataAsMap">
            <map>
                <entry key="batchProcessorName" value="emailJobProxy" />
            </map>
        </property>
        <property name="durability" value="true" />
    </bean>

然后在我用crontrigger之后,所以不需要在这里显示。

Hibernate拦截器:

<bean id="hibernateInterceptor"
        class="org.springframework.orm.hibernate4.support.OpenSessionInterceptor"
        autowire="byName" />

路由数据源:

<bean id="dataSource" class="com.resolution.scheduler.service.DBRoutingDataSource">
        <property name="targetDataSources">
            <map key-type="com.resolution.scheduler.service.DBType">
                 <entry key="READ" value-ref="secondaryDataSource"/>
                <entry key="READWRITE" value-ref="primaryDataSource"/>
            </map>
        </property>
        <property name="defaultTargetDataSource" ref="primaryDataSource"/>
    </bean>

可能的?

0 个答案:

没有答案
相关问题