All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tex.aktivecortex-core.1.3.0.source-code.aktivecortex-core-default.xml Maven / Gradle / Ivy

<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (C) 2012-2013. Aktive Cortex 
    
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    
     http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:axon="http://www.axonframework.org/schema/core"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.axonframework.org/schema/core http://www.axonframework.org/schema/axon-core-1.3.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">


    <aop:aspectj-autoproxy proxy-target-class="true" />

	<axon:annotation-config command-bus="commandBus" event-bus="eventBus"/>

	<!-- ================================================ -->
	<!-- JMS RESOURCES (Command Queue - Event Topic)      -->
	<!-- N.B.: la topic in ambiente di cluster deve       -->
	<!-- essere di tipo distribuito                       -->
	<!-- ================================================ -->

	<!-- CQRS Connection Factory (shared by command queue and event topic) -->
	<!-- MUST PROVIDE -->
	<!-- 	<bean id="connectionFactory" class="..."/> -->

	<!-- Commmand Queue -->
	<!-- MUST PROVIDE -->
	<!-- 	<bean id="commandQueue" class="..." /> -->

	<!-- Events Topic -->
	<!-- MUST PROVIDE -->
	<!-- 	<bean id="eventTopic" class="..." /> -->

    <!-- Competing Events Queue 1 -->
	<!-- MUST PROVIDE -->
	<!-- 	<bean id="eventQ1" class="..." /> -->

	<!-- Security Context implementation: org.aktivecortex.api.audit.SecurityContext -->
	<!-- MUST PROVIDE-->
	<!-- 	<bean id="securityContext" class="..." /> -->

    <!-- Spring Transaction Manager -->
	<!-- MUST PROVIDE-->
	<!-- 	<bean id="transactionManager" class="..." /> -->

	<bean id="protostuffMessageSerializer" class="org.aktivecortex.core.serializer.message.ProtostuffMessageSerializer" destroy-method="close"/>
	
	<!-- ================================================ -->
	<!-- ==               Task Executor                == -->
	<!-- == Utilizzato dai DMLC dei jms channels di SI == -->
	<!-- == Impiega il WorkManager di default di WL    == -->
	<!-- ================================================ -->

