Added support for a 'message-driven-channel-adapter' in the JMS namespace. Also, both the 'message-driven-channel-adapter' and the 'inbound-gateway' elements now accept a 'container' attribute with a reference to an instance of AbstractMessageListenerContainer (INT-477, INT-482).
This commit is contained in:
@@ -32,11 +32,12 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Parser for the <inbound-gateway> element of the 'jms' integration namespace.
|
||||
* Parser for the <message-driven-channel-adapter> element and the
|
||||
* <inbound-gateway> element of the 'jms' namespace.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class JmsInboundGatewayParser extends AbstractSingleBeanDefinitionParser {
|
||||
public class JmsMessageDrivenEndpointParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
private static String[] containerAttributes = new String[] {
|
||||
JmsAdapterParserUtils.CONNECTION_FACTORY_PROPERTY,
|
||||
@@ -48,6 +49,14 @@ public class JmsInboundGatewayParser extends AbstractSingleBeanDefinitionParser
|
||||
};
|
||||
|
||||
|
||||
private final boolean expectReply;
|
||||
|
||||
|
||||
public JmsMessageDrivenEndpointParser(boolean expectReply) {
|
||||
this.expectReply = expectReply;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return JmsMessageDrivenEndpoint.class;
|
||||
@@ -116,14 +125,21 @@ public class JmsInboundGatewayParser extends AbstractSingleBeanDefinitionParser
|
||||
|
||||
private String parseMessageListener(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ChannelPublishingJmsMessageListener.class);
|
||||
builder.addPropertyValue("expectReply", true);
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "request-channel");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "request-timeout");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-timeout");
|
||||
builder.addPropertyValue("expectReply", this.expectReply);
|
||||
if (this.expectReply) {
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "request-channel");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "request-timeout");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-timeout");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-request-payload");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-reply-payload");
|
||||
}
|
||||
else {
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "channel", "requestChannel");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout", "requestTimeout");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-payload", "extractRequestPayload");
|
||||
}
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "message-converter");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "header-mapper");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-request-payload");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-reply-payload");
|
||||
return BeanDefinitionReaderUtils.registerWithGeneratedName(builder.getBeanDefinition(), parserContext.getRegistry());
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ import org.springframework.integration.jms.JmsHeaders;
|
||||
public class JmsNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
public void init() {
|
||||
this.registerBeanDefinitionParser("inbound-gateway", new JmsInboundGatewayParser());
|
||||
this.registerBeanDefinitionParser("inbound-gateway", new JmsMessageDrivenEndpointParser(true));
|
||||
this.registerBeanDefinitionParser("message-driven-channel-adapter", new JmsMessageDrivenEndpointParser(false));
|
||||
this.registerBeanDefinitionParser("inbound-channel-adapter", new JmsInboundChannelAdapterParser());
|
||||
this.registerBeanDefinitionParser("outbound-gateway", new JmsOutboundGatewayParser());
|
||||
this.registerBeanDefinitionParser("outbound-channel-adapter", new JmsOutboundChannelAdapterParser());
|
||||
|
||||
@@ -18,10 +18,35 @@
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
<xsd:element name="message-driven-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Defines a JMS Message-Driven inbound Channel Adapter.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="jmsInboundAdapterType">
|
||||
<xsd:attribute name="channel" type="xsd:string"/>
|
||||
<xsd:attribute name="message-converter" type="xsd:string"/>
|
||||
<xsd:attribute name="header-mapper" type="xsd:string"/>
|
||||
<xsd:attribute name="extract-payload" type="xsd:string" default="true"/>
|
||||
<xsd:attribute name="send-timeout" type="xsd:string"/>
|
||||
<xsd:attribute name="transaction-manager" type="xsd:string"/>
|
||||
<xsd:attribute name="concurrent-consumers" type="xsd:string"/>
|
||||
<xsd:attribute name="max-concurrent-consumers" type="xsd:string"/>
|
||||
<xsd:attribute name="max-messages-per-task" type="xsd:string"/>
|
||||
<xsd:attribute name="idle-task-execution-limit" type="xsd:string"/>
|
||||
<xsd:attribute name="auto-startup" type="xsd:string" default="true"/>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="inbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Defines a JMS-based inbound Channel Adapter.
|
||||
Defines an inbound Channel Adapter for polling a JMS Destination.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
|
||||
Reference in New Issue
Block a user