Ce contenu n'est pas disponible dans la langue sélectionnée.

Chapter 58. Jolokia


Jolokia starter integrates the Jolokia agent configuration in Spring Boot. It wraps the Spring Support by adding the default configurations to let the application work out-of-the-box without manually declaring Jolokia servers. This starter can be considered as an alternative to the Jolokia JVM agent.

58.1. Dependencies

When using camel-jolokia with Red Hat build of Camel Spring Boot, add the following Maven dependency to your pom.xml to have support for auto configuration:

<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-jolokia-starter</artifactId>
</dependency>

This exposes the Jolokia endpoint at http://0.0.0.0:8778/jolokia/ . The agent can be configured according to the Jolokia Spring support page using the property prefix camel.component.jolokia. It is possible to configure camel.component.jolokia.lookup-config=true.

58.2. Using Jolokia agent

It is possible to configure the Jolokia server accessing the configuration map via properties according to the Jolokia agent configuration using camel.component.jolokia.server-config map configuration, that is, camel.component.jolokia.server-config.port=8779 or camel.component.jolokia.server-config.authMode=jaas. The value of the discoveryEnabled configuration key is set to true on JVM local environment (not on Kubernetes), to allow the Hawtio process to discover the Jolokia agent. It is possible to disable the default configuration by setting the camel.component.jolokia.server-config.discoveryEnabled=false.

58.3. Using Jolokia Restrictor

To avoid exposing all the JMX MBeans (see Security considerations), it provides a default Jolokia Restrictor that allows only Camel related data and some basic information from java. It is possible to avoid using the restrictor with the property camel.component.jolokia.use-camel-restrictor=false or to use your own custom one with the property camel.component.jolokia.server-config.restrictorClass=org.example.MyRestrictor.

An example to extend the provided restrictor is shown below.

Example

public class MyRestrictor extends CamelRestrictor {

	//getDefaultDomains() contains default domains, if you want to add some domain to the existing list
	@Override
	protected List<String> getAllowedDomains() {
		final List<String> newDomains = new ArrayList<>(getDefaultDomains());
		newDomains.add("my.domain");
		return newDomains;
	}
}

58.4. Implementing Spring Jolokia configuration

The starter creates a default configuration according to the provided properties, that covers all the configuration for the Jolokia agent/server but if you want to use your custom SpringJolokiaConfigHolder implementation, it is possible to declare in the Spring context a Bean named camelConfigHolder.

Example of camelConfigHolder

    @Bean("camelConfigHolder")
    public SpringJolokiaConfigHolder myConfigHolder() {
        final SpringJolokiaConfigHolder myConfig = new SpringJolokiaConfigHolder();
        myConfig.setConfig(Map.of("threadNr", "5", "executor", "fixed"));
        return myConfig;
    }

In this case, the executor configuration will be taken from the custom Bean if the same properties are not defined in the application.properties. This behaviour is also configurable with the property camel.component.jolokia.config-from-properties-first=false. It means that the configuration, in case the key is present in both application.properties and Bean implementation, uses the one from Bean. If the keys from properties and beans are not overridden each other, the simple merge will be applied. This way, the configuration properties allow to cover all the configurable aspect of the Jolokia server.

58.5. Using Camel log handler holder configuration

There is a log configuration also provided in the starter that uses the slf4j implementation. You can change this configuration by providing a Bean named camelLogHandlerHolder.

Example of camelLogHandlerHolder

    @Bean
	@ConditionalOnMissingBean(name = "camelLogHandlerHolder")
	public SpringJolokiaLogHandlerHolder myLogHandlerHolder() {
		final SpringJolokiaLogHandlerHolder stdoutHandlerHolder = new SpringJolokiaLogHandlerHolder();
		stdoutHandlerHolder.setType("stdout");
		return stdoutHandlerHolder;
	}

The category for the Camel Spring Boot starter is org.apache.camel.component.jolokia while it is possible to configure level of the core Jolokia server with org.jolokia.

Example in application.properties

logging.level.org.apache.camel.component.jolokia = TRACE
logging.level.org.jolokia = TRACE

58.6. Using Jolokia configuration in Kubernetes

The starter also provides some default configurations for a Kubernetes cluster environment. The starter checks the existence of a specific file to use as certification authority (/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt) and, if this file exists, it initializes the server using TLS protocol and client authentication. So the endpoint become https://0.0.0.0:8778/jolokia/. It is possible to avoid this behaviour with the property camel.component.jolokia.kubernetes-discover=false.

The wrapped library Jolokia Spring Support provides the integration with the Spring Boot Actuator as per configuration where it is possible to retrieve information about Jolokia server. As any other actuator endpoint, it is possible to be excluded or disabled.

Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2026 Red Hat
Retour au début