<!-- 	<bean id="taskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor" lazy-init="false"> -->
<!-- 		<property name="workManagerName" value="wm/eventhandling_workmanager"/> -->
<!-- 		<property name="resourceRef" value="true"/> -->
<!-- 		<property name="jndiEnvironment" ref="jndiProperties" /> -->
<!-- 	</bean> -->

	<!-- ================================================ -->
	<!-- ==               COMMAND BUS                  == -->
	<!-- == N.B.: il BUS si appoggia ad una coda JMS   == -->
	<!-- ================================================ -->
	
	<!-- Notification Manager -->
	<bean id="notificationManager" class="org.aktivecortex.core.notification.ConversationManagerImpl">
		<property name="securityContextProvider" ref="securityContext" />
	</bean>
	

	<!-- Log to FILE Command interceptor -->
	<bean id="auditInterceptor" class="org.aktivecortex.core.commandhandling.interceptors.afterreceive.AuditingInterceptor">
		 <property name="auditDataProvider">
        	<bean class="org.aktivecortex.core.audit.AuditEventDataProvider"/>
        </property>
		<property name="auditLogger">
			<bean class="org.aktivecortex.core.audit.ToStringBasedAuditCommandLogger"/>
		</property>
	</bean>
	
	<!-- Notification Management -->
	<bean id="remoteNotifier" class="org.aktivecortex.core.notification.ProgressRemoteNotifierImpl" p:eventBus-ref="eventBus"/>

    <bean id="progressNotifier" class="org.aktivecortex.core.notification.ProgressNotifierImpl">
        <property name="localNotifier">
            <bean class="org.aktivecortex.core.notification.ProgressLocalNotifierImpl" p:conversationManager-ref="notificationManager"/>
        </property>
        <property name="remoteNotifier" ref="remoteNotifier"/>
    </bean>

	<bean id="remoteNotifierJobDetail" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
		<property name="jobClass" value="org.aktivecortex.core.notification.RemoteNotifierJob" />
		<property name="jobDataAsMap">
			<map>
				<entry key="actualWorker" value-ref="remoteNotifier"/>
			</map>
		</property>
	</bean>
	
	<bean id="remoteTaskEventListener" class="org.aktivecortex.core.notification.support.ProgressEventListener">
		<property name="conversationManager" ref="notificationManager"/>
	</bean>

	<!-- Task & Command Metadata provider -->
	<bean id="taskProgressInterceptor" class="org.aktivecortex.core.commandhandling.interceptors.afterreceive.TaskProgressInterceptor"
          p:progressNotifier-ref="progressNotifier"
          p:distributedCluster-ref="competingCluster"  />

	<!-- Command Send Adapter -->
	<!-- MUST PROVIDE -->
	<!-- 	<bean id="commandSendAdapter" class="..."/> -->

	<!-- Command Channel -->
	<bean id="commandChannel" class="org.aktivecortex.core.message.channel.adapter.ChannelAdapter"
          p:adapterName="commandChannel"
          p:serializer-ref="protostuffMessageSerializer"
          p:sendAdapter-ref="commandSendAdapter"/>

	<!-- Command Message Factory -->
	<bean id="commandMessageFactory" class="org.aktivecortex.core.message.DefaultMessageFactory">
        <constructor-arg>
            <ref bean="notificationManager"/>
        </constructor-arg>
	</bean>

	<!-- COMMAND BUS -->
	<bean id="commandBus" class="org.aktivecortex.core.commandhandling.DistributedCommandBus">
		<property name="beforeSendInterceptors">
			<list>
				<bean class="org.aktivecortex.core.commandhandling.interceptors.beforesend.AuditCommandDataProvider" p:securityContext-ref="securityContext" />
			</list>
		</property>
		<property name="afterReceiveInterceptors">
			<list>
				<bean class="org.aktivecortex.core.commandhandling.interceptors.afterreceive.SpringTransactionalInterceptor">
					<property name="transactionManager" ref="transactionManager"/>
					<property name="transactionDefinition">
						<bean class="org.springframework.transaction.support.DefaultTransactionDefinition">
							<property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/> 
						</bean>
					</property>		 
				</bean>
				<ref local="taskProgressInterceptor"/>
				<ref local="auditInterceptor"/>
			</list>
		</property>
		<property name="messageFactory" ref="commandMessageFactory" />
		<property name="channel" ref="commandChannel" />
	</bean>

		
	<!-- ================================================ -->
	<!-- ==            CLUSTERING EVENT BUS            == -->
	<!-- ================================================ -->

	<!-- Non competing EventListeners Cluster -->
	<bean id="nonCompetingCluster" class="org.aktivecortex.core.eventbus.DistributedCluster" p:destinationName="T_Event" p:destinationType="TOPIC" />

	<!-- Competing EventListeners Cluster -->
	<!-- MUST PROVIDE-->
