驼峰式 IP 地址缓存

huangapple 未分类评论47阅读模式
英文:

Camel Ip Address caching

问题

我在camel路由中有一个URL,通过JVM自定义属性进行设置,它保持不变。

**<camel:to id="to-server" uri="{{serverURL}}" />**

serverURL属性设置为站点负载均衡器地址http://xyz:8080/Server/transactionServlet

在网络层面上,这个URL可以指向服务器1或服务器2,无论我们使用哪个服务器,该URL都应该正常工作。

在从服务器1切换到服务器2之后,我们的WAR仍然尝试向服务器1发送请求,但失败了。
似乎我们的WAR在启动时会缓存URL地址(站点负载均衡器当时指向的地址),并且不会意识到我们已经切换了。
唯一的解决方法是重新启动应用程序WAR,此时它会存储服务器2的地址(站点负载均衡器现在指向的地址),并开始将事务发布到服务器2。

是否有办法让camel不缓存IP地址,并且将请求发送到指向的任何服务器URL?
我正在使用Apache Camel 2.14
英文:

I have a URL in camel route which is set via JVM custom property and it remains unchanged.

	**<camel:to id="to-server" uri="{{serverURL}}" />**

serverURL property is set to a site loadbalancer address http://xyz:8080/Server/transactionServlet

In the network layer this URL can either be pointed to Server 1 or Server 2, the URL should work regardless of which server we're using.

After the switch over from Server 1 to Server 2, our WAR still tries to post to Server 1 and fails.
It appears that our WAR is caching the the URL address (what the site loadbalancer was pointing to at the time) when it was started and does not recognize that we have switched over.
The only workaround is to restart the application WAR, at which point it stores the Server 2 address (what the site loadbalancer is now pointing to) and begins posting transactions to Server 2.

is there any way to make camel not cache the IP Address and post to whatever server URL is pointing to ?
I am using Apache Camel 2.14

答案1

得分: 0

请查看 networkaddress.cache.ttl

> 在 java.security 中指定,用于指示从名称服务中成功的名称查找的缓存策略。该值被指定为整数,以表示缓存成功查找的秒数。
值为 -1 表示“永久缓存”。默认情况下,当安装了安全管理器时,会永久缓存;当未安装安全管理器时,会缓存一段特定的时间。

英文:

Have a look at networkaddress.cache.ttl.

> Specified in java.security to indicate the caching policy for successful name lookups from the name service.. The value is specified as integer to indicate the number of seconds to cache the successful lookup.
A value of -1 indicates "cache forever". The default behavior is to cache forever when a security manager is installed, and to cache for an implementation specific period of time, when a security manager is not installed.

huangapple
  • 本文由 发表于 2020年5月29日 15:02:28
  • 转载请务必保留本文链接:https://java.coder-hub.com/62080401.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定