buildscript{repositories{mavenCentral()}dependencies{classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")}}applyplugin:'java'applyplugin:'maven'applyplugin:'eclipse'applyplugin:'idea'applyplugin:'org.springframework.boot'applyplugin:'io.spring.dependency-management'group='com.gowhich'version='0.0.1-SNAPSHOT'description="""Demo project for Spring Boot"""bootJar{baseName='spring-demo'version='1.0'}sourceCompatibility=1.8targetCompatibility=1.8tasks.withType(JavaCompile){options.encoding='UTF-8'}repositories{mavenCentral()}dependencies{compilegroup:'org.springframework.boot',name:'spring-boot-starter-web',version:'2.0.2.RELEASE'compilegroup:'org.springframework.boot',name:'spring-boot-starter-jdbc',version:'2.0.2.RELEASE'compilegroup:'com.h2database',name:'h2',version:'1.4.197'compilegroup:'org.springframework.boot',name:'spring-boot-starter-thymeleaf',version:'2.0.2.RELEASE'compilegroup:'org.springframework.boot',name:'spring-boot-starter-security',version:'2.0.2.RELEASE'compilegroup:'org.springframework.ldap',name:'spring-ldap-core',version:'2.3.2.RELEASE'compilegroup:'org.springframework.security',name:'spring-security-ldap',version:'5.0.5.RELEASE'compilegroup:'com.unboundid',name:'unboundid-ldapsdk',version:'4.0.5'compilegroup:'org.springframework.social',name:'spring-social-facebook',version:'2.0.3.RELEASE'compilegroup:'com.fasterxml.jackson.core',name:'jackson-core',version:'2.9.5'compilegroup:'org.springframework.security',name:'spring-security-crypto',version:'5.0.5.RELEASE'compilegroup:'org.springframework.social',name:'spring-social-core',version:'1.1.6.RELEASE'compilegroup:'org.springframework.social',name:'spring-social-security',version:'1.1.6.RELEASE'compilegroup:'org.springframework.security',name:'spring-security-core',version:'5.0.6.RELEASE'compilegroup:'org.springframework.boot',name:'spring-boot-starter-data-redis',version:'2.0.4.RELEASE'testCompilegroup:'org.springframework.boot',name:'spring-boot-starter-test',version:'2.0.2.RELEASE'testCompilegroup:'org.springframework.security',name:'spring-security-test',version:'5.0.5.RELEASE'}
privatestaticfinalLoggerLOGGER=LoggerFactory.getLogger(SpringDemoApplication.class);@BeanRedisMessageListenerContainercontainer(RedisConnectionFactoryconnectionFactory,MessageListenerAdapterlistenerAdapter){RedisMessageListenerContainercontainer=newRedisMessageListenerContainer();container.setConnectionFactory(connectionFactory);container.addMessageListener(listenerAdapter,newPatternTopic("chat"));returncontainer;}@BeanMessageListenerAdapterlistenerAdapter(Receiverreceiver){returnnewMessageListenerAdapter(receiver,"receiveMessage");}@BeanReceiverreceiver(CountDownLatchlatch){returnnewReceiver(latch);}@BeanCountDownLatchlatch(){returnnewCountDownLatch(1);}@BeanStringRedisTemplatetemplate(RedisConnectionFactoryconnectionFactory){returnnewStringRedisTemplate(connectionFactory);}publicstaticvoidmain(String[]args)throwsInterruptedException{ApplicationContextctx=SpringApplication.run(SpringDemoApplication.class,args);StringRedisTemplatetemplate=ctx.getBean(StringRedisTemplate.class);CountDownLatchlatch=ctx.getBean(CountDownLatch.class);LOGGER.info("Sending message ...");template.convertAndSend("chat","Hello from walkerfree!");latch.await();System.exit(0);}