Java runtime caches both of successful and unsuccessful DNS name lookups results. Each of the caches gets a time-to-live (TTL) setting controlling how long a DNS lookup result can be held in the cache.
According the Java Doc, the following security properties are configurable for the caching policy:
The settings are stored in $JAVA_HOME/jre/lib/security/java.security, which can be modified in On-Premises environment. However it is hard to change the settings in CloudHub environment as a normal user doesn't have direct access to CloudHub workers.
Hence, this article is about how to adjust Java caching policy for DNS name lookups in CloudHub environment.
mvn install:install-file -Dfile=mulesoftsupport-tools-1.0-SNAPSHOT.jar -DpomFile=mulesoftsupport-tools-1.0-SNAPSHOT.pom
<dependency> <groupId>com.mulesoftsupport.tools</groupId> <artifactId>mulesoftsupport-tools</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
<flow name="setjavainetaddresscacheMule3Flow">
<poll doc:name="Poll">
<fixed-frequency-scheduler frequency="86400" timeUnit="SECONDS" startDelay="10"/>
<logger message="Setting InetAddress Cache TTL - #[com.mulesoftsupport.tools.App.setInetAddressCacheTTL(60,20)]" level="INFO" doc:name="Setting InetAddress Cache TTL"/>
</poll>
<logger message="Result: networkaddress.cache.ttl = #[sun.net.InetAddressCachePolicy.get()] networkaddress.cache.negative.ttl = #[sun.net.InetAddressCachePolicy.getNegative()]" level="INFO" doc:name="Print Result"/>
</flow>
Note: a deployable Mule 3 app is available in the zip file for test purpose<flow name="setjavainetaddresscacheMule4Flow" doc:id="4d40099d-3be8-462a-92d4-59108fbb2096" > <scheduler doc:name="Scheduler" doc:id="25125c75-22c3-46e2-b5e9-24a7d4872698" > <scheduling-strategy > <fixed-frequency frequency="100" timeUnit="DAYS"/> </scheduling-strategy> </scheduler> <logger level="INFO" doc:name="Setting InetAddress Cache TTL" doc:id="c360ee8f-63c7-4c3d-9a13-4485e112088f" message='#[%dw 2.0 output application/java --- "Setting InetAddress Cache TTL - " ++ java!com::mulesoftsupport::tools::App::setInetAddressCacheTTL(60, 20)]'/> <logger level="INFO" doc:name="Print Result" doc:id="026e7276-d2af-4496-a0f9-4152a6d51378" message='#[%dw 2.0 output application/json --- "Result: networkaddress.cache.ttl=" ++ java!sun::net::InetAddressCachePolicy::get() ++ " networkaddress.cache.negative.ttl=" ++ java!sun::net::InetAddressCachePolicy::getNegative()]'/> </flow>Note: a deployable Mule 4 app is available in the zip file for test purpose
DNS Resolution Cache In Mule Runtime And HTTP Connector
Disclaimer: the artifacts and source in the attached zip file are provided as reference for your own usage and they are not part of the official Mule product so their use will be considered as custom implementation made by the customer.
001116017

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.