Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-4544

Dynamic flow components are not registered as MBeans (or unregistered)

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 5.1 RC1
    • Fix Version/s: 5.1 GA
    • Component/s: DSL, JMX Support
    • Labels:

      Description

      /*
       * Copyright 2018 the original author or authors.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       *      http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */
      
      package org.springframework.integration.monitor;
      
      import static org.assertj.core.api.Assertions.assertThat;
      
      import java.util.Set;
      
      import javax.management.MBeanServer;
      import javax.management.ObjectName;
      
      import org.junit.jupiter.api.Test;
      
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.context.annotation.Bean;
      import org.springframework.context.annotation.Configuration;
      import org.springframework.integration.config.EnableIntegration;
      import org.springframework.integration.dsl.IntegrationFlow;
      import org.springframework.integration.dsl.IntegrationFlows;
      import org.springframework.integration.dsl.context.IntegrationFlowContext;
      import org.springframework.integration.dsl.context.IntegrationFlowContext.IntegrationFlowRegistration;
      import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport;
      import org.springframework.jmx.support.MBeanServerFactoryBean;
      import org.springframework.test.annotation.DirtiesContext;
      import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
      
      /**
       * @author Gary Russell
       * @since 5.1
       *
       */
      @SpringJUnitConfig
      @DirtiesContext
      public class DslMBeanTests {
      
      	@Autowired
      	private MBeanServer server;
      
      	@Test
      	public void testMaxFetch(@Autowired IntegrationFlowContext context) throws Exception {
      		Set<ObjectName> query = this.server.queryNames(new ObjectName("foo:type=MessageChannel,*"), null);
      		assertThat(query).hasSize(3);
      
      		IntegrationFlow dynamicFlow = IntegrationFlows.from("channelTwo")
      				.nullChannel();
      		IntegrationFlowRegistration reg = context.registration(dynamicFlow).register();
      
      		query = this.server.queryNames(new ObjectName("foo:type=MessageChannel,*"), null);
      		assertThat(query).hasSize(4);
      
      		reg.destroy();
      		query = this.server.queryNames(new ObjectName("foo:type=MessageChannel,*"), null);
      		assertThat(query).hasSize(3);
      	}
      
      	@Configuration
      	@EnableIntegrationMBeanExport(defaultDomain = "foo")
      	@EnableIntegration
      	public static class Config {
      
      		@Bean
      		public MBeanServerFactoryBean fb() {
      			MBeanServerFactoryBean fb = new MBeanServerFactoryBean();
      			fb.setLocateExistingServerIfPossible(true);
      			return fb;
      		}
      
      		@Bean
      		public IntegrationFlow staticFlow() {
      			return IntegrationFlows.from("channelOne")
      					.nullChannel();
      		}
      
      	}
      
      }
      

        Attachments

          Activity

            People

            Assignee:
            abilan Artem Bilan
            Reporter:
            grussell Gary Russell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: