Author: btellier
Date: Sat Nov 28 13:11:36 2015
New Revision: 1716968
URL: http://svn.apache.org/viewvc?rev=1716968&view=rev
Log:
MAILBOX-211 Spring configuration for Event system
Added:
james/project/trunk/mailbox/kafka/src/main/resources/
james/project/trunk/mailbox/kafka/src/main/resources/META-INF/
james/project/trunk/mailbox/kafka/src/main/resources/META-INF/spring/
james/project/trunk/mailbox/kafka/src/main/resources/META-INF/spring/kafka.xml
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/mailbox/spring/src/test/resources/events.properties
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/cassandra/src/main/resources/META-INF/spring/mailbox-cassandra.xml
james/project/trunk/mailbox/hbase/src/main/resources/META-INF/spring/mailbox-hbase.xml
james/project/trunk/mailbox/jcr/src/main/resources/META-INF/spring/mailbox-jcr.xml
james/project/trunk/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
james/project/trunk/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml
james/project/trunk/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/SpringMailbox.java
james/project/trunk/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml
james/project/trunk/server/app/src/main/resources/cassandra-template.properties
james/project/trunk/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/MailboxConfigurationBeanFactoryPostProcessor.java
james/project/trunk/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
Modified:
james/project/trunk/mailbox/cassandra/src/main/resources/META-INF/spring/mailbox-cassandra.xml
URL:
http://svn.apache.org/viewvc/james/project/trunk/mailbox/cassandra/src/main/resources/META-INF/spring/mailbox-cassandra.xml?rev=1716968&r1=1716967&r2=1716968&view=diff
==============================================================================
---
james/project/trunk/mailbox/cassandra/src/main/resources/META-INF/spring/mailbox-cassandra.xml
(original)
+++
james/project/trunk/mailbox/cassandra/src/main/resources/META-INF/spring/mailbox-cassandra.xml
Sat Nov 28 13:11:36 2015
@@ -37,6 +37,7 @@
<property name="quotaManager" ref="quotaManager"/>
<property name="quotaRootResolver" ref="quotaRootResolver"/>
<property name="quotaUpdater" ref="quotaUpdater"/>
+ <property name="delegatingMailboxListener" ref="delegating-listener"/>
</bean>
<bean id ="cassandra-subscriptionManager"
@@ -82,4 +83,10 @@
<bean id="cassandra-mailbox-id-deserializer"
class="org.apache.james.mailbox.cassandra.CassandraMailboxIdDeserializer"/>
+ <bean id="cassandra-mailbox-path-register-mapper"
class="org.apache.james.mailbox.cassandra.event.distributed.CassandraMailboxPathRegisterMapper"
lazy-init="true">
+ <constructor-arg index="0" ref="cassandra-session"/>
+ <constructor-arg index="1" ref="cassandra-type-provider"/>
+ <constructor-arg index="2"
ref="${cassandra.mailbox.path.register.mapper.ttl}"/>
+ </bean>
+
</beans>
Modified:
james/project/trunk/mailbox/hbase/src/main/resources/META-INF/spring/mailbox-hbase.xml
URL:
http://svn.apache.org/viewvc/james/project/trunk/mailbox/hbase/src/main/resources/META-INF/spring/mailbox-hbase.xml?rev=1716968&r1=1716967&r2=1716968&view=diff
==============================================================================
---
james/project/trunk/mailbox/hbase/src/main/resources/META-INF/spring/mailbox-hbase.xml
(original)
+++
james/project/trunk/mailbox/hbase/src/main/resources/META-INF/spring/mailbox-hbase.xml
Sat Nov 28 13:11:36 2015
@@ -46,6 +46,7 @@
<property name="quotaManager" ref="quotaManager"/>
<property name="maxQuotaManager" ref="maxQuotaManager"/>
<property name="quotaRootResolver" ref="quotaRootResolver"/>
+ <property name="delegatingMailboxListener" ref="delegating-listener"/>
</bean>
<bean id="hbase-sessionMapperFactory"
class="org.apache.james.mailbox.hbase.HBaseMailboxSessionMapperFactory">
Modified:
james/project/trunk/mailbox/jcr/src/main/resources/META-INF/spring/mailbox-jcr.xml
URL:
http://svn.apache.org/viewvc/james/project/trunk/mailbox/jcr/src/main/resources/META-INF/spring/mailbox-jcr.xml?rev=1716968&r1=1716967&r2=1716968&view=diff
==============================================================================
---
james/project/trunk/mailbox/jcr/src/main/resources/META-INF/spring/mailbox-jcr.xml
(original)
+++
james/project/trunk/mailbox/jcr/src/main/resources/META-INF/spring/mailbox-jcr.xml
Sat Nov 28 13:11:36 2015
@@ -36,6 +36,7 @@
<property name="quotaManager" ref="quotaManager"/>
<property name="quotaRootResolver" ref="quotaRootResolver"/>
<property name="quotaUpdater" ref="quotaUpdater"/>
+ <property name="delegatingMailboxListener" ref="delegating-listener"/>
</bean>
<bean id ="jcr-subscriptionManager"
class="org.apache.james.mailbox.jcr.JCRSubscriptionManager">
<constructor-arg index="0" ref="jcr-sessionMapperFactory"/>
Modified:
james/project/trunk/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
URL:
http://svn.apache.org/viewvc/james/project/trunk/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml?rev=1716968&r1=1716967&r2=1716968&view=diff
==============================================================================
---
james/project/trunk/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
(original)
+++
james/project/trunk/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
Sat Nov 28 13:11:36 2015
@@ -39,6 +39,7 @@
<property name="quotaManager" ref="quotaManager"/>
<property name="quotaRootResolver" ref="quotaRootResolver"/>
<property name="quotaUpdater" ref="quotaUpdater"/>
+ <property name="delegatingMailboxListener" ref="delegating-listener"/>
</bean>
<bean id ="jpa-subscriptionManager"
class="org.apache.james.mailbox.jpa.JPASubscriptionManager">
<constructor-arg index="0" ref="jpa-sessionMapperFactory"/>
Added:
james/project/trunk/mailbox/kafka/src/main/resources/META-INF/spring/kafka.xml
URL:
http://svn.apache.org/viewvc/james/project/trunk/mailbox/kafka/src/main/resources/META-INF/spring/kafka.xml?rev=1716968&view=auto
==============================================================================
---
james/project/trunk/mailbox/kafka/src/main/resources/META-INF/spring/kafka.xml
(added)
+++
james/project/trunk/mailbox/kafka/src/main/resources/META-INF/spring/kafka.xml
Sat Nov 28 13:11:36 2015
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="ignoreUnresolvablePlaceholders" value="true"/>
+ <property name ="location" value="classpath:events.properties"/>
+ </bean>
+
+ <bean id="kafka-publisher"
class="org.apache.james.mailbox.kafka.KafkaPublisher" lazy-init="true">
+ <constructor-arg index="0" ref="${kafka.ip}"/>
+ <constructor-arg index="1" ref="${kafka.port}"/>
+ </bean>
+
+ <bean id="kafka-consumer"
class="org.apache.james.mailbox.kafka.KafkaMessageConsumer" lazy-init="true">
+ <constructor-arg index="0" ref="${zookeeper.connection.string}"/>
+ <constructor-arg index="1" ref="${group.id}"/>
+ <constructor-arg index="2" ref="${event.thread.count}"/>
+ </bean>
+
+</beans>
\ No newline at end of file
Modified:
james/project/trunk/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml
URL:
http://svn.apache.org/viewvc/james/project/trunk/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml?rev=1716968&r1=1716967&r2=1716968&view=diff
==============================================================================
---
james/project/trunk/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml
(original)
+++
james/project/trunk/mailbox/maildir/src/main/resources/META-INF/spring/mailbox-maildir.xml
Sat Nov 28 13:11:36 2015
@@ -43,6 +43,7 @@
<property name="quotaManager" ref="quotaManager"/>
<property name="quotaRootResolver" ref="quotaRootResolver"/>
<property name="quotaUpdater" ref="quotaUpdater"/>
+ <property name="delegatingMailboxListener" ref="delegating-listener"/>
</bean>
<bean id ="maildir-subscriptionManager"
class="org.apache.james.mailbox.store.StoreSubscriptionManager">
<constructor-arg index="0" ref="maildir-sessionMapperFactory"/>
Modified:
james/project/trunk/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/SpringMailbox.java
URL:
http://svn.apache.org/viewvc/james/project/trunk/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/SpringMailbox.java?rev=1716968&r1=1716967&r2=1716968&view=diff
==============================================================================
---
james/project/trunk/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/SpringMailbox.java
(original)
+++
james/project/trunk/mailbox/spring/src/main/java/org/apache/james/mailbox/spring/SpringMailbox.java
Sat Nov 28 13:11:36 2015
@@ -28,7 +28,7 @@ public class SpringMailbox {
public SpringMailbox() {
applicationContext = new
ClassPathXmlApplicationContext("META-INF/spring/spring-mailbox.xml",
"META-INF/spring/mailbox-authenticator-anonymous.xml",
"META-INF/spring/quota.xml",
- "META-INF/spring/quota-alias.xml");
+ "META-INF/spring/quota-alias.xml",
"META-INF/spring/event-system.xml", "META-INF/spring/event-alias.xml");
}
public Object getBean(String beanName) {
Added:
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=1716968&view=auto
==============================================================================
---
james/project/trunk/mailbox/spring/src/main/resources/META-INF/spring/event-system.xml
(added)
+++
james/project/trunk/mailbox/spring/src/main/resources/META-INF/spring/event-system.xml
Sat Nov 28 13:11:36 2015
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="ignoreUnresolvablePlaceholders" value="true"/>
+ <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="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}"/>
+ </bean>
+
+ <bean id="registered-delegating-listener"
class="org.apache.james.mailbox.store.event.distributed.RegisteredDelegatingMailboxListener"
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="mailbox-path-register"/>
+ </bean>
+
+ <bean id="mailbox-path-register"
class="org.apache.james.mailbox.store.event.distributed.DistantMailboxPathRegister"
lazy-init="true">
+ <constructor-arg index="0" ref="distant-mailbox-path-register-mapper"/>
+ <constructor-arg index="1"
ref="${distant.mailbox.path.register.max.retries}"/>
+ <constructor-arg index="2"
ref="${distant.mailbox.path.register.refresh}"/>
+ </bean>
+
+ <bean id="json-event-serializer"
class="org.apache.james.mailbox.store.json.JsonEventSerializer"
lazy-init="true">
+ <constructor-arg index="0" ref="mailbox-converter"/>
+ </bean>
+
+ <bean id="message-pack-event-serializer"
class="org.apache.james.mailbox.store.json.MessagePackEventSerializer"
lazy-init="true">
+ <constructor-arg index="0" ref="event-converter"/>
+ </bean>
+
+ <bean id="event-converter"
class="org.apache.james.mailbox.store.json.event.EventConverter"
lazy-init="true">
+ <constructor-arg index="0" ref="mailbox-converter"/>
+ </bean>
+
+ <bean id="mailbox-converter"
class="org.apache.james.mailbox.store.json.event.MailboxConverter"
lazy-init="true">
+ <constructor-arg index="0" ref="mailbox-id-deserializer"/>
+ </bean>
+
+</beans>
\ No newline at end of file
Modified:
james/project/trunk/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml
URL:
http://svn.apache.org/viewvc/james/project/trunk/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml?rev=1716968&r1=1716967&r2=1716968&view=diff
==============================================================================
---
james/project/trunk/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml
(original)
+++
james/project/trunk/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml
Sat Nov 28 13:11:36 2015
@@ -57,5 +57,6 @@
<beans profile="cassandra">
<import resource="classpath:META-INF/spring/mailbox-cassandra.xml"/>
<import
resource="classpath:META-INF/spring/mailbox-elasticsearch.xml"/>
+ <import resource="classpath:META-INF/spring/kafka.xml"/>
</beans>
</beans>
Added:
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=1716968&view=auto
==============================================================================
---
james/project/trunk/mailbox/spring/src/test/resources/META-INF/spring/event-alias.xml
(added)
+++
james/project/trunk/mailbox/spring/src/test/resources/META-INF/spring/event-alias.xml
Sat Nov 28 13:11:36 2015
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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"
+ 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"/>
+
+</beans>
\ No newline at end of file
Added: james/project/trunk/mailbox/spring/src/test/resources/events.properties
URL:
http://svn.apache.org/viewvc/james/project/trunk/mailbox/spring/src/test/resources/events.properties?rev=1716968&view=auto
==============================================================================
--- james/project/trunk/mailbox/spring/src/test/resources/events.properties
(added)
+++ james/project/trunk/mailbox/spring/src/test/resources/events.properties Sat
Nov 28 13:11:36 2015
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#
+
+# This template file can be used as example for James Server configuration
+# DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+
+# The following properties needs to be set
+# if you want to use Kafka for inter node messaging for your event system.
+#
+# This needs to be done if you used <publisher>kafka</publisher> in event.xml
+
+kafka.ip=127.0.0.1
+kafka.port=9092
+zookeeper.connection.string=localhost
+group.id=azerty
+event.thread.count=4
+
+# This property needs to be set if you want to use the Broadcast Mailbox
Delegating Listener
+
+global.topic=JAMES_TOPIC
+
+distant.mailbox.path.register.max.retries=100
+distant.mailbox.path.register.refresh=900
Modified:
james/project/trunk/server/app/src/main/resources/cassandra-template.properties
URL:
http://svn.apache.org/viewvc/james/project/trunk/server/app/src/main/resources/cassandra-template.properties?rev=1716968&r1=1716967&r2=1716968&view=diff
==============================================================================
---
james/project/trunk/server/app/src/main/resources/cassandra-template.properties
(original)
+++
james/project/trunk/server/app/src/main/resources/cassandra-template.properties
Sat Nov 28 13:11:36 2015
@@ -23,4 +23,6 @@
cassandra.ip=127.0.0.1
cassandra.port=9042
cassandra.keyspace=apache_james
-cassandra.replication.factor=1
\ No newline at end of file
+cassandra.replication.factor=1
+
+cassandra.mailbox.path.register.mapper.ttl=1800
\ No newline at end of file
Added: 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=1716968&view=auto
==============================================================================
--- james/project/trunk/server/app/src/main/resources/events-template.xml
(added)
+++ james/project/trunk/server/app/src/main/resources/events-template.xml Sat
Nov 28 13:11:36 2015
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+ -->
+
+<!--
+ This template file can be used as example for James Server configuration
+ DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+
+<events>
+ <!-- By default the event system is in memory based, providing better
performances but is not
+ distributed and won't do the work with multiples servers -->
+ <type>default</type>
+
+ <!-- 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.
+
+ Here follows a non exhaustive list of such Mailbox Listeners :
+ - Memory quota based system
+ - Lucene based search system
+
+ Workload is higher because event needs to be serialized and de serialized.
+
+ Also note that depending on the publisher you use, messages might be
either lost or duplicated, implying wrong
+ indexing or wrong quota count on network partitions.
+
+ Here follows a sample configuration :
+ -->
+ <!--
+ <type>broadcast</type>
+ <serialization>json</serialization>
+ <publisher>kafka</publisher>
+ -->
+
+ <!--
+ Further notes on the choice you had here :
+
+ serialization : you have to choices : either json or message-pack
+
+ message-pack is a binary representation for json, and is 2 times lighter
by average, but is 2 time slower to serialize and de serialize.
+ This choice allows you to trade compute against network.
+
+ publisher : Publish - subscribe used. The only current implementation is
Kafka.
+ -->
+
+ <!-- Registered event system
+
+ Scalable event system based on registration : each James server listen on
his own topic and manage registrations on
+ mailbox paths in order to receive events interesting him.
+
+ This configuration does not support distributed unfriendly Mailbox
Listeners (see the non exhaustive list above) for obvious reasons.
+ -->
+ <!--
+ <type>registered</type>
+ <serialization>json</serialization>
+ <registration>cassandra</registration>
+ <publisher>kafka</publisher>
+ -->
+
+ <!--
+ The only registration system available is Cassandra, used in an available
fashion. This means there is no warranties,
+ either at least one delivery nor at most one delivery. But you get the
certitude that the system will always be available.
+ -->
+
+</events>
\ No newline at end of file
Added: 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=1716968&view=auto
==============================================================================
--- james/project/trunk/server/app/src/main/resources/events.properties (added)
+++ james/project/trunk/server/app/src/main/resources/events.properties Sat Nov
28 13:11:36 2015
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#
+
+# This template file can be used as example for James Server configuration
+# DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+
+# The following properties needs to be set
+# if you want to use Kafka for inter node messaging for your event system.
+#
+# This needs to be done if you used <publisher>kafka</publisher> in event.xml
+
+kafka.ip=127.0.0.1
+kafka.port=9092
+zookeeper.connection.string=localhost
+group.id=azerty
+event.thread.count=4
+
+# This property needs to be set if you want to use the Broadcast Mailbox
Delegating Listener
+
+global.topic=JAMES_TOPIC
+
+distant.mailbox.path.register.max.retries=100
+distant.mailbox.path.register.refresh=900
Added:
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=1716968&view=auto
==============================================================================
---
james/project/trunk/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/EventsConfigurationBeanFactoryPostProcessor.java
(added)
+++
james/project/trunk/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/EventsConfigurationBeanFactoryPostProcessor.java
Sat Nov 28 13:11:36 2015
@@ -0,0 +1,104 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you 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. *
+ ****************************************************************/
+
+package org.apache.james.container.spring.bean.factorypostprocessor;
+
+import com.google.common.base.Strings;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.container.spring.lifecycle.ConfigurationProvider;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+
+public class EventsConfigurationBeanFactoryPostProcessor implements
BeanFactoryPostProcessor {
+
+ @Override
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory
beanFactory) throws BeansException {
+ ConfigurationProvider confProvider =
beanFactory.getBean(ConfigurationProvider.class);
+ try {
+ HierarchicalConfiguration config =
confProvider.getConfiguration("events");
+ String type = config.getString("type", "default");
+ String serialization = config.getString("serialization", "json");
+ String publisher = config.getString("publisher", "kafka");
+ String registration = config.getString("registration",
"cassandra");
+ String delegatingListenerAlias = getDelegatingListenerAlias(type);
+ String serializationAlias = getSerializationAlias(serialization);
+ String registrationAlias = getRegistrationAlias(registration);
+ String publisherAlias = null;
+ String consumerAlias = null;
+
+ if (publisher.equals("kafka")) {
+ publisherAlias = "kafka-publisher";
+ consumerAlias = "kafka-consumer";
+ }
+
+ detectInvalidValue(delegatingListenerAlias, "Delegating listener
type " + type + " not supported!");
+ beanFactory.registerAlias(delegatingListenerAlias,
"delegating-listener");
+ 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(publisherAlias, "publisher");
+ beanFactory.registerAlias(consumerAlias, "consumer");
+ if (delegatingListenerAlias.equals("registered")) {
+ detectInvalidValue(registrationAlias, "Registration system
type " + registration + " not supported!");
+ beanFactory.registerAlias(registrationAlias,
"distant-mailbox-path-register-mapper");
+ }
+ }
+
+ } catch (ConfigurationException e) {
+ throw new FatalBeanException("Unable to config the
mailboxmanager", e);
+ }
+ }
+
+ private void detectInvalidValue(String registrationAlias, String message)
throws ConfigurationException {
+ if (Strings.isNullOrEmpty(registrationAlias)) {
+ throw new ConfigurationException(message);
+ }
+ }
+
+ private String getRegistrationAlias(String registration) {
+ if (registration.equals("cassandra")) {
+ return "cassandra-mailbox-path-register-mapper";
+ }
+ return null;
+ }
+
+ private String getSerializationAlias(String serialization) {
+ if (serialization.equals("json")) {
+ return "json-event-serializer";
+ } else if (serialization.equals("message-pack")) {
+ return "message-pack-event-serializer";
+ }
+ return null;
+ }
+
+ private String getDelegatingListenerAlias(String type) {
+ if (type.equals("default")) {
+ return "default-delegating-listener";
+ } else if (type.equals("broadcast")) {
+ return "broadcast-delegating-listener";
+ } else if (type.equals("registered")) {
+ return "registered-delegating-listener";
+ }
+ return null;
+ }
+}
Modified:
james/project/trunk/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/MailboxConfigurationBeanFactoryPostProcessor.java
URL:
http://svn.apache.org/viewvc/james/project/trunk/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/MailboxConfigurationBeanFactoryPostProcessor.java?rev=1716968&r1=1716967&r2=1716968&view=diff
==============================================================================
---
james/project/trunk/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/MailboxConfigurationBeanFactoryPostProcessor.java
(original)
+++
james/project/trunk/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/MailboxConfigurationBeanFactoryPostProcessor.java
Sat Nov 28 13:11:36 2015
@@ -24,8 +24,11 @@ import org.apache.commons.configuration.
import org.apache.james.container.spring.lifecycle.ConfigurationProvider;
import org.springframework.beans.BeansException;
import org.springframework.beans.FatalBeanException;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
/**
Modified:
james/project/trunk/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
URL:
http://svn.apache.org/viewvc/james/project/trunk/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml?rev=1716968&r1=1716967&r2=1716968&view=diff
==============================================================================
---
james/project/trunk/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
(original)
+++
james/project/trunk/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
Sat Nov 28 13:11:36 2015
@@ -135,6 +135,11 @@
<constructor-arg index="1" ref="quotaRootResolver"/>
</bean>
+ <!-- Event system -->
+ <bean
class="org.apache.james.container.spring.bean.factorypostprocessor.EventsConfigurationBeanFactoryPostProcessor"/>
+
+ <import resource="classpath:META-INF/spring/event-system.xml"/>
+
<!-- Mailbox Copier -->
<bean id="mailboxcopier"
class="org.apache.james.mailbox.copier.MailboxCopierImpl"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]