Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

spring - DefaultMessageListenerContainer not receiving messages

I have a DefaultMessageListenerContainer configured as follows:

DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConcurrentConsumers(4);
container.setConnectionFactory(connectionFactory);
container.setDestinationName(String.format("Consumer.%s.VirtualTopic.%s", group, topic));
container.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
container.setSessionTransacted(true);
container.setMessageListener(new DelegatingMessageListener(listener, messageMapper, event));

container.start();

The message container never receives messages, and my message listener is never invoked. Leaving all else the same, if I just switch DefaultMessageListenerContainer to SimpleMessageListenerContainer, it works - but SimpleMessageListenerContainer doesn't recover after a connection loss

There are no errors in the logs, and hardly any relevant messages. Does anyone have any reasons for why this may be happening?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When constructing the container in Java (outside a Spring application context), you need to invoke afterPropertiesSet() before start().

The context does that automatically for Spring beans.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...