Author: btellier Date: Sat Nov 28 15:30:56 2015 New Revision: 1716988 URL: http://svn.apache.org/viewvc?rev=1716988&view=rev Log: MAILBOX-259 Add configuration for Mailbox event delivery customisation
Modified: james/project/trunk/mailbox/spring/src/main/resources/META-INF/spring/event-system.xml james/project/trunk/mailbox/spring/src/test/resources/META-INF/spring/event-alias.xml james/project/trunk/server/app/src/main/resources/events-template.xml james/project/trunk/server/app/src/main/resources/events.properties james/project/trunk/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/EventsConfigurationBeanFactoryPostProcessor.java Modified: james/project/trunk/mailbox/spring/src/main/resources/META-INF/spring/event-system.xml URL: http://svn.apache.org/viewvc/james/project/trunk/mailbox/spring/src/main/resources/META-INF/spring/event-system.xml?rev=1716988&r1=1716987&r2=1716988&view=diff ============================================================================== --- james/project/trunk/mailbox/spring/src/main/resources/META-INF/spring/event-system.xml (original) +++ james/project/trunk/mailbox/spring/src/main/resources/META-INF/spring/event-system.xml Sat Nov 28 15:30:56 2015 @@ -28,13 +28,16 @@ <property name ="location" value="classpath:events.properties"/> </bean> - <bean id="default-delegating-listener" class="org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener" lazy-init="true"/> + <bean id="default-delegating-listener" class="org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener" lazy-init="true"> + <constructor-arg index="0" ref="event-delivery"/> + </bean> <bean id="broadcast-delegating-listener" class="org.apache.james.mailbox.store.event.distributed.BroadcastDelegatingMailboxListener" lazy-init="true"> <constructor-arg index="0" ref="publisher"/> <constructor-arg index="1" ref="consumer"/> <constructor-arg index="2" ref="event-serializer"/> - <constructor-arg index="3" ref="${global.topic}"/> + <constructor-arg index="3" ref="event-delivery"/> + <constructor-arg index="4" ref="${global.topic}"/> </bean> <bean id="registered-delegating-listener" class="org.apache.james.mailbox.store.event.distributed.RegisteredDelegatingMailboxListener" lazy-init="true"> @@ -42,6 +45,7 @@ <constructor-arg index="1" ref="consumer"/> <constructor-arg index="2" ref="event-serializer"/> <constructor-arg index="3" ref="mailbox-path-register"/> + <constructor-arg index="4" ref="event-delivery"/> </bean> <bean id="mailbox-path-register" class="org.apache.james.mailbox.store.event.distributed.DistantMailboxPathRegister" lazy-init="true"> @@ -66,4 +70,11 @@ <constructor-arg index="0" ref="mailbox-id-deserializer"/> </bean> + <bean id="synchronous-event-delivery" class="org.apache.james.mailbox.store.event.SynchronousEventDelivery" lazy-init="true"/> + + + <bean id="asynchronous-event-delivery" class="org.apache.james.mailbox.store.event.AsynchronousEventDelivery" lazy-init="true"> + <constructor-arg index="0" ref="${event.delivery.thread.count}"/> + </bean> + </beans> \ No newline at end of file Modified: james/project/trunk/mailbox/spring/src/test/resources/META-INF/spring/event-alias.xml URL: http://svn.apache.org/viewvc/james/project/trunk/mailbox/spring/src/test/resources/META-INF/spring/event-alias.xml?rev=1716988&r1=1716987&r2=1716988&view=diff ============================================================================== --- james/project/trunk/mailbox/spring/src/test/resources/META-INF/spring/event-alias.xml (original) +++ james/project/trunk/mailbox/spring/src/test/resources/META-INF/spring/event-alias.xml Sat Nov 28 15:30:56 2015 @@ -23,5 +23,6 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <alias name="default-delegating-listener" alias="delegating-listener"/> + <alias name="synchronous-event-delivery" alias="event-delivery"/> </beans> \ No newline at end of file Modified: james/project/trunk/server/app/src/main/resources/events-template.xml URL: http://svn.apache.org/viewvc/james/project/trunk/server/app/src/main/resources/events-template.xml?rev=1716988&r1=1716987&r2=1716988&view=diff ============================================================================== --- james/project/trunk/server/app/src/main/resources/events-template.xml (original) +++ james/project/trunk/server/app/src/main/resources/events-template.xml Sat Nov 28 15:30:56 2015 @@ -28,6 +28,13 @@ distributed and won't do the work with multiples servers --> <type>default</type> + <!-- Do you want to wait for MailboxListeners to be executed before returning result to the user ? + + If yes set this to synchronous + If no set this to asynchronous + --> + <delivery>synchronous</delivery> + <!-- Broadcast event system will send messages to all your James servers. It is the only viable options if you rely on Mailbox Listeners that do not perform well in a distributed system. Modified: james/project/trunk/server/app/src/main/resources/events.properties URL: http://svn.apache.org/viewvc/james/project/trunk/server/app/src/main/resources/events.properties?rev=1716988&r1=1716987&r2=1716988&view=diff ============================================================================== --- james/project/trunk/server/app/src/main/resources/events.properties (original) +++ james/project/trunk/server/app/src/main/resources/events.properties Sat Nov 28 15:30:56 2015 @@ -36,3 +36,7 @@ global.topic=JAMES_TOPIC distant.mailbox.path.register.max.retries=100 distant.mailbox.path.register.refresh=900 + +# Worker threads count for asynchronous event delivery + +event.delivery.thread.count=10 Modified: james/project/trunk/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/EventsConfigurationBeanFactoryPostProcessor.java URL: http://svn.apache.org/viewvc/james/project/trunk/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/EventsConfigurationBeanFactoryPostProcessor.java?rev=1716988&r1=1716987&r2=1716988&view=diff ============================================================================== --- james/project/trunk/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/EventsConfigurationBeanFactoryPostProcessor.java (original) +++ james/project/trunk/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/EventsConfigurationBeanFactoryPostProcessor.java Sat Nov 28 15:30:56 2015 @@ -39,9 +39,11 @@ public class EventsConfigurationBeanFact String serialization = config.getString("serialization", "json"); String publisher = config.getString("publisher", "kafka"); String registration = config.getString("registration", "cassandra"); + String delivery = config.getString("delivery", "synchronous"); String delegatingListenerAlias = getDelegatingListenerAlias(type); String serializationAlias = getSerializationAlias(serialization); String registrationAlias = getRegistrationAlias(registration); + String deliveryAlias = null; String publisherAlias = null; String consumerAlias = null; @@ -50,12 +52,20 @@ public class EventsConfigurationBeanFact consumerAlias = "kafka-consumer"; } + if (delivery.equals("synchronous")) { + deliveryAlias = "synchronous-event-delivery"; + } else if (delivery.equals("asynchronous")) { + deliveryAlias = "asynchronous-event-delivery"; + } + detectInvalidValue(delegatingListenerAlias, "Delegating listener type " + type + " not supported!"); + detectInvalidValue(deliveryAlias, "Event delivery " + delivery + " not supported"); beanFactory.registerAlias(delegatingListenerAlias, "delegating-listener"); + beanFactory.registerAlias(deliveryAlias, "event-delivery"); if (!delegatingListenerAlias.equals("default")) { detectInvalidValue(serializationAlias, "Serialization system type " + serialization + " not supported!"); - beanFactory.registerAlias(serializationAlias, "event-serializer"); detectInvalidValue(publisherAlias, "Publisher system type " + publisher + " not supported!"); + beanFactory.registerAlias(serializationAlias, "event-serializer"); beanFactory.registerAlias(publisherAlias, "publisher"); beanFactory.registerAlias(consumerAlias, "consumer"); if (delegatingListenerAlias.equals("registered")) { --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org