Este contenido no está disponible en el idioma seleccionado.

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

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2026 Red Hat
Volver arriba