<!-- 	<bean id="competingCluster" class="org.aktivecortex.core.eventbus.DistributedCompetingCluster" p:destinationName="Q_Event_1" p:destinationType="QUEUE"> -->
<!-- 		<property name="competingListeners"> -->
<!-- 			<set> -->
<!-- 				<value>org.axonframework.v2.saga.annotation.AsyncAnnotatedSagaManager</value>				 -->
<!-- 				<value>...</value> -->
<!-- 			</set> -->
<!-- 		</property> -->
<!-- 		<property name="sagas"> -->
<!-- 			<set> -->
<!-- 				<value>...</value> -->
<!-- 			</set> -->
<!-- 		</property> -->
<!-- 	</bean> -->

	<!-- Cluster Configuration Logger -->
	<bean class="org.aktivecortex.core.context.ConfigurationListener"/>

	<!-- Cluster Selector that provides event bus routing policies -->
	<bean id="jmsClusterSelector" class="org.aktivecortex.core.eventbus.DistributedClusterSelector"
          p:competingCluster-ref="competingCluster"
          p:nonCompetingCluster-ref="nonCompetingCluster"/>
	
	<!-- Non Competing Events Send Adapter -->
	<!-- MUST PROVIDE -->
	<!-- 	<bean id="nonCompetingEventSendAdapter" class="..."/> -->

	<!-- Non Competing Events Channel -->	
	<bean id="nonCompetingEventChannel" class="org.aktivecortex.core.message.channel.adapter.ChannelAdapter"
          p:adapterName="nonCompetingEventChannel"
          p:serializer-ref="protostuffMessageSerializer"
          p:sendAdapter-ref="nonCompetingEventSendAdapter"/>

	<!-- Competing Events Send Adapter -->
	<!-- MUST PROVIDE -->
	<!-- 	<bean id="competingEventSendAdapter" class="..."/> -->

	<!-- Competing Events Channel -->	
	<bean id="competingEventChannel" class="org.aktivecortex.core.message.channel.adapter.ChannelAdapter"
            p:adapterName="competingEventChannel"
            p:serializer-ref="protostuffMessageSerializer"
            p:sendAdapter-ref="competingEventSendAdapter"/>

