Skip to content

Commit 94e3f08

Browse files
committed
added "receive-timeout" attribute to "jms:listener-container" element in JMS namespace (SPR-9114)
1 parent 1c2b1d2 commit 94e3f08

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

org.springframework.jms/src/main/java/org/springframework/jms/config/JcaListenerContainerParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -108,6 +108,7 @@ protected BeanDefinition parseContainer(Element listenerEle, Element containerEl
108108
return containerDef;
109109
}
110110

111+
@Override
111112
protected boolean indicatesPubSub(BeanDefinition containerDef) {
112113
BeanDefinition configDef =
113114
(BeanDefinition) containerDef.getPropertyValues().getPropertyValue("activationSpecConfig").getValue();

org.springframework.jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,6 +47,8 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
4747

4848
private static final String CACHE_ATTRIBUTE = "cache";
4949

50+
private static final String RECEIVE_TIMEOUT_ATTRIBUTE = "receive-timeout";
51+
5052

5153
protected BeanDefinition parseContainer(Element listenerEle, Element containerEle, ParserContext parserContext) {
5254
RootBeanDefinition containerDef = new RootBeanDefinition();
@@ -156,6 +158,13 @@ else if ("simple102".equals(containerType)) {
156158
}
157159
}
158160

161+
String receiveTimeout = containerEle.getAttribute(RECEIVE_TIMEOUT_ATTRIBUTE);
162+
if (StringUtils.hasText(receiveTimeout)) {
163+
if (containerType.startsWith("default")) {
164+
containerDef.getPropertyValues().add("receiveTimeout", new Integer(receiveTimeout));
165+
}
166+
}
167+
159168
String phase = containerEle.getAttribute(PHASE_ATTRIBUTE);
160169
if (StringUtils.hasText(phase)) {
161170
containerDef.getPropertyValues().add("phase", phase);
@@ -164,10 +173,12 @@ else if ("simple102".equals(containerType)) {
164173
return containerDef;
165174
}
166175

176+
@Override
167177
protected boolean indicatesPubSub(BeanDefinition containerDef) {
168178
return indicatesPubSubConfig(containerDef);
169179
}
170180

181+
@Override
171182
protected boolean indicatesJms102(BeanDefinition containerDef) {
172183
return containerDef.getBeanClassName().endsWith("102");
173184
}

org.springframework.jms/src/main/resources/org/springframework/jms/config/spring-jms-3.1.xsd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@
233233
]]></xsd:documentation>
234234
</xsd:annotation>
235235
</xsd:attribute>
236+
<xsd:attribute name="receive-timeout" type="xsd:int">
237+
<xsd:annotation>
238+
<xsd:documentation><![CDATA[
239+
The timeout to use for receive calls (in milliseconds).
240+
The default is 1000 ms (1 sec); -1 indicates no timeout at all.
241+
]]></xsd:documentation>
242+
</xsd:annotation>
243+
</xsd:attribute>
236244
<xsd:attribute name="phase" type="xsd:string">
237245
<xsd:annotation>
238246
<xsd:documentation><![CDATA[

org.springframework.jms/src/test/java/org/springframework/jms/config/jmsNamespaceHandlerTests.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns:jms="http://www.springframework.org/schema/jms"
55
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
6-
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd">
6+
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.1.xsd">
77

88
<jms:listener-container connection-factory="testConnectionFactory" task-executor="testTaskExecutor"
99
destination-resolver="testDestinationResolver" message-converter="testMessageConverter"
10-
transaction-manager="testTransactionManager" error-handler="testErrorHandler" concurrency="1-2" phase="99">
10+
transaction-manager="testTransactionManager" error-handler="testErrorHandler"
11+
concurrency="1-2" prefetch="50" receive-timeout="100" phase="99">
1112
<jms:listener id="listener1" destination="testDestination" ref="testBean1" method="setName"/>
1213
<jms:listener id="listener2" destination="testDestination" ref="testBean2" method="setName" response-destination="responseDestination"/>
1314
</jms:listener-container>

0 commit comments

Comments
 (0)