added "receive-timeout" attribute to "jms:listener-container" element in JMS namespace (SPR-9114)

This commit is contained in:
Juergen Hoeller
2012-02-14 22:51:32 +01:00
parent 1c2b1d2c85
commit 94e3f08a44
4 changed files with 25 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2012 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.
@@ -108,6 +108,7 @@ class JcaListenerContainerParser extends AbstractListenerContainerParser {
return containerDef;
}
@Override
protected boolean indicatesPubSub(BeanDefinition containerDef) {
BeanDefinition configDef =
(BeanDefinition) containerDef.getPropertyValues().getPropertyValue("activationSpecConfig").getValue();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2012 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.
@@ -47,6 +47,8 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
private static final String CACHE_ATTRIBUTE = "cache";
private static final String RECEIVE_TIMEOUT_ATTRIBUTE = "receive-timeout";
protected BeanDefinition parseContainer(Element listenerEle, Element containerEle, ParserContext parserContext) {
RootBeanDefinition containerDef = new RootBeanDefinition();
@@ -156,6 +158,13 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
}
}
String receiveTimeout = containerEle.getAttribute(RECEIVE_TIMEOUT_ATTRIBUTE);
if (StringUtils.hasText(receiveTimeout)) {
if (containerType.startsWith("default")) {
containerDef.getPropertyValues().add("receiveTimeout", new Integer(receiveTimeout));
}
}
String phase = containerEle.getAttribute(PHASE_ATTRIBUTE);
if (StringUtils.hasText(phase)) {
containerDef.getPropertyValues().add("phase", phase);
@@ -164,10 +173,12 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
return containerDef;
}
@Override
protected boolean indicatesPubSub(BeanDefinition containerDef) {
return indicatesPubSubConfig(containerDef);
}
@Override
protected boolean indicatesJms102(BeanDefinition containerDef) {
return containerDef.getBeanClassName().endsWith("102");
}

View File

@@ -233,6 +233,14 @@
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="receive-timeout" type="xsd:int">
<xsd:annotation>
<xsd:documentation><![CDATA[
The timeout to use for receive calls (in milliseconds).
The default is 1000 ms (1 sec); -1 indicates no timeout at all.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="phase" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[

View File

@@ -3,11 +3,12 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.springframework.org/schema/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd">
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.1.xsd">
<jms:listener-container connection-factory="testConnectionFactory" task-executor="testTaskExecutor"
destination-resolver="testDestinationResolver" message-converter="testMessageConverter"
transaction-manager="testTransactionManager" error-handler="testErrorHandler" concurrency="1-2" phase="99">
transaction-manager="testTransactionManager" error-handler="testErrorHandler"
concurrency="1-2" prefetch="50" receive-timeout="100" phase="99">
<jms:listener id="listener1" destination="testDestination" ref="testBean1" method="setName"/>
<jms:listener id="listener2" destination="testDestination" ref="testBean2" method="setName" response-destination="responseDestination"/>
</jms:listener-container>