이 콘텐츠는 선택한 언어로 제공되지 않습니다.

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>
Copy to Clipboard Toggle word wrap

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;
	}
}
Copy to Clipboard Toggle word wrap

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;
    }
Copy to Clipboard Toggle word wrap

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;
	}
Copy to Clipboard Toggle word wrap

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
Copy to Clipboard Toggle word wrap

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

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동