Spring RabbitMQ doesn't work when called from parallel streams
the-james-burton opened this issue · 1 comments
the-james-burton commented
If we try and use a parallel stream in th furnace's ProducerManager
it appears to lock up when populating the history. I have seen it work just once, so it might be non-deterministic but it locks up almost always.
See if there are any settings for this in the Spring RabbitMQ stuff. If not, then maybe a project to demonstrate and log issue
the-james-burton commented
This was due to the historic population being done in the @PostConstruct
method, i.e. while Spring is still initialising. Moving the historic population into a method called by the main class after spring initialisation successfully resolved this.
Stack trace below for reference. See AMQP-218 for more details.
Name: main
State: BLOCKED on java.lang.Object@22c35b34 owned by: ForkJoinPool.commonPool-worker-1
Total blocked: 40 Total waited: 11
Stack trace:
org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:563)
org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1430)
org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1411)
org.springframework.amqp.rabbit.core.RabbitTemplate.send(RabbitTemplate.java:712)
org.springframework.amqp.rabbit.core.RabbitTemplate.send(RabbitTemplate.java:706)
org.jimsey.projects.turbine.furnace.amqp.AmqpPublisher.publishTick(AmqpPublisher.java:62)
[..]
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
- locked java.util.concurrent.ConcurrentHashMap@442b5354
[..]
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
- locked java.lang.Object@792f1fda
Name: ForkJoinPool.commonPool-worker-1
State: BLOCKED on java.util.concurrent.ConcurrentHashMap@442b5354 owned by: main
Total blocked: 5 Total waited: 4
Stack trace:
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:187)
org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:486)
org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:432)
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:403)
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:515)
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:508)
org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1189)
org.springframework.amqp.rabbit.core.RabbitAdmin.initialize(RabbitAdmin.java:450)
org.springframework.amqp.rabbit.core.RabbitAdmin$11.onCreate(RabbitAdmin.java:419)
org.springframework.amqp.rabbit.connection.CompositeConnectionListener.onCreate(CompositeConnectionListener.java:33)
org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:571)
- locked java.lang.Object@22c35b34
org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1430)
org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1411)
org.springframework.amqp.rabbit.core.RabbitTemplate.send(RabbitTemplate.java:712)
org.springframework.amqp.rabbit.core.RabbitTemplate.send(RabbitTemplate.java:706)
org.jimsey.projects.turbine.furnace.amqp.AmqpPublisher.publishTick(AmqpPublisher.java:62)