Announcement Announcement Module
Collapse
No announcement yet.
How can I configure a TaskScheduler in a int-jms:message-driven-channel-adapter? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I configure a TaskScheduler in a int-jms:message-driven-channel-adapter?

    Hello,

    I'd like to use a custom TaskScheduler for listening to JMS Queues.

    The main reason is that the application will be deployed in a Java EE server (WebSphere 8 or 8.5, currently I'm not sure) and I think it's better to use a TimerManagerTaskScheduler in such application server.

    Thanks to Spring profiles, a "<task:scheduler >" is enough for my testings.

    However, I don't know how to configure my taskScheduler in a:

    Code:
     <int-jms:message-driven-channel-adapter ... task-scheduler=myTaskScheduler?>
    By using it's container attribute, I can provide a taskExecutor via a "<jms:listener-container ...>". If it has an "empty" listener (I mean, a class with no methods), I don't care if Spring Integration ignores the ChannelPublishingJmsMessageListener in the JmsMessageDrivenEndpoint's constructor:

    Code:
        <jms:listener-container connection-factory="jmsConnectionFactory" task-executor="jmsTaskExecutor" transaction-manager="jmsTransactionManager">
        	<jms:listener id="incomingListenerContainer" destination="${jms.queue.incoming}" />
        </jms:listener-container>
    
    	<int-jms:message-driven-channel-adapter id="jmsIn" 
    			channel="processSerializablePojoFromJms" 
    			container="incomingListenerContainer" />
    
        <beans profile="dev">
        
    	 	<task:executor id="jmsTaskExecutor" pool-size="4" queue-capacity="10" />
    
        </beans>
        <beans profile="prod">
        
    	 	<bean id="jmsTaskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
    	 		<property name="workManagerName" value="wm/jmsTaskExecutor" />
    	 		<property name="resourceRef" value="true"/>
    	 	</bean>
        </beans>
    But I'd rather a Task Scheduler.

    Since JmsMessageDrivenEndpoint is an AbstractEndpoint, that has a setTaskScheduler method (it sets its parent's taskScheduler, that is an IntegrationObjectSupport) I could write:

    Code:
    		JmsMessageDrivenEndpoint jmsIn = new JmsMessageDrivenEndpoint(..., ...);
    		jmsIn.setTaskScheduler(myTaskScheduler);
    But I don't know if it's possible using the namespace. Does anyone know how to achieve this?

    Thanks.

  • #2
    Why do you want to use a scheduler? The reason you see it on the JMDE is simply because it's on the IntegrationObjectSupport superclass; it's not actually used by that endpoint.

    BTW, instead of defining a dummy listener, just declare the DefaultMessageListenerContainer as a <bean/> instead.

    Comment


    • #3
      Originally posted by Gary Russell View Post
      Why do you want to use a scheduler?
      Because in testing I saw that the DefaultMessageListenerContainer makes calls with high frecuency (and I don't find an attribute to manage that frequency)

      Furthermore, we know the exchange via JMS that we want to listen to, won't have a high frequency, so I don't want to overcharge the system with unnecessary checks.

      Originally posted by Gary Russell View Post
      The reason you see it on the JMDE is simply because it's on the IntegrationObjectSupport superclass; it's not actually used by that endpoint.
      OK, thanks. (Doh!) I didn't put enough attention to the source code (too many classes to read, indeed)

      Originally posted by Gary Russell View Post
      BTW, instead of defining a dummy listener, just declare the DefaultMessageListenerContainer as a <bean/> instead.
      Good point, thanks.

      Comment


      • #4
        makes calls with high frecuency
        See receiveTimeout on the containter; it defaults to 1 second; you can increase it and the thread will block in the JMS provider library for that time.

        The reason you don't want it too long is you want the container to be responsive to shutdowns - it won't actually shut down until the receive times out.

        Bear in mind that this is NOT pinging the server each time, it is simply asking the provider's client library if it has received a message from the broker.

        Comment


        • #5
          Thank you very much for the explanation.

          My main concern on this regard is that the JMS provider in production will be WebSphere, and I've never used it for this. For local testing I'm working with ActiveMQ.

          So, thanks again for your great support.

          Comment

          Working...
          X