INT-3319 Fix BeanFactory Propagation
JIRA: https://jira.spring.io/browse/INT-3319 The `MessageBuilderFactory` abstraction relies on the bean factory being propagated to all classes that create messages. Some classes were missed in the initial PR.
This commit is contained in:
committed by
Artem Bilan
parent
1c9bcaccee
commit
75af72a77c
@@ -102,7 +102,9 @@ public class SubscribableJmsChannel extends AbstractJmsChannel implements Subscr
|
||||
|
||||
private void configureDispatcher(boolean isPubSub) {
|
||||
if (isPubSub) {
|
||||
this.dispatcher = new BroadcastingDispatcher(true);
|
||||
BroadcastingDispatcher broadcastingDispatcher = new BroadcastingDispatcher(true);
|
||||
broadcastingDispatcher.setBeanFactory(this.getBeanFactory());
|
||||
this.dispatcher = broadcastingDispatcher;
|
||||
}
|
||||
else {
|
||||
UnicastingDispatcher unicastingDispatcher = new UnicastingDispatcher();
|
||||
|
||||
@@ -337,6 +337,9 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
|
||||
this.container = this.createContainer();
|
||||
SubscribableJmsChannel subscribableJmsChannel = new SubscribableJmsChannel(this.container, this.jmsTemplate);
|
||||
subscribableJmsChannel.setMaxSubscribers(this.maxSubscribers);
|
||||
if (this.getBeanFactory() != null) {
|
||||
subscribableJmsChannel.setBeanFactory(this.getBeanFactory());
|
||||
}
|
||||
this.channel = subscribableJmsChannel;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.jms.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,6 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.integration.jms.PollableJmsChannel;
|
||||
import org.springframework.integration.jms.SubscribableJmsChannel;
|
||||
import org.springframework.integration.support.MessageBuilderFactory;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
@@ -116,6 +118,9 @@ public class JmsChannelParserTests {
|
||||
@Autowired
|
||||
private AbstractApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
private MessageBuilderFactory messageBuilderFactory;
|
||||
|
||||
|
||||
@After
|
||||
public void closeContext() {
|
||||
@@ -172,8 +177,12 @@ public class JmsChannelParserTests {
|
||||
AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) accessor.getPropertyValue("container");
|
||||
assertEquals(topic, jmsTemplate.getDefaultDestination());
|
||||
assertEquals(topic, container.getDestination());
|
||||
assertSame(this.messageBuilderFactory, TestUtils.getPropertyValue(channel, "dispatcher.messageBuilderFactory"));
|
||||
assertSame(this.messageBuilderFactory,
|
||||
TestUtils.getPropertyValue(channel, "container.messageListener.messageBuilderFactory"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void topicNameChannel() {
|
||||
assertEquals(SubscribableJmsChannel.class, topicNameChannel.getClass());
|
||||
|
||||
Reference in New Issue
Block a user