<!-- 	Axon Terminal that forward events to the underlying channel associated to each cluster destination -->
	<bean id="eventBusTerminal" class="org.aktivecortex.core.eventbus.DistributedEventBusTerminal">
		<property name="channels">
			<map>
				<entry key="T_Event" value-ref="nonCompetingEventChannel"/>
				<entry key="Q_Event_1" value-ref="competingEventChannel"/>
			</map>
		</property>
	</bean>

	<!-- CLUSTERING EVENT BUS -->
	<bean id="eventBus" class="org.axonframework.eventhandling.ClusteringEventBus">
		<constructor-arg ref="jmsClusterSelector"/>
		<constructor-arg ref="eventBusTerminal"/>
	</bean>
	
	<!-- ================================================ -->
	<!-- ==          ENTITY MANAGER PROVIDER           == -->
	<!-- ================================================ -->
	<bean id="entityManagerProvider" class="org.axonframework.util.jpa.ContainerManagedEntityManagerProvider"/>
 
	<!-- ================================================ -->
	<!-- ==                 EVENT STORE                == -->
	<!-- ================================================ -->
	<bean id="protostuffEventSerializer" class="org.aktivecortex.core.serializer.event.ProtostuffEventSerializer" destroy-method="close"/>

	<axon:jpa-event-store id="eventStore" event-serializer="protostuffEventSerializer"/>

	<!-- ================================================ -->
	<!-- ==                     SAGA                   == -->
	<!-- ================================================ -->
	<!-- Spring dependencies resource injection -->
	<bean id="resourceInjector" class="org.aktivecortex.core.axon2backport.saga.spring.SpringResourceInjector" />

	<!-- saga serializer -->
	<bean id="sagaSerializer" class="org.aktivecortex.core.serializer.saga.ProtostuffSagaSerializer" destroy-method="close"/>
	
	<!-- saga repository (Prototype scoped to permit SagaManager hot restart ) -->
	<bean id="sagaRepository" scope="prototype" class="org.aktivecortex.core.axon2backport.saga.repository.jpa.JpaSagaRepository" 
		p:serializer-ref="sagaSerializer" p:resourceInjector-ref="resourceInjector">
		<constructor-arg index="0" ref="entityManagerProvider" />
	</bean>
	
	<bean id="sagaRepositoryFactory" class="org.aktivecortex.core.axon2backport.saga.spring.SpringSagaRepositoryFactory" 
	      p:beanName="sagaRepository" />

	<bean id="sagaFactory" class="org.aktivecortex.core.axon2backport.saga.GenericSagaFactory" p:resourceInjector-ref="resourceInjector"/>
	
	<bean id="axonTxManager" class="org.aktivecortex.core.axon2backport.unitofwork.SpringTransactionManager"
			p:transactionManager-ref="transactionManager" />
			
	<!-- Saga Event processors Strategy 
	     available strategies are BlockingWaitStrategy, SleepingWaitStrategy, YeldingWaitStrategy) -->
	<bean id="sagaWaitStrategy" class="com.lmax.disruptor.BlockingWaitStrategy" />

    <bean id="unHandledEventNotifier" class="org.aktivecortex.core.notification.support.NotificationUnhandledSagaEventListener">
        <constructor-arg ref="progressNotifier" />
    </bean>
	
	<!-- Saga Manager -->
	<!-- MUST PROVIDE -->
	<!-- N.B. Enable property p:executor-ref="taskExecutor" to use workmanager executorservice -->
	<!--      in this case you must edit config.xml domain configuration file and include property deployment-principal-name -->
	<!--      see https://jira.springsource.org/browse/SPR-4670 for details and Oracle Metalink CR374022 -->
	<!--      and also http://aktiveqc.cloud.reply.eu/jira/browse/COLI-390 issue -->
	<!-- default executor service is jvm cached executor service obtained through Executors.newCachedThreadPool() -->
    <!-- <bean id="sagaManager" class="org.aktivecortex.core.axon2backport.saga.annotation.AsyncAnnotatedSagaManager"
		  init-method="start" destroy-method="stop"
		  p:BUFFER_SIZE="2048"
		  p:processorCount="4"
		  p:sagaFactory-ref="sagaFactory"
		  p:sagaRepositoryFactory-ref="sagaRepositoryFactory"
		  p:transactionManager-ref="axonTxManager"
	          p:sagaSerializer-ref="sagaSerializer"
		  p:waitStrategy-ref="sagaWaitStrategy"
 	          p:maxRetries="5"
		  p:retryInterval="5000"> 
		<constructor-arg index="0" ref="eventBus" />
		<constructor-arg index="1">
			<list>
				<value>org.yourpackage.YourSaga</value>					
			</list>
		</constructor-arg>
		<property name="transientExceptions">
			<set>
				<value>javax.transaction.HeuristicMixedException</value>
				<value>javax.transaction.HeuristicRollbackException</value>
				<value>javax.transaction.RollbackException</value>
				<value>javax.transaction.TransactionRolledbackException</value>
				<value>javax.persistence.PersistenceException</value>
			</set>
		</property>
	</bean> -->


    <bean id="remoteNotifierTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
		<!-- see the example of method invoking job above -->
		<property name="jobDetail" ref="remoteNotifierJobDetail" />
		<!-- 10 seconds -->
		<property name="startDelay" value="10000" />
		<!-- repeat every 5 seconds -->
		<property name="repeatInterval" value="5000" />
	</bean>

	<!-- N.B. Set p:taskExecutor-ref="taskExecutor"  if necessary -->
	<!-- MUST PROVIDE -->
<!-- 	<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false"> -->
<!-- 		<property name="triggers"> -->
<!-- 			<list> -->
<!-- 				<ref bean="remoteNotifierTrigger"/> -->
<!-- 			</list> -->
<!-- 		</property> -->
<!-- 		<property name="quartzProperties"> -->
<!-- 			<props> -->
<!-- 				<prop key="org.quartz.scheduler.skipUpdateCheck">true</prop> -->
<!-- 			</props> -->
<!-- 		</property> -->
<!-- 	</bean> -->


    <bean id="schedulerFactory" class="org.aktivecortex.core.eventhandling.scheduling.QuartzEventSchedulerFactoryBean"
			p:eventBus-ref="eventBus"
            p:transactionManager-ref="transactionManager"
			p:scheduler-ref="scheduler" />

</beans>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy