Re: Testing JMX with camel-test-junit5

2024-01-01 Thread Claus Ibsen
Hi

Have you added camel-management as a dependency.

On Tue, Jan 2, 2024 at 2:15 AM Steve973  wrote:

> Hello.  I have a CamelSpringBootTest, and I am trying to test that my
> mbeans have been registered.  This is how I am trying to check:
>
> @CamelSpringTest
> @ContextConfiguration
> @DirtiesContext(classMode =
> DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
> class DynamicRouterJmxIT {
>
> @Autowired
> CamelContext camelContext;
>
> @Test
> void testExpectedMbeansExist() throws MalformedObjectNameException {
> Assertions.assertTrue(camelContext.isStarted());
> MBeanServer mBeanServer =
> camelContext.getManagementStrategy().getManagementAgent().getMBeanServer();
> ObjectName name = new
>
> ObjectName("org.apache.camel:context=camelContext,type=routes,name=\"testRoute\"");
> DynamicRouterControlService controlMbean =
> JMX.newMBeanProxy(mBeanServer, name,
> DynamicRouterControlService.class);
> DynamicRouterFilterService filterMbean =
> JMX.newMBeanProxy(mBeanServer, name,
> DynamicRouterFilterService.class);
> Assertions.assertNotNull(controlMbean);
> Assertions.assertNotNull(filterMbean);
> }
> }
>
> Here is the XML that I am using for it, called
> DynamicRouterJmxIT-context.xml:
>
> http://www.springframework.org/schema/beans";
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>xsi:schemaLocation="
>http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
>http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd";>
>
>   http://camel.apache.org/schema/spring";>
> 
> 
> 
>   
>   
> 
> 
>   
>   
> 
>   
> 
>
>
> I keep getting this error:
>
> Cannot invoke "org.apache.camel.spi.ManagementAgent.getMBeanServer()"
> because the return value of
> "org.apache.camel.spi.ManagementStrategy.getManagementAgent()" is null
>
> What am I doing wrong?
>
> Thanks,
> Steve
>


-- 
Claus Ibsen
-
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Testing JMX with camel-test-junit5

2024-01-01 Thread Steve973
Hello.  I have a CamelSpringBootTest, and I am trying to test that my
mbeans have been registered.  This is how I am trying to check:

@CamelSpringTest
@ContextConfiguration
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
class DynamicRouterJmxIT {

@Autowired
CamelContext camelContext;

@Test
void testExpectedMbeansExist() throws MalformedObjectNameException {
Assertions.assertTrue(camelContext.isStarted());
MBeanServer mBeanServer =
camelContext.getManagementStrategy().getManagementAgent().getMBeanServer();
ObjectName name = new
ObjectName("org.apache.camel:context=camelContext,type=routes,name=\"testRoute\"");
DynamicRouterControlService controlMbean =
JMX.newMBeanProxy(mBeanServer, name,
DynamicRouterControlService.class);
DynamicRouterFilterService filterMbean =
JMX.newMBeanProxy(mBeanServer, name,
DynamicRouterFilterService.class);
Assertions.assertNotNull(controlMbean);
Assertions.assertNotNull(filterMbean);
}
}

Here is the XML that I am using for it, called
DynamicRouterJmxIT-context.xml:

http://www.springframework.org/schema/beans";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
   http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd";>

  http://camel.apache.org/schema/spring";>



  
  


  
  

  



I keep getting this error:

Cannot invoke "org.apache.camel.spi.ManagementAgent.getMBeanServer()"
because the return value of
"org.apache.camel.spi.ManagementStrategy.getManagementAgent()" is null

What am I doing wrong?

Thanks,
Steve


Re: Adding http(s) compatibility to a component (for discoverable service compatibility)

2024-01-01 Thread Steve973
Thank you for your insight, Claus!  While I am trying to add things that
will be as useful as possible to people, I do not always know what would be
best for the community.  Instead of discovery, I will add some
component-specific JMX monitoring and control through the @Managed*
annotations.  This will include subscription control, and
filter/subscription statistics.  If you can think of anything else that I
can add, or at least some popular use cases, or newer/emerging use cases
that are gaining popularity, please let me know.  Also, if you know of some
tickets that will help me learn Camel better, feel free to point me to
them.  I can usually find some time to contribute more.

Thanks,
Steve

On Sat, Dec 30, 2023 at 10:14 AM Claus Ibsen  wrote:

> Hi
>
> There is this ticket
> https://issues.apache.org/jira/browse/CAMEL-18546
>
> Its about being able to have a list of hosted services by the current Camel
> application, that can be exposed for tooling and end users.
> This is not intended as a distributed service registrt ala Consul or
> whatever. But a quick way to find out if there is a service in this running
> Camel application,
> and if so, how to access it.
>
> However for your dynamic router component, it seems you talk about being
> able to manage it via HTTP.
>
> Camel components are usually made managable via JMX, and then you can also
> make a "dev console" that is intended for developers to quickly see some
> information
> from it via a http web console (not for production management), but those
> dev consoles also comes with a HTTP JSon apit that can be used for basic
> management.
> This is some of the stuff we use for camel-jbang.
>
>
>
>
> On Sat, Dec 30, 2023 at 3:57 PM Claus Ibsen  wrote:
>
> > Hi
> >
> > A discoverable service? Do you mean some kind of external service
> registry
> > ala Consul, Kubernetes ?
> > Camel is not everyhing, and if you need a service registry then favour to
> > use those kind of products that does that.
> > Then you can make your component enlist itself into their service
> > registries.
> >
> > However beware to not make your component doing too much and being to
> > complex.
> >
> > Your component is a dynamic router that was intended to be for routing
> > internally in Camel.
> >
> >
> >
> >
> >
> >
> >
> >
> > On Sat, Dec 30, 2023 at 3:31 PM Steve973  wrote:
> >
> >> Hello.  In my component, I have a control channel component that
> services
> >> a
> >> few types of administrative messages that configure the component in
> >> certain ways.  I would like to experiment with making the control
> >> component
> >> endpoint a discoverable service, so I would like to try to clarify some
> >> things before I start.
> >>
> >> First, I assume that I will need to create another component-endpoint
> pair
> >> that uses HTTP.  That seems really obvious, but I wanted to make sure
> that
> >> I am not missing something.  It certainly would not be the first time
> that
> >> has happened!
> >>
> >> Next, is the Undertow component the best example for me to learn how I
> >> should approach it?  I should only need basic http/https functionality
> to
> >> accept the request information.  If possible, I would like to be able to
> >> reuse the logic that my non-http control channel already implements.  If
> >> there is another component that provides an http endpoint as (mostly) an
> >> additional access point, I would be interested in seeing that.  The
> >> undertow component is pretty substantial, and I do not know if it would
> be
> >> worth that additional complexity and code to integrate with component
> >> discovery.
> >>
> >> Lastly, what else should I be aware of?  The "Service Registry" page in
> >> the
> >> Camel online manual does not seem to be directed toward
> >> developers, other than the idea of implementing DiscoverableService.
> If I
> >> end up doing all of this with my component, would it be helpful to add a
> >> more detailed section to the manual to help others get started with
> >> implementation?
> >>
> >> Thanks,
> >> Steve
> >>
> >
> >
> > --
> > Claus Ibsen
> > -
> > @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >
>
>
> --
> Claus Ibsen
> -
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>