How to read jmx mbean using Spring, within the same process - jmx

I want to read C3P0 JMX MBean to extract some of the attributes, and expose over one of the rest endpoint. How can I read Jmx bean using spring within the same process ?.

Related

Configure Spring Cloud Task to use Kafa of Spring Cloud Data Flow server

I have a Spring Cloud Data Flow (SCDF) server running on Kubernetes cluster with Kafka as the message broker. Now I am trying to launch a Spring Cloud Task (SCT) that writes to a topic in Kafka. I would like the SCT to use the same Kafka that SCDF is using. This brings up two questions that I have and hope they can be answered:
How to configure the SCT to use the same Kafka as SCDF?
Is it possible to configure the SCT so that the Kafka server uri can be passed to the SCT automatically when it launches, similar to
the data source properties that get passed to the SCT at launch?
As I could not find any examples on how to achieve this, help is very appreciated.
Edit: My own answer
This is how I get it working for my case. My SCT requires spring.kafka.bootstrap-servers to be supplied. From SCDF's shell, I provide it as an argument --spring.kafka.bootstrap-servers=${KAFKA_SERVICE_HOST}:${KAFKA_SERVICE_PORT}, where KAFKA_SERVICE_HOST and KAFKA_SERVICE_PORT are environment variables created by SCDF's k8s setup script.
This is how to launch the task within SCDF's shell
dataflow:>task launch --name sample-task --arguments "--spring.kafka.bootstrap-servers=${KAFKA_SERVICE_HOST}:${KAFKA_SERVICE_PORT}"
You may want to review the Spring Cloud Task Events section in the reference guide.
The expectation is that you'd choose the binder of choice and pack that library in the Task application's classpath. With that dependency, you'd then configure the application with Spring Cloud Stream's Kafka binder properties such as the spring.cloud.stream.kafka.binder.brokers and others that are relevant to connect to the existing Kafka cluster.
Upon launching the Task application (from SCDF) with these configurations, you'd be able to publish or receive events in your Task app.
Alternatively, with the Kafka-binder in the classpath of the Task application, you can define the Kafka binder properties to all the Task's launched by SCDF via global configuration. See Common Application Properties in the ref. guide for more information. In this model, you don't have to configure each of the Task application with Kafka properties explicitly, but instead, SCDF would propagate them automatically when it launches the Tasks. Keep in mind that these properties would be supplied to all the Task launches.

Solace JCA using JBoss JNDI

The JCA resource adapter uses Solace as a JNDI store for fetching connection and destinations. We are looking at an option where Solace JNDI option is disabled at the broker but the application needs to be fetch the connection factory/destinations using JNDI lookup in JBOSS server. Is this feasible?
This feature will be available in the upcoming release of the Solace JMS Resource Adapter. In this release, there will be the option to configure your application to use a non-Solace JNDI store. This can be done by setting the JNDI provider's (in your case, JBoss) Connection URL, username, and password in the Resource Adapter's bean properties.

OpenNMS skipping certain JMX MXBeans while collection

I have exposed an MBean NotifyFailedTriggers that exposes an Integer value. I have configured the poller, collectd and jmx-datacollection config files correctly. However, the collectd daemon seems to be skipping the mbean saying it is not registered. See the attached log.
2018-06-12 13:08:41,204 DEBUG [pool-10-thread-8] o.o.n.j.i.DefaultJmxCollector: Collecting MBean (objectname=com.example:name=notifyFailedTriggers, wildcard=false)
2018-06-12 13:08:41,205 DEBUG [pool-10-thread-8]
o.o.n.j.i.DefaultJmxCollector: Collecting ObjectName
com.example:name=notifyFailedTriggers
2018-06-12 13:08:41,328 DEBUG [pool-10-thread-8]
o.o.n.j.i.DefaultJmxCollector: ObjectName
com.example:name=notifyFailedTriggers is not registered.
2018-06-12 13:08:41,329 DEBUG [pool-10-thread-8]
o.o.n.j.i.DefaultJmxCollector: Skip ObjectName
com.example:name=notifyFailedTriggers
2018-06-12 13:08:41,510 INFO [Collectd-Thread-15-of-50]
o.o.n.c.CollectableService: run: finished collection for
3/xx.xx.84.122/onms-poc/example1
2018-06-12 13:08:41,510 DEBUG [Collectd-Thread-15-of-50]
o.o.n.s.LegacyScheduler: schedule: Adding ready runnable
CollectableService for service 3:/xx.xx.84.122:onms-poc (ready in
300000ms) at interval 300000
This is a standalone java application that is exposing the MXBeans.
Is there a specific reason why it considers this MXBean to be unregistered and hence skipping it?
In a nutshell, it considers the MXBean to be unregistered if the MBean server says that it is. You may need to configure the application to enable certain beans, or perhaps the version of the application that you're using does not support the particular bean in question.
Behind the curtain, the JMX collector asks the MBean server whether the object is registered. If the MBean server responds that it is not, the JMX collector logs the message you pasted. Here's the JMX collector code where that happens, and here's the documentation of the "isRegistered" method that it's calling to make that determination.

Get WildFly/Keycloak datasources pool statistics via JMX

I'm using Keycloak 3.4.3.Final version in domain mode.
And I can obtain DataSources statistics (like ActiveCount,AviableCount,..)
from WildFly management console.
But when I connect remotely via JMX to some cluster node using JConsole,
MBeans tab of JConsole doesn't contain information about pool statistics-
only some static information about configuration is shown
in jboss.as/auth-server-clustered/datasources item
Is it possible to get this statstics via JMX?

spring boot + secure jmx

By default spring boot exposes a number of JMX endpoints, has anyone had any experience securing these, it seems there is no security surrounding JMX.
The only config available to Spring boot:
endpoints.jmx.enabled=true
endpoints.jmx.domain= # the JMX domain, defaults to 'org.springboot'
endpoints.jmx.unique-names=false
endpoints.jmx.enabled=true
endpoints.jmx.staticNames=
I have seen examples using JmxSecurityAuthenticator, should I follow this pattern.
AFAIK securing the JMX connections is all about how you set up the server. I think you just need to add a #Bean of type ConnectorServerFactoryBean.

Resources