Hi Philipp,
Thx again for you detailed inputs.
Yes, 1/ seems promising.
With a bit of effort, I'm sure it would even be possible to setup a unit
test that launches 2 embedded amq, the first one being stopped after a
delay (see [1] for the current unit test). You would also need to
configure your broker configuration to read from both embedded amq
(aBroker.addConnector("tcp://127.0.0.1....");
The advantage of that kind of unit test is:
- You will get faster a candidate jar because developing is
eclipse/unitest is much faster than deploying a new jar in james
(star/stop) and stopping a real amq instance.
- You are more confident on your jars when you will try it in the real env.
- Other users will benefit from your unit test.
Whatever you do, Good luck :)
Thx, Eric
[1]
https://svn.apache.org/repos/asf/james/server/trunk/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java
On 17/01/2013 15:01, Philipp Krenn wrote:
Hi Eric,
thanks for the quick reply!
Just to be clear, depending on the configuration, we run into different
exceptions:
1) If we use AMQ's PooledConnectionFactory we get a ClassCastException as soon
as a message is being delivered due to the wrong exception. Failover is working
fine, however.
2) If we use Spring's CachingConnectionFactory message delivery is working
fine, but upon failover we run into an IllegalStateException which results in
100% CPU utilization.
Our configuration looks like this:
##########################################
<!-- ActiveMQ: Broker, Connections, BlobTransferPolicy... -->
<!-- <amq:broker useJmx="true" persistent="false" brokerName="james"
dataDirectory="filesystem=file://var/store/activemq/brokers"
useShutdownHook="false" schedulerSupport="false" id="broker">
<amq:destinationPolicy>
<amq:policyMap> <amq:policyEntries> Support priority handling
of messages
http://activemq.apache.org/how-can-i-support-priority-queues.html
<amq:policyEntry
queue=">" prioritizedMessages="true"/> </amq:policyEntries>
</amq:policyMap>
</amq:destinationPolicy> <amq:managementContext> <amq:managementContext
createConnector="false"/>
</amq:managementContext> <amq:persistenceAdapter>
<amq:amqPersistenceAdapter/>
</amq:persistenceAdapter> <amq:plugins> <amq:statisticsBrokerPlugin/>
</amq:plugins>
<amq:transportConnectors> <amq:transportConnector
uri="tcp://localhost:6000"
/> </amq:transportConnectors> </amq:broker> -->
<amq:connectionFactory id="amqConnectionFactory"
brokerURL="${jms.broker.url}">
<amq:prefetchPolicy>
<!-- Disable prefetch so slow consuming can not block
other threads -->
<!-- See JAMES-1253 -->
<amq:prefetchPolicy queuePrefetch="0"
topicPrefetch="0" />
</amq:prefetchPolicy>
<property name="blobTransferPolicy" ref="blobTransferPolicy" />
</amq:connectionFactory>
<bean id="blobTransferPolicy"
class="org.apache.james.queue.activemq.FileSystemBlobTransferPolicy">
<property name="defaultUploadUrl"
value="file://var/store/activemq/blob-transfer" />
</bean>
<bean id="jmsConnectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory"
ref="amqConnectionFactory" />
<property name="sessionCacheSize" value="10" />
<property name="cacheConsumers" value="false" />
<property name="cacheProducers" value="false" />
<property name="reconnectOnException" value="true" />
</bean>
<!--
<bean id="jmsConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
<property name="connectionFactory" ref="amqConnectionFactory">
</property>
</bean> -->
##########################################
We'll look into 1) and will try to provide a patch.
We're not sure how / why 2) happens, but that's also not the intended behavior
IMHO.
Cheers,
Philipp
Am 17.01.2013 um 14:32 schrieb Eric Charles <e...@apache.org>:
Hi Philipp,
Good to see you are progressing.
If I undertand well fail-over occurs, but your receive a ClassCastException
upon receiving a message.
I would be great if you could share the details of your configuration (just
replace hostname, username, password...) to make fail-over work.
Also, you could try to patch the code with javax.jms.ConnectionFactory, rebuild
it and see if it works with the new jars.
Thx again and come back here if you need more details on anything,
Eric
On 17/01/2013 13:23, Philipp Krenn wrote:
Hi,
we have removed the definition for creating an ActiveMQ broker from the
spring-server.xml and are using an external one. In order to do so, we have
configured <amq:connectionFactory.../> accordingly. This configuration is the
same as we are using for several other camel-based applications (where we also use
Spring's CachingConnectionFactory) accessing the same broker.
So we do not expect that this is a configuration error. What we also observed
is that by replacing the CachingConnectionFactory by AMQ's
PooledConnectionFactory, the failover works fine. However, an exception is
thrown upon receiving a message, since somewhere in the code an
org.springframework.jms.connection.CachingConnectionFactory instead of a
javax.jms.ConnectionFactory is injected.
Best regards,
Philipp
Am 15.01.2013 um 20:57 schrieb Eric Charles <e...@apache.org>:
Hi,
Interestting, this is the first time I hear about a real James with amq in a
failover configuration.
I guess you changed in spring-server.xml the block
<amq:transportConnectors>
<amq:transportConnector uri="tcp://localhost:0" />
</amq:transportConnectors>
Maybe a first test scenario would be to be sure James doesn't use the queue,
failingover amq, and begin to send again mail to james. The error may be due
because the fail over occurs while a transaction is occurring?
Thx, Eric
On 15/01/2013 15:26, Philipp Krenn wrote:
Hi,
We are using James Server with an ActiveMQ master/slave configuration
configured via failover:
failover:(tcp://mq0.xxx:8080,tcp://mq1.xxx:8080)?jms.prefetchPolicy.all=0
When the master stops, we would expect a failover to the slave - this is
working fine with other applications. However, James Server does not switch
queue instance and keeps producing the following exception instead:
[ERROR] - Exception caught in RemoteDelivery.run() [Remote delivery thread (3)]
[j.mailetcontext]
org.apache.james.queue.api.MailQueue$MailQueueException: Unable to dequeue next
message (javax.jms.IllegalStateException: The Session is closed)
at
org.apache.james.queue.jms.JMSMailQueue.deQueue(JMSMailQueue.java:170)
~[james-server-queue-jms-3.0-beta5-20130109.104230-723.jar:3.0-beta5-SNAPSHOT]
at
org.apache.james.transport.mailets.RemoteDelivery.run(RemoteDelivery.java:771)
~[james-server-mailets-3.0-beta5-20130110.114225-802.jar:3.0-beta5-SNAPSHOT]
at java.lang.Thread.run(Thread.java:679) [na:1.6.0_24]
Caused by: javax.jms.IllegalStateException: The Session is closed
at
org.apache.activemq.ActiveMQSession.checkClosed(ActiveMQSession.java:731)
~[activemq-core-5.7.0.jar:5.7.0]
at
org.apache.activemq.ActiveMQSession.createQueue(ActiveMQSession.java:1169)
~[activemq-core-5.7.0.jar:5.7.0]
at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source) ~[na:na]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:1.6.0_24]
at java.lang.reflect.Method.invoke(Method.java:616) ~[na:1.6.0_24]
at
org.springframework.jms.connection.CachingConnectionFactory$CachedSessionInvocationHandler.invoke(CachingConnectionFactory.java:344)
~[spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at $Proxy87.createQueue(Unknown Source) ~[na:na]
at
org.apache.james.queue.jms.JMSMailQueue.deQueue(JMSMailQueue.java:107)
~[james-server-queue-jms-3.0-beta5-20130109.104230-723.jar:3.0-beta5-SNAPSHOT]
... 2 common frames omitted
The James Server keeps running and consumes 100% of the available CPU until it
is manually restarted.
Thanks for looking into this issue.
Cheers,
Philipp
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org