Added namespace support for a 'bridge' element that simply connects any input-channel to any output-channel. This enables the conversion between PollableChannels and SubscribableChannels and also provides throttling capabilities based on the polling interval (or cron-expression) and 'max-messages-per-poll' settings (INT-193).
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
|
||||
|
||||
<channel id="pollableChannel">
|
||||
<queue/>
|
||||
</channel>
|
||||
|
||||
<channel id="output1">
|
||||
<queue/>
|
||||
</channel>
|
||||
|
||||
<channel id="subscribableChannel"/>
|
||||
|
||||
<channel id="output2">
|
||||
<queue/>
|
||||
</channel>
|
||||
|
||||
<bridge input-channel="pollableChannel" output-channel="output1">
|
||||
<poller max-messages-per-poll="2">
|
||||
<interval-trigger interval="3000"/>
|
||||
</poller>
|
||||
</bridge>
|
||||
|
||||
<bridge input-channel="subscribableChannel" output-channel="output2"/>
|
||||
|
||||
</beans:beans>
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2002-2008 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.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@ContextConfiguration
|
||||
public class BridgeParserTests extends AbstractJUnit4SpringContextTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("pollableChannel")
|
||||
private PollableChannel pollableChannel;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("subscribableChannel")
|
||||
private MessageChannel subscribableChannel;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("output1")
|
||||
private PollableChannel output1;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("output2")
|
||||
private PollableChannel output2;
|
||||
|
||||
|
||||
@Test
|
||||
public void pollableChannel() {
|
||||
Message<?> message = new StringMessage("test1");
|
||||
this.pollableChannel.send(message);
|
||||
Message<?> reply = this.output1.receive(1000);
|
||||
assertEquals(message, reply);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void subscribableChannel() {
|
||||
Message<?> message = new StringMessage("test2");
|
||||
this.subscribableChannel.send(message);
|
||||
Message<?> reply = this.output2.receive(0);
|
||||
assertEquals(message, reply);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user