我可以在同一个Spring Boot应用程序中拥有两个@ClientCacheApplication吗?

时间:2019-04-15 23:09:35

标签: gemfire spring-data-gemfire

在同一个 Spring Boot 应用程序中可以有两个@ClientCacheApplication实例吗?

我有两个班级:PeopleDataAccessJobDataAccess。他们俩都是@ClientCacheApplication

@Service
@ClientCacheApplication(name = "AccessingDataGemFireApplication", logLevel = "error")
@EnableEntityDefinedRegions(basePackageClasses = People.class, clientRegionShortcut = ClientRegionShortcut.LOCAL)
@EnableGemfireRepositories(basePackageClasses = PeopleRepository.class)
public class PeopleDataAccess {

  @Autowired
  PeopleRepository peopleRepository;

  public void saveRecord() {
    People alice = new People("Adult Alice", 40);
    People bob = new People("Baby Bob", 1);
    People carol = new People("Teen Carol", 13);
    peopleRepository.save(alice);
    peopleRepository.save(bob);
    peopleRepository.save(carol);
  }
}


@Service
@ClientCacheApplication(name = "AccessingDataGemFireApplication", logLevel = "error")
@EnableEntityDefinedRegions(basePackageClasses = Job.class, clientRegionShortcut = ClientRegionShortcut.LOCAL)
@EnableGemfireRepositories(basePackageClasses = JobRepository.class)
public class JobDataAccess {

  @Autowired
  JobRepository jobRepository;

  public void saveRecord() {
    Job firemen = new Job("Firemen");
    Job accounting = new Job("Accounting");
    jobRepository.save(firemen);
    jobRepository.save(accounting);
  }
}

1 个答案:

答案 0 :(得分:1)

简短答案...否。对于Pivotal GemFire / Apache Geode,任何缓存实例(无论是ClientCache还是同级Cache(用于服务器端))都是 Singleton < / em>。也就是说,每个JVM只能有1个实例。

也许您能描述您的UC以及您要完成的工作,我可以提供更多指导吗?