Announcement Announcement Module
Collapse
No announcement yet.
Beans environment profile does not work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Beans environment profile does not work

    I am trying to configure bean profiles but it does not work,
    I see in the log the message:
    DEBUG 2012-12-12 13:27:00,815 [main] core.env.PropertySourcesPropertyResolver - Found key 'spring.profiles.active' in [systemProperties] with type [String] and value 'dev'
    DEBUG 2012-12-12 13:27:00,824 [main] core.env.StandardEnvironment - Activating profile 'dev'

    which means that the profile was activated but it does not seem to work, can any one help me with this?

    Here is the xml configuration:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    	       	http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    	       	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
           		http://www.springframework.org/schema/context
           		http://www.springframework.org/schema/context/spring-context-3.0.xsd">
           		
           		
    		
    <beans profile="dev">  
    		
    		<import resource="com.leadspace.common.msg.amq.xml" />            
    	    <!-- ********************* Task executors ************************ -->
    		<bean id="workersTaskExecutor" class="com.leadspace.common.messaging.taskexecutors.WorkersTaskExecutor">
    			<property name="taskExecutor" ref="threadPoolExecutor"/>
    		</bean>
    		
    		<bean id="threadPoolExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
    				<property name="corePoolSize" value="20"/>
    				<property name="queueCapacity" value="40"/>
    				<property name="keepAliveSeconds" value="600"/>
    				<property name="maxPoolSize" value="50"/>
    			</bean>
    		
    		<!-- ********************* Task Services ************************ -->
    	
    	<bean id="taskService" class="com.leadspace.common.messaging.services.BasicTaskService"
    		abstract="true"
    		scope="singleton">
    		<property name="taskExecutor" ref="workersTaskExecutor" /> 
    	</bean>
    	
    	 <bean id="taskServiceDispatcher"
    		class="com.leadspace.common.messaging.services.BasicTaskService"
    		parent="taskService" scope="singleton">
            <property name="taskExecutor" ref="jmsSenderTaskExecutor"/>
    	</bean>
    	
    	<bean id="taskServiceExecutor"
    			class="com.leadspace.common.messaging.services.BasicTaskService"
    			parent="taskService" scope="singleton">
    	        <property name="taskExecutor" ref="workersTaskExecutor"/>
    		</bean>
    	
    		
    		<!-- ********************* Logics ************************ -->
    		 <bean id="runSpotLightProject"
    			class="com.leadspace.controller.messaging.logics.RunSpotLightProject">
    			<property name="service" ref="spotlightResultsService" /> 
    		</bean>
    		
    		<bean id="handleSpotlightResult"
    			class="com.leadspace.controller.task.SpotlightResultHandler">
    		</bean>
    		
    			<!-- ********************* Services ************************ -->
    		<bean id="service" class="com.leadspace.common.messaging.services.AbstractService"
    			abstract="true"
    			scope="prototype">
    			<property name="taskService" ref="taskService" /> 
    		</bean>
    		<bean id="spotlightResultsService" class="com.leadspace.controller.messaging.services.SpotlightResultService"
    			scope="prototype">
    			<property name="taskService" ref="taskServiceDispatcher" /> 
    		</bean>
    		
    </beans> 
    </beans>

  • #2
    And it doesn't work becuase?! What is making you think it doesn't work.

    Comment


    • #3
      I have 2 processes: 1 in tomcat and one not. tomcat produces messages to the AMQ-queue and the other process consumes.
      I defined the spring xmls to have a profile called 'dev'
      the tomcat process loads the spring beans inside the active profile 'dev'
      but the jms listener which is on the other process and defined inside the profile 'dev' does call the 'onMessage' and
      when observing the acitve mq admin page i see no consumer on the queue defined.

      I have no idea to explain this.

      Comment


      • #4
        Why should the configuration on the tomcat side influence the config on the other side?! A system property is passed as a -D parameter one JVM doesn't influence the other JVM...

        Comment


        • #5
          I know, i just mentioned this to show that i am configuring everything right since one side of the jms queue (the producer) works fine, but the other side does not.
          thanks

          Comment


          • #6
            Your story is confusing and for me you haven't configured it right... One JVM doesn't influence the other... So settings from x do nothing for y... Either make it an environment setting or pass the parameter to both processes...

            Comment


            • #7
              I am sorry, i guess i didn't explain my self very well.
              The buttom line is that the listener bean which is defined in the active profile is not set as a consumer for some reason after i added the active profile support.
              It might be some problem I am responsible for, but i can't see it, since i configured other beans on other processes like this and they worked.
              Any way, I was wondering if someone ever tested this feature with the jms configuration in spring. if so, then it must be my mistake.
              thanks

              Comment


              • #8
                Hi,
                I found the problem, it was some configuration issues.
                thanks for the help.

                Comment

                Working...
                X