Some Fixes and Improvements
* Fix several typos in log messages. And some test on the matter as well * Add comment to `AbstractPersistentAcceptOnceFileListFilter.rollback()` to clarify the reason of `rollingBack` variable * Make `RemoteFileTemplate.StreamHolder` as `static` to avoid extra internal variable to outer class instance * Replace `MessagingException` with `AbstractInboundFileSynchronizingMessageSource` in `init()` method of some components. It isn't Messaging yet in that phase * Fix `SubscribableRedisChannel.MessageListenerDelegate` to handle `Object` not `String`, because with the `serializer` injection there is no guaranty that incoming is always `String` * Move `JSch.setLogger(new JschLogger());` in the `DefaultSftpSessionFactory` to `static` block. It really should be done only once * Remove `Assert.isTrue(this.port >= 0)` from the `DefaultSftpSessionFactory`. The subsequant `initJschSession()` convert it to default `22` port * Change in the `JschProxyFactoryBean` `UnsupportedOperationException` to `IllegalArgumentException`. Wrong enum is wrong argument. That isn't a problem of operation * Simplify `stop()` in the `CuratorFrameworkFactoryBean` and mark it as a `this.running = false`. Otherwise it wasn't able to be restarted * Expose `leaderEventPublisher` in the `LeaderInitiatorFactoryBean` and fix `stop(Runnable callback)` with propagation `callback` to delegate. Fix `SubscribableRedisChannelTests` for new `handleMessage(Object)` signature
This commit is contained in:
committed by
Gary Russell
parent
28216013dd
commit
7124136091
@@ -50,14 +50,19 @@ import org.springframework.util.StringUtils;
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @since 2.0
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class SubscribableRedisChannel extends AbstractMessageChannel implements SubscribableChannel, SmartLifecycle, DisposableBean {
|
||||
public class SubscribableRedisChannel extends AbstractMessageChannel
|
||||
implements SubscribableChannel, SmartLifecycle, DisposableBean {
|
||||
|
||||
private final RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
|
||||
private final RedisConnectionFactory connectionFactory;
|
||||
|
||||
private final RedisTemplate redisTemplate;
|
||||
|
||||
private final String topicName;
|
||||
|
||||
private final BroadcastingDispatcher dispatcher = new BroadcastingDispatcher(true);
|
||||
@@ -68,7 +73,9 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
|
||||
// defaults
|
||||
private volatile Executor taskExecutor = new SimpleAsyncTaskExecutor();
|
||||
|
||||
private volatile RedisSerializer<?> serializer = new StringRedisSerializer();
|
||||
|
||||
private volatile MessageConverter messageConverter = new SimpleMessageConverter();
|
||||
|
||||
public SubscribableRedisChannel(RedisConnectionFactory connectionFactory, String topicName) {
|
||||
@@ -130,7 +137,8 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
}
|
||||
super.onInit();
|
||||
if (this.maxSubscribers == null) {
|
||||
Integer maxSubscribers = this.getIntegrationProperty(IntegrationProperties.CHANNELS_MAX_BROADCAST_SUBSCRIBERS, Integer.class);
|
||||
Integer maxSubscribers =
|
||||
getIntegrationProperty(IntegrationProperties.CHANNELS_MAX_BROADCAST_SUBSCRIBERS, Integer.class);
|
||||
this.setMaxSubscribers(maxSubscribers);
|
||||
}
|
||||
if (this.messageConverter == null) {
|
||||
@@ -161,7 +169,7 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
|
||||
@Override
|
||||
public boolean isAutoStartup() {
|
||||
return (this.container != null) ? this.container.isAutoStartup() : false;
|
||||
return (this.container != null) && this.container.isAutoStartup();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -171,7 +179,7 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return (this.container != null) ? this.container.isRunning() : false;
|
||||
return (this.container != null) && this.container.isRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,8 +213,8 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
private class MessageListenerDelegate {
|
||||
|
||||
@SuppressWarnings({ "unused", "unchecked" })
|
||||
public void handleMessage(String s) {
|
||||
Message<?> siMessage = SubscribableRedisChannel.this.messageConverter.toMessage(s, null);
|
||||
public void handleMessage(Object payload) {
|
||||
Message<?> siMessage = SubscribableRedisChannel.this.messageConverter.toMessage(payload, null);
|
||||
try {
|
||||
SubscribableRedisChannel.this.dispatcher.dispatch(siMessage);
|
||||
}
|
||||
@@ -215,9 +223,10 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
topicName = StringUtils.hasText(topicName) ? topicName : "unknown";
|
||||
throw new MessageDeliveryException(siMessage, e.getMessage()
|
||||
+ " for redis-channel '"
|
||||
+ topicName + "' (" + SubscribableRedisChannel.this.getFullChannelName()
|
||||
+ ").", e);
|
||||
+ topicName
|
||||
+ "' (" + SubscribableRedisChannel.this.getFullChannelName() + ").", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public class SubscribableRedisChannelTests extends RedisAvailableTests {
|
||||
MessageListenerAdapter listener = channelMapping.entrySet().iterator().next().getValue().iterator().next();
|
||||
Object delegate = TestUtils.getPropertyValue(listener, "delegate");
|
||||
try {
|
||||
ReflectionUtils.findMethod(delegate.getClass(), "handleMessage", String.class).invoke(delegate,
|
||||
ReflectionUtils.findMethod(delegate.getClass(), "handleMessage", Object.class).invoke(delegate,
|
||||
"Hello, world!");
|
||||
fail("Exception expected");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user