added support for durable subscription settings
This commit is contained in:
@@ -59,7 +59,8 @@ public class JmsMessageDrivenEndpointParser extends AbstractSingleBeanDefinition
|
||||
"max-messages-per-task", "selector",
|
||||
"receive-timeout", "recovery-interval",
|
||||
"idle-consumer-limit", "idle-task-execution-limit",
|
||||
"cache-level"
|
||||
"cache-level", "subscription-durable", "durable-subscription-name",
|
||||
"client-id"
|
||||
};
|
||||
|
||||
|
||||
@@ -149,6 +150,9 @@ public class JmsMessageDrivenEndpointParser extends AbstractSingleBeanDefinition
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "idle-consumer-limit");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "idle-task-execution-limit");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "cache-level");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "subscription-durable");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "durable-subscription-name");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "client-id");
|
||||
builder.addPropertyValue("autoStartup", false);
|
||||
return BeanDefinitionReaderUtils.registerWithGeneratedName(builder.getBeanDefinition(), parserContext.getRegistry());
|
||||
}
|
||||
|
||||
@@ -377,6 +377,35 @@
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="subscription-durable" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Boolean property indicating whether to make the subscription durable. The durable subscription name to be used can be specified
|
||||
through the "durableSubscriptionName" property. Default is "false". Set this to "true" to register a durable subscription,
|
||||
typically in combination with a "durableSubscriptionName" value (unless your message listener class name is good enough as
|
||||
subscription name). Only makes sense when listening to a topic (pub-sub domain).
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="durable-subscription-name" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The name of a durable subscription to create. To be applied in case of a topic (pub-sub domain) with subscription durability
|
||||
activated. The durable subscription name needs to be unique within this client's JMS client id. Default is the class name of the
|
||||
specified message listener. Note: Only 1 concurrent consumer (which is the default of this message listener container) is allowed
|
||||
for each durable subscription.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="client-id" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The JMS client id for a shared Connection created and used by this container. Note that client ids need to be unique among all
|
||||
active Connections of the underlying JMS provider. Furthermore, a client id can only be assigned if the original ConnectionFactory
|
||||
hasn't already assigned one.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="channel" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
@@ -621,6 +650,35 @@
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="subscription-durable" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Boolean property indicating whether to make the subscription durable. The durable subscription name to be used can be specified
|
||||
through the "durableSubscriptionName" property. Default is "false". Set this to "true" to register a durable subscription,
|
||||
typically in combination with a "durableSubscriptionName" value (unless your message listener class name is good enough as
|
||||
subscription name). Only makes sense when listening to a topic (pub-sub domain).
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="durable-subscription-name" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The name of a durable subscription to create. To be applied in case of a topic (pub-sub domain) with subscription durability
|
||||
activated. The durable subscription name needs to be unique within this client's JMS client id. Default is the class name of the
|
||||
specified message listener. Note: Only 1 concurrent consumer (which is the default of this message listener container) is allowed
|
||||
for each durable subscription.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="client-id" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The JMS client id for a shared Connection created and used by this container. Note that client ids need to be unique among all
|
||||
active Connections of the underlying JMS provider. Furthermore, a client id can only be assigned if the original ConnectionFactory
|
||||
hasn't already assigned one.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="concurrent-consumers" type="xsd:string"/>
|
||||
<xsd:attribute name="max-concurrent-consumers" type="xsd:string"/>
|
||||
<xsd:attribute name="cache-level" type="xsd:string"/>
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.jms.connection.JmsTransactionManager;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.jms.listener.DefaultMessageListenerContainer;
|
||||
import org.springframework.jms.support.destination.JmsDestinationAccessor;
|
||||
|
||||
/**
|
||||
@@ -343,6 +344,18 @@ public class JmsInboundGatewayParserTests {
|
||||
assertEquals(Boolean.TRUE, container.isPubSubDomain());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gatewayWithDurableSubscription() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"inboundGatewayWithDurableSubscription.xml", this.getClass());
|
||||
JmsMessageDrivenEndpoint endpoint = context.getBean("gateway", JmsMessageDrivenEndpoint.class);
|
||||
DefaultMessageListenerContainer container = (DefaultMessageListenerContainer) new DirectFieldAccessor(endpoint).getPropertyValue("listenerContainer");
|
||||
assertEquals(Boolean.TRUE, container.isPubSubDomain());
|
||||
assertEquals(Boolean.TRUE, container.isSubscriptionDurable());
|
||||
assertEquals("testDurableSubscriptionName", container.getDurableSubscriptionName());
|
||||
assertEquals("testClientId", container.getClientId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gatewayWithReplyChannel() {
|
||||
ActiveMqTestUtils.prepare();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -31,6 +31,7 @@ import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.jms.JmsMessageDrivenEndpoint;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.jms.listener.DefaultMessageListenerContainer;
|
||||
import org.springframework.jms.support.destination.JmsDestinationAccessor;
|
||||
|
||||
/**
|
||||
@@ -66,6 +67,18 @@ public class JmsMessageDrivenChannelAdapterParserTests {
|
||||
assertEquals(Boolean.TRUE, container.isPubSubDomain());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adapterWithDurableSubscription() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsInboundWithDurableSubscription.xml", this.getClass());
|
||||
JmsMessageDrivenEndpoint endpoint = context.getBean("messageDrivenAdapter", JmsMessageDrivenEndpoint.class);
|
||||
DefaultMessageListenerContainer container = (DefaultMessageListenerContainer) new DirectFieldAccessor(endpoint).getPropertyValue("listenerContainer");
|
||||
assertEquals(Boolean.TRUE, container.isPubSubDomain());
|
||||
assertEquals(Boolean.TRUE, container.isSubscriptionDurable());
|
||||
assertEquals("testDurableSubscriptionName", container.getDurableSubscriptionName());
|
||||
assertEquals("testClientId", container.getClientId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGatewayWithReceiveTimeout() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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:si="http://www.springframework.org/schema/integration"
|
||||
xmlns:jms="http://www.springframework.org/schema/integration/jms"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/jms
|
||||
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
|
||||
|
||||
<si:channel id="requestChannel">
|
||||
<si:queue/>
|
||||
</si:channel>
|
||||
|
||||
<jms:inbound-gateway id="gateway"
|
||||
request-destination-name="testDestinationName"
|
||||
request-channel="requestChannel"
|
||||
request-pub-sub-domain="true"
|
||||
subscription-durable="true"
|
||||
durable-subscription-name="testDurableSubscriptionName"
|
||||
client-id="testClientId" />
|
||||
|
||||
<bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.integration.jms.StubConnection">
|
||||
<constructor-arg value="test"/>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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:si="http://www.springframework.org/schema/integration"
|
||||
xmlns:jms="http://www.springframework.org/schema/integration/jms"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/jms
|
||||
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
|
||||
|
||||
<si:channel id="output">
|
||||
<si:queue capacity="1"/>
|
||||
</si:channel>
|
||||
|
||||
<jms:message-driven-channel-adapter id="messageDrivenAdapter"
|
||||
destination-name="testDestination"
|
||||
pub-sub-domain="true"
|
||||
subscription-durable="true"
|
||||
durable-subscription-name="testDurableSubscriptionName"
|
||||
client-id="testClientId"
|
||||
channel="output"/>
|
||||
|
||||
<bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.integration.jms.StubConnection">
|
||||
<constructor-arg value="test"/>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user