INT-2049 added namespace support, also add SpEL support to CacheWritingMessageHandler and general cleanup
This commit is contained in:
committed by
Mark Fisher
parent
0bba8827ca
commit
a6cda6d93d
@@ -137,5 +137,4 @@ public class CacheListeningMessageProducerTests {
|
||||
assertNotNull(message2);
|
||||
assertEquals("foo was abc", message2.getPayload());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,11 +28,13 @@ import org.springframework.data.gemfire.RegionFactoryBean;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
import com.gemstone.bp.edu.emory.mathcs.backport.java.util.Collections;
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author David Turanski
|
||||
* @since 2.1
|
||||
*/
|
||||
public class CacheWritingMessageHandlerTests {
|
||||
@@ -56,5 +58,31 @@ public class CacheWritingMessageHandlerTests {
|
||||
assertEquals(1, region.size());
|
||||
assertEquals("bar", region.get("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ExpressionsWriteToCache() throws Exception {
|
||||
CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
|
||||
cacheFactoryBean.afterPropertiesSet();
|
||||
Cache cache = cacheFactoryBean.getObject();
|
||||
RegionFactoryBean<String, String> regionFactoryBean = new RegionFactoryBean<String, String>();
|
||||
regionFactoryBean.setName("test.expressionsWriteToCache");
|
||||
regionFactoryBean.setCache(cache);
|
||||
regionFactoryBean.afterPropertiesSet();
|
||||
Region<String, String> region = regionFactoryBean.getObject();
|
||||
assertEquals(0, region.size());
|
||||
CacheWritingMessageHandler handler = new CacheWritingMessageHandler(region);
|
||||
|
||||
Map<String, String> expressions = new HashMap<String, String>();
|
||||
expressions.put("'foo'", "'bar'");
|
||||
expressions.put("payload.toUpperCase()", "headers['bar'].toUpperCase()");
|
||||
handler.setCacheEntries(expressions);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Message<?> message = MessageBuilder.withPayload("foo").copyHeaders(Collections.singletonMap("bar", "bar")).build();
|
||||
handler.handleMessage(message);
|
||||
assertEquals(2, region.size());
|
||||
assertEquals("BAR", region.get("FOO"));
|
||||
assertEquals("bar", region.get("foo"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?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:p="http://www.springframework.org/schema/p"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
|
||||
<context:component-scan base-package="org.springframework.integration.gemfire.inbound.cq.client"/>
|
||||
|
||||
<context:property-placeholder location="org/springframework/integration/gemfire/inbound/cq/common.properties"/>
|
||||
|
||||
<!--<util:properties id="props" location="org/springframework/integration/gemfire/inbound/cq/gfe-cache.properties"/>-->
|
||||
|
||||
|
||||
|
||||
<int:channel id="cqIn"/>
|
||||
|
||||
<int:service-activator input-channel="cqIn" ref="cqServiceActivator"/>
|
||||
|
||||
</beans>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?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:p="http://www.springframework.org/schema/p"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
|
||||
<!-- infrastrcture-->
|
||||
<context:component-scan base-package="org.springframework.integration.gemfire.inbound.cq.server"/>
|
||||
<context:property-placeholder location="org/springframework/integration/gemfire/inbound/cq/common.properties"/>
|
||||
|
||||
<!-- setup the cache-->
|
||||
<util:properties id="props" location="org/springframework/integration/gemfire/inbound/cq/gfe-cache.properties"/>
|
||||
<gfe:cache properties-ref="props" id="c"/>
|
||||
|
||||
<!-- tx manager-->
|
||||
<gfe:transaction-manager cache-ref="c"/>
|
||||
|
||||
<!-- region -->
|
||||
<gfe:replicated-region id="r" name="${region-name}" cache-ref="c" />
|
||||
|
||||
</beans>
|
||||
@@ -1,5 +0,0 @@
|
||||
host=127.0.0.1
|
||||
port=55221
|
||||
region-name=people
|
||||
region-query=select * from /people
|
||||
correlation-header=time
|
||||
@@ -1,3 +0,0 @@
|
||||
log-level=warning
|
||||
name=Spring Integration GemFire World
|
||||
bind-address=127.0.0.1
|
||||
@@ -1,35 +0,0 @@
|
||||
<?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:p="http://www.springframework.org/schema/p"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<context:property-placeholder location="org/springframework/integration/gemfire/inbound/cq/common.properties"/>
|
||||
|
||||
<context:component-scan base-package="org.springframework.integration.gemfire.store.messagegroupstore"/>
|
||||
|
||||
<int:channel id="i"/>
|
||||
|
||||
<int:aggregator release-strategy="releaseStrategy" correlation-strategy="correlationStrategy" message-store="gemfireMessageGroupStore" input-channel="i" output-channel="o" />
|
||||
|
||||
<int:channel id="o"/>
|
||||
|
||||
<int:service-activator input-channel="o" ref="messageGroupStoreActivator" />
|
||||
|
||||
|
||||
<util:properties id="props" location="org/springframework/integration/gemfire/inbound/cq/gfe-cache.properties"/>
|
||||
|
||||
<gfe:cache properties-ref="props" id="c"/>
|
||||
<gfe:transaction-manager cache-ref="c"/>
|
||||
|
||||
<gfe:replicated-region id="unmarkedRegion" cache-ref="c"/>
|
||||
<gfe:replicated-region id="markedRegion" cache-ref="c"/>
|
||||
<gfe:replicated-region id="messageGroupRegion" cache-ref="c"/>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user