在Tomcat集群中,如何在应用程序中共享bean? [英] In a Tomcat cluster, how to share beans in an application?

查看:138
本文介绍了在Tomcat集群中,如何在应用程序中共享bean?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这听起来像是一个愚蠢的问题或一个简单的问题,但是我对任何类型的集群的经验都很少甚至没有,我只是好奇是否以及如何可能出现某种情况。

This might sound like a dumb or a simple question, but I really have little to no experience with clustering of any kind and I'm just curious if and how a certain scenario is possible.

比方说,我已经建立了N个Tomcat实例的集群,并且已经在所有N个实例中部署了应用程序 App1

Let's say I've set up a cluster of N Tomcat instances, and I've deployed my application App1 across all N instances.

要在应用程序中具有某些bean(不是全部,而是某些)在整个集群中共享,我需要做些什么?

What would I need to do to be able to have certain beans in the application - not all, but some - be "shared" across the cluster?

即,如果我有一个用于 WebsiteSettings 的bean,我希望有一些查找过程,应用程序可以在其中寻找该bean并给定它的一个实例,并且该bean的属性/值的任何更新也可用于集群中的任何其他机器,即 WebsiteSettings.getGreeting()将返回相同的值

i.e., if I had a bean for WebsiteSettings, I'd like to have some lookup process where the application could ask for the bean and be given an instance of it, and any updates to the bean's properties/values are also available to any other machines in the cluster, i.e., WebsiteSettings.getGreeting() would return the same value on all N machines whenever it was updated.

我是否需要将这些bean设置为MBean,并具有 App1 查找它们vi一个JMX? Tomcat的集群支持是否会负责将MBean中的更改自动复制到集群中的所有节点?

Do I need to set these beans up as MBeans, and have App1 look them up via JMX? Will Tomcat's clustering support then take care of replicating changes in the MBean to all node's in the cluster automatically?

推荐答案

请看看在 Terracotta 上-它使您可以将同一个对象(以某种方式)驻留在许多实例上,其中所有实例其他节点的更新是在JVM级别而不是在代码中无缝完成的。

Please take a look at Terracotta - it allows you to have the same object (in a way) reside on many instances, where all the updates of the other nodes are done seamlessle in the JVM level and not in your code.

您可能想了解一下以获取更多信息-什么是兵马俑

You may want to take a look at this for further information - What Is Terracotta

这篇关于在Tomcat集群中,如何在应用程序中共享bean?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