Camel
  1. Camel
  2. CAMEL-2674

Add Spring JMX / @ManagedAttribute annotation to loadbalancer processor in order to be able though jmx console to add / remove endpoints

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Future
    • Component/s: None
    • Labels:
      None

      Description

      Add Spring JMX / @ManagedAttribute annotation to loadbalancer processor in order to be able though jmx console to add /
      remove endpoints from existing List. This will allow infra people to reconfigure dynamically list of HTTP / Jetty / Mina servers available for loadbalancing.

      1. camel-2674.patch
        11 kB
        Charles Moulliard

        Activity

        Hide
        Charles Moulliard added a comment -

        Ok. This will be part of a more important evolution of Camel (3.x) !

        Show
        Charles Moulliard added a comment - Ok. This will be part of a more important evolution of Camel (3.x) !
        Hide
        Claus Ibsen added a comment -

        This requires to have the internal Channel concept improved in Camel to allow it to react more dynamic. So it can easily adjust to having a new SendDefinition added at runtime.

        Also when adding the endpoint should be enlisted in JMX so we can gather JMX stats. So its actually a bit more complicated than at first sight.

        We could omit all this and just add the processor but then

        • tracing
        • interceptors
        • error handling
          will not kick in.
        Show
        Claus Ibsen added a comment - This requires to have the internal Channel concept improved in Camel to allow it to react more dynamic. So it can easily adjust to having a new SendDefinition added at runtime. Also when adding the endpoint should be enlisted in JMX so we can gather JMX stats. So its actually a bit more complicated than at first sight. We could omit all this and just add the processor but then tracing interceptors error handling will not kick in.
        Hide
        Claus Ibsen added a comment -

        The real processor is inside the Channel.

        Just add a patch to this ticket and I can take a look tomorrow when I got some time

        Show
        Claus Ibsen added a comment - The real processor is inside the Channel. Just add a patch to this ticket and I can take a look tomorrow when I got some time
        Hide
        Charles Moulliard added a comment -

        In debug mode, I have discovered that I get a DefaultChannel processor instead of SendProcessor for the list of Loadbalancer Processors.

        Is it possible to find what is the destination endpoint from the DefaultChannel processor ?

        Show
        Charles Moulliard added a comment - In debug mode, I have discovered that I get a DefaultChannel processor instead of SendProcessor for the list of Loadbalancer Processors. Is it possible to find what is the destination endpoint from the DefaultChannel processor ?
        Hide
        Charles Moulliard added a comment -

        I have been able to implement setEndpointUri(String uri) and test it through JMX (junit test).

        Now I try to get from the processors list, the endpoints defined as destination for the loadbalancer. The following code does not work as it seems that LoadBalancer is not an instanceof SendProcessor

            @ManagedAttribute(description = "List of endpoints uri")
            public List<Endpoint> getEndpointUriList() {
            	
            	List<Processor> processors = loadbalancer.getProcessors();
            	List<Endpoint> endpoints = new ArrayList<Endpoint>();
            	
            	for(Processor p : processors) {
            		if (p instanceof SendProcessor) {
            			SendProcessor sp = (SendProcessor)p;
            			
            			if (sp.getDestination()!= null) {
            				endpoints.add(sp.getDestination());
            			}
            		}
            	}
            	
            	return endpoints;
            }
        

        Any idea to get list of endpoints is welcome ?

        Show
        Charles Moulliard added a comment - I have been able to implement setEndpointUri(String uri) and test it through JMX (junit test). Now I try to get from the processors list, the endpoints defined as destination for the loadbalancer. The following code does not work as it seems that LoadBalancer is not an instanceof SendProcessor @ManagedAttribute(description = "List of endpoints uri" ) public List<Endpoint> getEndpointUriList() { List<Processor> processors = loadbalancer.getProcessors(); List<Endpoint> endpoints = new ArrayList<Endpoint>(); for (Processor p : processors) { if (p instanceof SendProcessor) { SendProcessor sp = (SendProcessor)p; if (sp.getDestination()!= null ) { endpoints.add(sp.getDestination()); } } } return endpoints; } Any idea to get list of endpoints is welcome ?
        Hide
        Claus Ibsen added a comment -

        You need to use a JmxOperation on the mbean for this

        public void addEndpointUri(String uri) {
          // lookup endpoint using CamelContext
         // use createProducer method on endpoint to create the Processor needed
        // add the processor on the Load Balancer
        

        And when you need to remove you may have to provide a number / index for the endpoint to be removed

        And you may need an operation to list the current endpoint uris and their index number so you can see which endpoints there currently are
        and which number (index) you need to use if you want to remove one of them

        Show
        Claus Ibsen added a comment - You need to use a JmxOperation on the mbean for this public void addEndpointUri( String uri) { // lookup endpoint using CamelContext // use createProducer method on endpoint to create the Processor needed // add the processor on the Load Balancer And when you need to remove you may have to provide a number / index for the endpoint to be removed And you may need an operation to list the current endpoint uris and their index number so you can see which endpoints there currently are and which number (index) you need to use if you want to remove one of them
        Hide
        Charles Moulliard added a comment -

        The two methods proposed by LoadBalancerSupport which interest me are addProcessor / removeProcessor. As the idea is to provide through jmx attribute, the endpoint (ex : "mina:tcp://localhost:9999?sync=true&allowDefaultCodec=true"), How can I create a Processor with the endpoint provided ?

        Show
        Charles Moulliard added a comment - The two methods proposed by LoadBalancerSupport which interest me are addProcessor / removeProcessor. As the idea is to provide through jmx attribute, the endpoint (ex : "mina:tcp://localhost:9999?sync=true&allowDefaultCodec=true"), How can I create a Processor with the endpoint provided ?
        Hide
        Claus Ibsen added a comment -

        Yes and see also how to test it in ManagedThrottlerTest

        Show
        Claus Ibsen added a comment - Yes and see also how to test it in ManagedThrottlerTest
        Hide
        Charles Moulliard added a comment -

        Hi Claus,

        It means that I have to create a ManagedLoadbalancer class (based on the example ManagedThrottler) and adapt next the class DefaultManagementLifecycleStrategy ?

        Show
        Charles Moulliard added a comment - Hi Claus, It means that I have to create a ManagedLoadbalancer class (based on the example ManagedThrottler) and adapt next the class DefaultManagementLifecycleStrategy ?
        Hide
        Claus Ibsen added a comment -

        See how ManagedThrottler is done.

        Show
        Claus Ibsen added a comment - See how ManagedThrottler is done.
        Hide
        Charles Moulliard added a comment -

        Is LoadBalancerSupport the class where MBEAN support will be added or another class of Loadbalancer processor ?

        Show
        Charles Moulliard added a comment - Is LoadBalancerSupport the class where MBEAN support will be added or another class of Loadbalancer processor ?

          People

          • Assignee:
            Unassigned
            Reporter:
            Charles Moulliard
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development