Skip to content

Commit

Permalink
INT-3341: Add Redis Queue Gateways
Browse files Browse the repository at this point in the history
Add RedisQueueOutboundGateway and RedisQueueInboundGateway

JIRA: https://jira.spring.io/browse/INT-3341

add test

fix format issue

change expectmessage to extractpayload, fix test potential bug

fix copyright year

fix format and naming issue

fix as Artem's comments

fix as Artem's comments

change boolean condition judgement

INT-3341: Polishing

Minor Doc Polishing
  • Loading branch information
liujiong1982 authored and garyrussell committed Oct 26, 2014
1 parent ff2b15e commit 1d4785f
Show file tree
Hide file tree
Showing 17 changed files with 1,443 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ protected final void postProcess(BeanDefinitionBuilder builder, Element element)
if (StringUtils.hasText(errorChannel)) {
builder.addPropertyReference("errorChannel", errorChannel);
}
String autoStartup = element.getAttribute("auto-startup");
if (StringUtils.hasText(autoStartup)) {
builder.addPropertyValue("autoStartup", autoStartup);
}
this.doPostProcess(builder, element);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private void initializeIfNecessary() {
}
}

private MessageChannel getRequestChannel() {
protected MessageChannel getRequestChannel() {
if (this.requestChannelName != null) {
synchronized (this) {
if (this.requestChannelName != null) {
Expand All @@ -252,7 +252,7 @@ private MessageChannel getRequestChannel() {
return this.requestChannel;
}

private MessageChannel getReplyChannel() {
protected MessageChannel getReplyChannel() {
if (this.replyChannelName != null) {
synchronized (this) {
if (this.replyChannelName != null) {
Expand All @@ -272,7 +272,7 @@ private MessageChannel getReplyChannel() {
return this.replyChannel;
}

private MessageChannel getErrorChannel() {
protected MessageChannel getErrorChannel() {
if (this.errorChannelName != null) {
synchronized (this) {
if (this.errorChannelName != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ public void init() {
registerBeanDefinitionParser("queue-inbound-channel-adapter", new RedisQueueInboundChannelAdapterParser());
registerBeanDefinitionParser("queue-outbound-channel-adapter", new RedisQueueOutboundChannelAdapterParser());
registerBeanDefinitionParser("outbound-gateway", new RedisOutboundGatewayParser());
registerBeanDefinitionParser("queue-inbound-gateway", new RedisQueueInboundGatewayParser());
registerBeanDefinitionParser("queue-outbound-gateway", new RedisQueueOutboundGatewayParser());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.integration.redis.config;

import org.w3c.dom.Element;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.integration.config.xml.AbstractInboundGatewayParser;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.integration.redis.inbound.RedisQueueInboundGateway;
import org.springframework.util.StringUtils;

/**
* Parser for the <queue-inbound-gateway> element of the 'redis' namespace.
*
* @author David Liu
* @author Artem Bilan
* @since 4.1
*/
public class RedisQueueInboundGatewayParser extends AbstractInboundGatewayParser {

@Override
protected Class<?> getBeanClass(Element element) {
return RedisQueueInboundGateway.class;
}

@Override
protected boolean isEligibleAttribute(String attributeName) {
return !attributeName.equals("queue")
&& !attributeName.equals("connection-factory")
&& !attributeName.equals("serializer")
&& !attributeName.equals("task-executor")
&& super.isEligibleAttribute(attributeName);
}

@Override
protected void doPostProcess(BeanDefinitionBuilder builder, Element element) {
builder.addConstructorArgValue(element.getAttribute("queue"));
String connectionFactory = element.getAttribute("connection-factory");
if (!StringUtils.hasText(connectionFactory)) {
connectionFactory = "redisConnectionFactory";
}
builder.addConstructorArgReference(connectionFactory);

IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "serializer", true);
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "task-executor");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.integration.redis.config;

import org.w3c.dom.Element;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.xml.AbstractConsumerEndpointParser;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.integration.redis.outbound.RedisQueueOutboundGateway;
import org.springframework.util.StringUtils;

/**
* Parser for the &lt;int-redis:queue-outbound-channel-adapter&gt; element.
*
* @author Artem Bilan
* @author David Liu
* @since 3.0
*/
public class RedisQueueOutboundGatewayParser extends AbstractConsumerEndpointParser {

@Override
protected String getInputChannelAttributeName() {
return "request-channel";
}

@Override
protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(RedisQueueOutboundGateway.class);
builder.addConstructorArgValue(element.getAttribute("queue"));
String connectionFactory = element.getAttribute("connection-factory");
if (!StringUtils.hasText(connectionFactory)) {
connectionFactory = "redisConnectionFactory";
}
builder.addConstructorArgReference(connectionFactory);
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "reply-channel", "outputChannel");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-payload");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "serializer");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-timeout", "receiveTimeout");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "requires-reply");
return builder;
}

}
Loading

0 comments on commit 1d4785f

Please sign in to comment.