Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
bb18f81b
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bb18f81b
编写于
8月 28, 2013
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added "recovery-interval" attribute to <jms:listener-container>
Issue: SPR-10711
上级
4c0da586
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
100 addition
and
20 deletion
+100
-20
spring-jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java
...pringframework/jms/config/JmsListenerContainerParser.java
+9
-0
spring-jms/src/main/resources/org/springframework/jms/config/spring-jms-4.0.xsd
...sources/org/springframework/jms/config/spring-jms-4.0.xsd
+8
-0
spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java
.../springframework/jms/config/JmsNamespaceHandlerTests.java
+36
-18
spring-jms/src/test/java/org/springframework/jms/config/jmsNamespaceHandlerTests.xml
...g/springframework/jms/config/jmsNamespaceHandlerTests.xml
+2
-2
src/reference/docbook/jms.xml
src/reference/docbook/jms.xml
+45
-0
未找到文件。
spring-jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java
浏览文件 @
bb18f81b
...
...
@@ -49,6 +49,8 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
private
static
final
String
RECEIVE_TIMEOUT_ATTRIBUTE
=
"receive-timeout"
;
private
static
final
String
RECOVERY_INTERVAL_ATTRIBUTE
=
"recovery-interval"
;
@Override
protected
BeanDefinition
parseContainer
(
Element
listenerEle
,
Element
containerEle
,
ParserContext
parserContext
)
{
...
...
@@ -160,6 +162,13 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
}
}
String
recoveryInterval
=
containerEle
.
getAttribute
(
RECOVERY_INTERVAL_ATTRIBUTE
);
if
(
StringUtils
.
hasText
(
recoveryInterval
))
{
if
(
containerType
.
startsWith
(
"default"
))
{
containerDef
.
getPropertyValues
().
add
(
"recoveryInterval"
,
recoveryInterval
);
}
}
String
phase
=
containerEle
.
getAttribute
(
PHASE_ATTRIBUTE
);
if
(
StringUtils
.
hasText
(
phase
))
{
containerDef
.
getPropertyValues
().
add
(
"phase"
,
phase
);
...
...
spring-jms/src/main/resources/org/springframework/jms/config/spring-jms-4.0.xsd
浏览文件 @
bb18f81b
...
...
@@ -240,6 +240,14 @@
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute
name=
"recovery-interval"
type=
"xsd:string"
>
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Specify the interval between recovery attempts, in milliseconds.
The default is 5000 ms, that is, 5 seconds.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute
name=
"phase"
type=
"xsd:string"
>
<xsd:annotation>
<xsd:documentation>
<![CDATA[
...
...
spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java
浏览文件 @
bb18f81b
...
...
@@ -139,6 +139,17 @@ public class JmsNamespaceHandlerTests {
assertSame
(
message3
,
testBean3
.
message
);
}
@Test
public
void
testRecoveryInterval
()
{
long
recoveryInterval1
=
getRecoveryInterval
(
"listener1"
);
long
recoveryInterval2
=
getRecoveryInterval
(
"listener2"
);
long
recoveryInterval3
=
getRecoveryInterval
(
DefaultMessageListenerContainer
.
class
.
getName
()
+
"#0"
);
assertEquals
(
1000L
,
recoveryInterval1
);
assertEquals
(
1000L
,
recoveryInterval2
);
assertEquals
(
DefaultMessageListenerContainer
.
DEFAULT_RECOVERY_INTERVAL
,
recoveryInterval3
);
}
@Test
public
void
testErrorHandlers
()
{
ErrorHandler
expected
=
this
.
context
.
getBean
(
"testErrorHandler"
,
ErrorHandler
.
class
);
...
...
@@ -164,24 +175,6 @@ public class JmsNamespaceHandlerTests {
assertEquals
(
Integer
.
MAX_VALUE
,
defaultPhase
);
}
private
MessageListener
getListener
(
String
containerBeanName
)
{
DefaultMessageListenerContainer
container
=
this
.
context
.
getBean
(
containerBeanName
,
DefaultMessageListenerContainer
.
class
);
return
(
MessageListener
)
container
.
getMessageListener
();
}
private
ErrorHandler
getErrorHandler
(
String
containerBeanName
)
{
DefaultMessageListenerContainer
container
=
this
.
context
.
getBean
(
containerBeanName
,
DefaultMessageListenerContainer
.
class
);
return
(
ErrorHandler
)
new
DirectFieldAccessor
(
container
).
getPropertyValue
(
"errorHandler"
);
}
public
int
getPhase
(
String
containerBeanName
)
{
Object
container
=
this
.
context
.
getBean
(
containerBeanName
);
if
(!(
container
instanceof
Phased
))
{
throw
new
IllegalStateException
(
"Container '"
+
containerBeanName
+
"' does not implement Phased."
);
}
return
((
Phased
)
container
).
getPhase
();
}
@Test
public
void
testComponentRegistration
()
{
assertTrue
(
"Parser should have registered a component named 'listener1'"
,
context
.
containsComponentDefinition
(
"listener1"
));
...
...
@@ -203,6 +196,7 @@ public class JmsNamespaceHandlerTests {
}
}
private
void
validateComponentDefinition
(
ComponentDefinition
compDef
)
{
BeanDefinition
[]
beanDefs
=
compDef
.
getBeanDefinitions
();
for
(
BeanDefinition
beanDef
:
beanDefs
)
{
...
...
@@ -210,6 +204,30 @@ public class JmsNamespaceHandlerTests {
}
}
private
MessageListener
getListener
(
String
containerBeanName
)
{
DefaultMessageListenerContainer
container
=
this
.
context
.
getBean
(
containerBeanName
,
DefaultMessageListenerContainer
.
class
);
return
(
MessageListener
)
container
.
getMessageListener
();
}
private
ErrorHandler
getErrorHandler
(
String
containerBeanName
)
{
DefaultMessageListenerContainer
container
=
this
.
context
.
getBean
(
containerBeanName
,
DefaultMessageListenerContainer
.
class
);
return
(
ErrorHandler
)
new
DirectFieldAccessor
(
container
).
getPropertyValue
(
"errorHandler"
);
}
private
long
getRecoveryInterval
(
String
containerBeanName
)
{
DefaultMessageListenerContainer
container
=
this
.
context
.
getBean
(
containerBeanName
,
DefaultMessageListenerContainer
.
class
);
Long
recoveryInterval
=
(
Long
)
new
DirectFieldAccessor
(
container
).
getPropertyValue
(
"recoveryInterval"
);
return
recoveryInterval
.
longValue
();
}
private
int
getPhase
(
String
containerBeanName
)
{
Object
container
=
this
.
context
.
getBean
(
containerBeanName
);
if
(!(
container
instanceof
Phased
))
{
throw
new
IllegalStateException
(
"Container '"
+
containerBeanName
+
"' does not implement Phased."
);
}
return
((
Phased
)
container
).
getPhase
();
}
public
static
class
TestMessageListener
implements
MessageListener
{
...
...
spring-jms/src/test/java/org/springframework/jms/config/jmsNamespaceHandlerTests.xml
浏览文件 @
bb18f81b
...
...
@@ -3,12 +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-
3.1
.xsd"
>
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-
4.0
.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"
prefetch=
"50"
receive-timeout=
"100"
phase=
"99"
>
concurrency=
"1-2"
prefetch=
"50"
receive-timeout=
"100"
recovery-interval=
"1000"
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>
...
...
src/reference/docbook/jms.xml
浏览文件 @
bb18f81b
...
...
@@ -1086,6 +1086,16 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
<literal>
'default'
</literal>
).
</para></entry>
</row>
<row>
<entry>
container-class
</entry>
<entry><para>
A custom listener container implementation class
as fully qualified class name. Default is Spring's standard
<classname>
DefaultMessageListenerContainer
</classname>
or
<classname>
SimpleMessageListenerContainer
</classname>
,
according to the "container-type" attribute.
</para></entry>
</row>
<row>
<entry>
connection-factory
</entry>
...
...
@@ -1121,6 +1131,15 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
<classname>
SimpleMessageConverter
</classname>
.
</para></entry>
</row>
<row>
<entry>
error-handler
</entry>
<entry><para>
A reference to an
<interfacename>
ErrorHandler
</interfacename>
strategy for handling
any uncaught Exceptions that may occur during the execution of the
<interfacename>
MessageListener
</interfacename>
.
</para></entry>
</row>
<row>
<entry>
destination-type
</entry>
...
...
@@ -1195,6 +1214,32 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
session. Note that raising this number might lead to starvation of
concurrent consumers!
</para></entry>
</row>
<row>
<entry>
receive-timeout
</entry>
<entry><para>
The timeout to use for receive calls (in milliseconds).
The default is
<literal>
1000
</literal>
ms (1 sec);
<literal>
-1
</literal>
indicates no timeout at all.
</para></entry>
</row>
<row>
<entry>
recovery-interval
</entry>
<entry><para>
Specify the interval between recovery attempts, in
milliseconds. The default is
<literal>
5000
</literal>
ms, that is,
5 seconds.
</para></entry>
</row>
<row>
<entry>
phase
</entry>
<entry><para>
The lifecycle phase within which this container should
start and stop. The lower the value the earlier this container will
start and the later it will stop. The default is
<literal>
Integer.MAX_VALUE
</literal>
meaning the container will start
as late as possible and stop as soon as possible.
</para></entry>
</row>
</tbody>
</tgroup>
</table>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录