Spring Integration RedisLockRegistry示例

时间:2017-07-04 04:16:42

标签: spring

我想使用Spring Integration RedisLockRegistry。我对Spring Integration RedisLockRegistry有一些疑问。

  1. 我可以将redisLockRegistry用作Spring bean吗?这意味着我的应用程序只需一个redisLockRegistry

  2. 我在版本5.0中看到RedisLockRegistry工具ExpirableLockRegistry

  3. 我是否需要运行expireUnusedOlderThan方法?

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题并开始分析弹簧代码。所以从我的来源我可以说:

  1. 是的,您可以创建并将其配置为LockRegistry RedisLockRegistry的任何实例的bean,例如JdbcLockRegistryPassThruLockRegistry。出于测试目的,我甚至想使用expireUnusedOlderThan

  2. 我试图在Spring中找到@Autowired private ExpirableLockRegistry lockRegistry; @Scheduled(fixedDelay=50000) public void cleanObsolete(){ lockRegistry.expireUnusedOlderThan(50000); } 的任何调用但没有成功。

  3. 所以我创建了如下简单的调度程序:

    <UserControl
    x:Class="UniversalProject.UWP.Controls.TabHeader"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:UniversalProject.UWP.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" Width="64" Height="68" IsTabStop="False"
    d:DesignHeight="300"
    d:DesignWidth="400">
    
    <StackPanel >
        <FontIcon
            HorizontalAlignment="Center"
            Margin="0,12,0,0"
            Glyph="{Binding Glyph}"
            FontSize="16" />
        <TextBlock
            FontFamily="Segoe UI"
            Text="{Binding Label}"
            Style="{StaticResource CaptionTextBlockStyle}"
            LineStackingStrategy="BlockLineHeight"
            LineHeight="14"
            MaxLines="2"
            IsTextScaleFactorEnabled="False"
            TextAlignment="Center"
            HorizontalAlignment="Center"
            Margin="2,5,2,7" />
    </StackPanel>