diff --git a/build.gradle b/build.gradle index 3f077c920c..a38e04e01c 100644 --- a/build.gradle +++ b/build.gradle @@ -135,7 +135,6 @@ allprojects { 'https://jakarta.ee/specifications/platform/9/apidocs/', 'https://docs.spring.io/spring-framework/docs/current/javadoc-api', 'https://docs.spring.io/spring-amqp/docs/current/api/', - 'https://docs.spring.io/spring-data-gemfire/docs/current/api/', 'https://docs.spring.io/spring-data/data-mongo/docs/current/api/', 'https://docs.spring.io/spring-data/data-redis/docs/current/api/', 'https://docs.spring.io/spring-ws/docs/current/api/' @@ -583,11 +582,11 @@ project('spring-integration-file') { testImplementation project(':spring-integration-redis') testImplementation project(':spring-integration-redis').sourceSets.test.output - testImplementation project(':spring-integration-gemfire') testImplementation project(':spring-integration-jdbc') testImplementation "com.h2database:h2:$h2Version" testImplementation "io.lettuce:lettuce-core:$lettuceVersion" testImplementation "com.jayway.jsonpath:json-path:$jsonpathVersion" + testImplementation 'com.fasterxml.jackson.core:jackson-databind' } } @@ -604,31 +603,6 @@ project('spring-integration-ftp') { } } -project('spring-integration-gemfire') { - description = 'Spring Integration GemFire Support' - dependencies { - api project(':spring-integration-core') - api('org.springframework.data:spring-data-geode') { - exclude group: 'org.springframework' - exclude group: 'org.apache.shiro', module: 'shiro-event' - exclude group: 'org.apache.shiro', module: 'shiro-lang' - exclude group: 'org.apache.shiro', module: 'shiro-crypto-hash' - exclude group: 'org.apache.shiro', module: 'shiro-crypto-cipher' - exclude group: 'org.apache.shiro', module: 'shiro-config-ogdl' - exclude group: 'org.apache.shiro', module: 'shiro-config-core' - exclude group: 'org.apache.shiro', module: 'shiro-cache' - exclude group: 'commons-logging' - } - api "commons-io:commons-io:$commonsIoVersion" - - testImplementation project(':spring-integration-stream') - } - - tasks.withType(JavaForkOptions) { - jvmArgs '--add-opens', 'jdk.management/com.sun.management.internal=ALL-UNNAMED' - } -} - project('spring-integration-graphql') { description = 'Spring Integration GraphQL Support' dependencies { diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/aggregator/FileAggregatorTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/aggregator/FileAggregatorTests.java index 8cdd05254c..1aad767f75 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/aggregator/FileAggregatorTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/aggregator/FileAggregatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 the original author or authors. + * Copyright 2021-2022 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. @@ -33,7 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; import org.springframework.core.task.TaskExecutor; import org.springframework.integration.IntegrationMessageHeaderAccessor; import org.springframework.integration.channel.QueueChannel; @@ -56,7 +55,6 @@ import org.springframework.util.FileCopyUtils; /** * @author Artem Bilan - * * @since 5.5 */ @SpringJUnitConfig @@ -81,12 +79,6 @@ public class FileAggregatorTests { @Autowired PollableChannel resultChannel; - @Autowired - MessageChannel input; - - @Autowired - PollableChannel output; - @BeforeAll static void setup() throws IOException { file = new File(tmpDir, "foo.txt"); @@ -146,26 +138,8 @@ public class FileAggregatorTests { .isEmpty(); } - @Test - void testFileAggregatorXmlConfig() { - this.input.send(new GenericMessage<>(file)); - - Message receive = this.output.receive(10_000); - assertThat(receive).isNotNull(); - assertThat(receive.getHeaders()) - .containsEntry(FileHeaders.FILENAME, "foo.txt") - .containsEntry(FileHeaders.LINE_COUNT, 4L) - .doesNotContainKeys("firstLine", IntegrationMessageHeaderAccessor.CORRELATION_ID); - - assertThat(receive.getPayload()) - .isInstanceOf(List.class) - .asList() - .containsExactly("file header", "first line", "second line", "last line"); - } - @Configuration @EnableIntegration - @ImportResource("org/springframework/integration/file/aggregator/FileAggregatorTests.xml") public static class Config { @Bean diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/aggregator/FileAggregatorTests.xml b/spring-integration-file/src/test/java/org/springframework/integration/file/aggregator/FileAggregatorTests.xml deleted file mode 100644 index bb528b2df4..0000000000 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/aggregator/FileAggregatorTests.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/filters/PersistentAcceptOnceFileListFilterExternalStoreTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/filters/PersistentAcceptOnceFileListFilterExternalStoreTests.java index 94aeeacdd8..c5590bb9f8 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/filters/PersistentAcceptOnceFileListFilterExternalStoreTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/filters/PersistentAcceptOnceFileListFilterExternalStoreTests.java @@ -27,7 +27,6 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.geode.cache.CacheFactory; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -35,7 +34,6 @@ import org.mockito.Mockito; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.StringRedisSerializer; -import org.springframework.integration.gemfire.metadata.GemfireMetadataStore; import org.springframework.integration.jdbc.metadata.JdbcMetadataStore; import org.springframework.integration.metadata.ConcurrentMetadataStore; import org.springframework.integration.redis.RedisContainerTest; @@ -50,9 +48,7 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; * @author Artem Bilan * @author Bojan Vukasovic * @author Artem Vozhdayenko - * * @since 4.0 - * */ public class PersistentAcceptOnceFileListFilterExternalStoreTests implements RedisContainerTest { @@ -80,11 +76,6 @@ public class PersistentAcceptOnceFileListFilterExternalStoreTests implements Red } } - @Test - public void testFileSystemWithGemfireMetadataStore() throws Exception { - this.testFileSystem(new GemfireMetadataStore(new CacheFactory().create())); - } - @Test public void testFileSystemWithJdbcMetadataStore() throws Exception { EmbeddedDatabase dataSource = new EmbeddedDatabaseBuilder() @@ -135,21 +126,21 @@ public class PersistentAcceptOnceFileListFilterExternalStoreTests implements Red final FileSystemPersistentAcceptOnceFileListFilter filter = new FileSystemPersistentAcceptOnceFileListFilter(store, "foo:"); final File file = File.createTempFile("foo", ".txt"); - assertThat(filter.filterFiles(new File[] {file})).hasSize(1); + assertThat(filter.filterFiles(new File[]{ file })).hasSize(1); String ts = store.get("foo:" + file.getAbsolutePath()); assertThat(ts).isEqualTo(String.valueOf(file.lastModified())); - assertThat(filter.filterFiles(new File[] {file})).isEmpty(); + assertThat(filter.filterFiles(new File[]{ file })).isEmpty(); assertThat(file.setLastModified(file.lastModified() + 5000L)).isTrue(); - assertThat(filter.filterFiles(new File[] {file})).hasSize(1); + assertThat(filter.filterFiles(new File[]{ file })).hasSize(1); ts = store.get("foo:" + file.getAbsolutePath()); assertThat(ts).isEqualTo(String.valueOf(file.lastModified())); - assertThat(filter.filterFiles(new File[] {file})).isEmpty(); + assertThat(filter.filterFiles(new File[]{ file })).isEmpty(); suspend.set(true); assertThat(file.setLastModified(file.lastModified() + 5000L)).isTrue(); Future result = Executors.newSingleThreadExecutor() - .submit(() -> filter.filterFiles(new File[] {file}).size()); + .submit(() -> filter.filterFiles(new File[]{ file }).size()); assertThat(latch2.await(10, TimeUnit.SECONDS)).isTrue(); store.put("foo:" + file.getAbsolutePath(), "43"); latch1.countDown(); diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParser.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParser.java deleted file mode 100644 index 93f3638632..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParser.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.config.xml; - -import org.w3c.dom.Element; - -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.integration.config.xml.AbstractChannelAdapterParser; -import org.springframework.integration.config.xml.IntegrationNamespaceUtils; -import org.springframework.integration.gemfire.inbound.ContinuousQueryMessageProducer; - -/** - * @author David Turanski - * @author Dan Oxlade - * @author Gary Russell - * @author Artem Bilan - * @since 2.1 - * - */ -public class GemfireCqInboundChannelAdapterParser extends AbstractChannelAdapterParser { - - - private static final String ERROR_CHANNEL_ATTRIBUTE = "error-channel"; - - private static final String OUTPUT_CHANNEL_PROPERTY = "outputChannel"; - - private static final String QUERY_LISTENER_CONTAINER_ATTRIBUTE = "cq-listener-container"; - - private static final String DURABLE_ATTRIBUTE = "durable"; - - private static final String QUERY_NAME_ATTRIBUTE = "query-name"; - - private static final String QUERY_ATTRIBUTE = "query"; - - private static final String EXPRESSION_ATTRIBUTE = "expression"; - - private static final String SUPPORTED_EVENT_TYPES_PROPERTY = "supportedEventTypes"; - - private static final String QUERY_EVENTS_ATTRIBUTE = "query-events"; - - @Override - protected AbstractBeanDefinition doParse(Element element, ParserContext parserContext, String channelName) { - BeanDefinitionBuilder continuousQueryMessageProducer = - BeanDefinitionBuilder.genericBeanDefinition(ContinuousQueryMessageProducer.class); - IntegrationNamespaceUtils.setValueIfAttributeDefined(continuousQueryMessageProducer, element, - EXPRESSION_ATTRIBUTE, "payloadExpressionString"); - IntegrationNamespaceUtils.setValueIfAttributeDefined(continuousQueryMessageProducer, element, - QUERY_EVENTS_ATTRIBUTE, SUPPORTED_EVENT_TYPES_PROPERTY); - - if (!element.hasAttribute(QUERY_LISTENER_CONTAINER_ATTRIBUTE)) { - parserContext.getReaderContext() - .error("'" + QUERY_LISTENER_CONTAINER_ATTRIBUTE + "' attribute is required.", element); - } - - if (!element.hasAttribute(QUERY_ATTRIBUTE)) { - parserContext.getReaderContext().error("'" + QUERY_ATTRIBUTE + "' attribute is required.", element); - } - - continuousQueryMessageProducer.addConstructorArgReference(element.getAttribute(QUERY_LISTENER_CONTAINER_ATTRIBUTE)); - continuousQueryMessageProducer.addConstructorArgValue(element.getAttribute(QUERY_ATTRIBUTE)); - - continuousQueryMessageProducer.addPropertyReference(OUTPUT_CHANNEL_PROPERTY, channelName); - IntegrationNamespaceUtils.setReferenceIfAttributeDefined(continuousQueryMessageProducer, element, - ERROR_CHANNEL_ATTRIBUTE); - - IntegrationNamespaceUtils.setValueIfAttributeDefined(continuousQueryMessageProducer, element, QUERY_NAME_ATTRIBUTE); - IntegrationNamespaceUtils.setValueIfAttributeDefined(continuousQueryMessageProducer, element, DURABLE_ATTRIBUTE); - return continuousQueryMessageProducer.getBeanDefinition(); - } - -} diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParser.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParser.java deleted file mode 100644 index 67928a8ad9..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParser.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.config.xml; - -import org.w3c.dom.Element; - -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.integration.config.xml.AbstractChannelAdapterParser; -import org.springframework.integration.config.xml.IntegrationNamespaceUtils; -import org.springframework.integration.gemfire.inbound.CacheListeningMessageProducer; - -/** - * @author David Turanski - * @author Gary Russell - * @author Artem Bilan - * @since 2.1 - */ -public class GemfireInboundChannelAdapterParser extends AbstractChannelAdapterParser { - - private static final String ERROR_CHANNEL_ATTRIBUTE = "error-channel"; - - private static final String OUTPUT_CHANNEL_PROPERTY = "outputChannel"; - - private static final String REGION_ATTRIBUTE = "region"; - - private static final String EXPRESSION_ATTRIBUTE = "expression"; - - private static final String SUPPORTED_EVENT_TYPES_PROPERTY = "supportedEventTypes"; - - private static final String CACHE_EVENTS_ATTRIBUTE = "cache-events"; - - @Override - protected AbstractBeanDefinition doParse(Element element, ParserContext parserContext, String channelName) { - BeanDefinitionBuilder listeningMessageProducer = - BeanDefinitionBuilder.genericBeanDefinition(CacheListeningMessageProducer.class); - IntegrationNamespaceUtils.setValueIfAttributeDefined(listeningMessageProducer, element, - EXPRESSION_ATTRIBUTE, "payloadExpressionString"); - IntegrationNamespaceUtils.setValueIfAttributeDefined(listeningMessageProducer, element, - CACHE_EVENTS_ATTRIBUTE, SUPPORTED_EVENT_TYPES_PROPERTY); - - if (!element.hasAttribute(REGION_ATTRIBUTE)) { - parserContext.getReaderContext().error("'region' attribute is required.", element); - } - - listeningMessageProducer.addConstructorArgReference(element.getAttribute(REGION_ATTRIBUTE)); - - listeningMessageProducer.addPropertyReference(OUTPUT_CHANNEL_PROPERTY, channelName); - IntegrationNamespaceUtils.setReferenceIfAttributeDefined(listeningMessageProducer, element, - ERROR_CHANNEL_ATTRIBUTE); - return listeningMessageProducer.getBeanDefinition(); - } - -} diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireIntegrationNamespaceHandler.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireIntegrationNamespaceHandler.java deleted file mode 100644 index 3492154fd3..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireIntegrationNamespaceHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.config.xml; - -import org.springframework.integration.config.xml.AbstractIntegrationNamespaceHandler; - -/** - * @author David Turanski - * @since 2.1 - */ -public class GemfireIntegrationNamespaceHandler extends AbstractIntegrationNamespaceHandler { - - /* (non-Javadoc) - * @see org.springframework.beans.factory.xml.NamespaceHandler#init() - */ - public void init() { - registerBeanDefinitionParser("inbound-channel-adapter", new GemfireInboundChannelAdapterParser()); - registerBeanDefinitionParser("cq-inbound-channel-adapter", new GemfireCqInboundChannelAdapterParser()); - registerBeanDefinitionParser("outbound-channel-adapter", new GemfireOutboundChannelAdapterParser()); - } - -} diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireOutboundChannelAdapterParser.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireOutboundChannelAdapterParser.java deleted file mode 100644 index ec617c8ac4..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireOutboundChannelAdapterParser.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.config.xml; - -import java.util.Map; - -import org.w3c.dom.Element; - -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser; -import org.springframework.integration.gemfire.outbound.CacheWritingMessageHandler; -import org.springframework.util.xml.DomUtils; - -/** - * @author David Turanski - * @author Gary Russell - * @since 2.1 - */ -public class GemfireOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser { - - private static final String CACHE_ENTRIES_PROPERTY = "cacheEntries"; - - private static final String CACHE_ENTRIES_ELEMENT = "cache-entries"; - - private static final String REGION_ATTRIBUTE = "region"; - - /* (non-Javadoc) - * @see AbstractOutboundChannelAdapterParser#parseConsumer(Element, ParserContext) - */ - @Override - protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { - BeanDefinitionBuilder cacheWritingMessageHandler = BeanDefinitionBuilder.genericBeanDefinition( - CacheWritingMessageHandler.class); - if (!element.hasAttribute(REGION_ATTRIBUTE)) { - parserContext.getReaderContext().error("'region' attribute is required.", element); - } - - cacheWritingMessageHandler.addConstructorArgReference(element.getAttribute(REGION_ATTRIBUTE)); - - Element cacheEntries = DomUtils.getChildElementByTagName(element, CACHE_ENTRIES_ELEMENT); - if (cacheEntries != null) { - Map map = parserContext.getDelegate() - .parseMapElement(cacheEntries, cacheWritingMessageHandler.getBeanDefinition()); - cacheWritingMessageHandler.addPropertyValue(CACHE_ENTRIES_PROPERTY, map); - } - return cacheWritingMessageHandler.getBeanDefinition(); - } -} diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/package-info.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/package-info.java deleted file mode 100644 index 83e13b5ba4..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides classes for configuration - parsers, namespace handlers. - */ -package org.springframework.integration.gemfire.config.xml; diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducer.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducer.java deleted file mode 100644 index 61c609c649..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducer.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.inbound; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.geode.cache.CacheClosedException; -import org.apache.geode.cache.CacheListener; -import org.apache.geode.cache.EntryEvent; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.util.CacheListenerAdapter; - -import org.springframework.integration.endpoint.ExpressionMessageProducerSupport; -import org.springframework.messaging.Message; -import org.springframework.util.Assert; - -/** - * An inbound endpoint that listens to a GemFire region for events and then publishes Messages to - * a channel. The default supported event types are CREATED and UPDATED. See the {@link EventType} - * enum for all options. A SpEL expression may be provided to generate a Message payload by - * evaluating that expression against the {@link EntryEvent} instance as the root object. If no - * payloadExpression is provided, the {@link EntryEvent} itself will be the payload. - * - * @author Mark Fisher - * @author David Turanski - * @author Artem Bilan - * @since 2.1 - */ -@SuppressWarnings({ "rawtypes", "unchecked" }) -public class CacheListeningMessageProducer extends ExpressionMessageProducerSupport { - - private final Log logger = LogFactory.getLog(this.getClass()); - - private final Region region; - - private final CacheListener listener; - - private volatile Set supportedEventTypes = - new HashSet(Arrays.asList(EventType.CREATED, EventType.UPDATED)); - - - public CacheListeningMessageProducer(Region region) { - Assert.notNull(region, "region must not be null"); - this.region = region; - this.listener = new MessageProducingCacheListener(); - } - - - public void setSupportedEventTypes(EventType... eventTypes) { - Assert.notEmpty(eventTypes, "eventTypes must not be empty"); - this.supportedEventTypes = new HashSet(Arrays.asList(eventTypes)); - } - - @Override - public String getComponentType() { - return "gemfire:inbound-channel-adapter"; - } - - @Override - protected void doStart() { - if (this.logger.isInfoEnabled()) { - this.logger.info("adding MessageProducingCacheListener to GemFire Region '" + this.region.getName() + "'"); - } - this.region.getAttributesMutator().addCacheListener(this.listener); - } - - @Override - protected void doStop() { - if (this.logger.isInfoEnabled()) { - this.logger.info("removing MessageProducingCacheListener from GemFire Region '" + this.region.getName() + "'"); - } - try { - this.region.getAttributesMutator().removeCacheListener(this.listener); - } - catch (CacheClosedException e) { - if (this.logger.isDebugEnabled()) { - this.logger.debug(e.getMessage(), e); - } - } - - } - - private class MessageProducingCacheListener extends CacheListenerAdapter { - - @Override - public void afterCreate(EntryEvent event) { - if (CacheListeningMessageProducer.this.supportedEventTypes.contains(EventType.CREATED)) { - processEvent(event); - } - } - - @Override - public void afterUpdate(EntryEvent event) { - if (CacheListeningMessageProducer.this.supportedEventTypes.contains(EventType.UPDATED)) { - processEvent(event); - } - } - - @Override - public void afterInvalidate(EntryEvent event) { - if (CacheListeningMessageProducer.this.supportedEventTypes.contains(EventType.INVALIDATED)) { - processEvent(event); - } - } - - @Override - public void afterDestroy(EntryEvent event) { - if (CacheListeningMessageProducer.this.supportedEventTypes.contains(EventType.DESTROYED)) { - processEvent(event); - } - } - - private void processEvent(EntryEvent event) { - publish(evaluatePayloadExpression(event)); - - } - - private void publish(Object object) { - Message message = null; - if (object instanceof Message) { - message = (Message) object; - } - else { - message = getMessageBuilderFactory().withPayload(object).build(); - } - sendMessage(message); - } - } - -} diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/ContinuousQueryMessageProducer.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/ContinuousQueryMessageProducer.java deleted file mode 100644 index 665e3abf69..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/ContinuousQueryMessageProducer.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.inbound; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.geode.cache.query.CqEvent; - -import org.springframework.data.gemfire.listener.ContinuousQueryDefinition; -import org.springframework.data.gemfire.listener.ContinuousQueryListener; -import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer; -import org.springframework.integration.endpoint.ExpressionMessageProducerSupport; -import org.springframework.messaging.Message; -import org.springframework.util.Assert; - -/** - * Responds to a Gemfire continuous query (set using the #query field) that is - * constantly evaluated against a cache - * {@link org.apache.geode.cache.Region}. This is much faster than - * re-querying the cache manually. - * - * @author Josh Long - * @author David Turanski - * @author Artem Bilan - * @since 2.1 - * - */ -public class ContinuousQueryMessageProducer extends ExpressionMessageProducerSupport - implements ContinuousQueryListener { - - private static Log logger = LogFactory.getLog(ContinuousQueryMessageProducer.class); - - private final String query; - - private final ContinuousQueryListenerContainer queryListenerContainer; - - private volatile String queryName; - - private boolean durable; - - private volatile Set supportedEventTypes = - new HashSet(Arrays.asList(CqEventType.CREATED, CqEventType.UPDATED)); - - /** - * @param queryListenerContainer a {@link ContinuousQueryListenerContainer} - * @param query the query string - */ - public ContinuousQueryMessageProducer(ContinuousQueryListenerContainer queryListenerContainer, String query) { - Assert.notNull(queryListenerContainer, "'queryListenerContainer' cannot be null"); - Assert.notNull(query, "'query' cannot be null"); - this.queryListenerContainer = queryListenerContainer; - this.query = query; - } - - /** - * @param queryName optional query name - */ - public void setQueryName(String queryName) { - this.queryName = queryName; - } - - /** - * @param durable true if the query is a durable subscription - */ - public void setDurable(boolean durable) { - this.durable = durable; - } - - public void setSupportedEventTypes(CqEventType... eventTypes) { - Assert.notEmpty(eventTypes, "eventTypes must not be empty"); - this.supportedEventTypes = new HashSet(Arrays.asList(eventTypes)); - } - - @Override - public String getComponentType() { - return "gemfire:cq-inbound-channel-adapter"; - } - - @Override - protected void onInit() { - super.onInit(); - if (this.queryName == null) { - this.queryListenerContainer.addListener(new ContinuousQueryDefinition(this.query, this, this.durable)); - } - else { - this.queryListenerContainer.addListener(new ContinuousQueryDefinition(this.queryName, this.query, this, - this.durable)); - } - } - - /* - * (non-Javadoc) - * @see org.springframework.data.gemfire.listener.QueryListener#onEvent(com.gemstone.gemfire.cache.query.CqEvent) - */ - @Override - public void onEvent(CqEvent event) { - if (isEventSupported(event)) { - if (logger.isDebugEnabled()) { - logger.debug(String.format("processing cq event key [%s] event [%s]", event.getQueryOperation() - .toString(), event.getKey())); - } - Message message = null; - Object object = evaluatePayloadExpression(event); - if (object instanceof Message) { - message = (Message) object; - } - else { - message = getMessageBuilderFactory().withPayload(object).build(); - } - sendMessage(message); - } - } - - private boolean isEventSupported(CqEvent event) { - - String eventName = event.getQueryOperation().toString() + - (event.getQueryOperation().toString().endsWith("Y") ? "ED" : "D"); - CqEventType eventType = CqEventType.valueOf(eventName); - return this.supportedEventTypes.contains(eventType); - } - -} diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/CqEventType.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/CqEventType.java deleted file mode 100644 index 7964a5309a..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/CqEventType.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2002-2021 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 - * - * https://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.gemfire.inbound; - -/** - * Enumeration of GemFire Continuous Query Event Types. - * - * @author David Turanski - * - * @since 2.1 - */ -public enum CqEventType { - CREATED, - - UPDATED, - - DESTROYED, - - REGION_CLEARED, - - REGION_INVALIDATED -} diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/EventType.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/EventType.java deleted file mode 100644 index 60be238d84..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/EventType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.inbound; - -/** - * Enumeration of GemFire event types. - * - * @author Mark Fisher - * @since 2.1 - */ -public enum EventType { - - CREATED, - - UPDATED, - - DESTROYED, - - INVALIDATED - -} diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/package-info.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/package-info.java deleted file mode 100644 index 29f4b7f241..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/inbound/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides classes supporting inbound endpoints. - */ -package org.springframework.integration.gemfire.inbound; diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStore.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStore.java deleted file mode 100644 index 6630883014..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStore.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2014-2019 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 - * - * https://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.gemfire.metadata; - -import java.util.List; -import java.util.Objects; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.EntryEvent; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.Scope; -import org.apache.geode.cache.util.CacheListenerAdapter; - -import org.springframework.integration.metadata.ListenableMetadataStore; -import org.springframework.integration.metadata.MetadataStoreListener; -import org.springframework.util.Assert; - -/** - * Gemfire implementation of {@link ListenableMetadataStore}. - * Use this {@link org.springframework.integration.metadata.MetadataStore} - * to achieve meta-data persistence shared across application instances and - * restarts. - * - * @author Artem Bilan - * @author Venil Noronha - * @author Gary Russell - * - * @since 4.0 - */ -public class GemfireMetadataStore implements ListenableMetadataStore { - - private static final String KEY_MUST_NOT_BE_NULL = "'key' must not be null."; - - public static final String KEY = "MetaData"; - - private final GemfireCacheListener cacheListener = new GemfireCacheListener(); - - private final Region region; - - public GemfireMetadataStore(Cache cache) { - this(Objects.requireNonNull(cache, "'cache' must not be null") - .createRegionFactory() - .setScope(Scope.LOCAL) - .create(KEY)); - } - - public GemfireMetadataStore(Region region) { - Assert.notNull(region, "'region' must not be null"); - this.region = region; - this.region.getAttributesMutator() - .addCacheListener(this.cacheListener); - } - - @Override - public void put(String key, String value) { - Assert.notNull(key, KEY_MUST_NOT_BE_NULL); - Assert.notNull(value, "'value' must not be null."); - this.region.put(key, value); - } - - @Override - public String putIfAbsent(String key, String value) { - Assert.notNull(key, KEY_MUST_NOT_BE_NULL); - Assert.notNull(value, "'value' must not be null."); - return this.region.putIfAbsent(key, value); - } - - @Override - public boolean replace(String key, String oldValue, String newValue) { - Assert.notNull(key, KEY_MUST_NOT_BE_NULL); - Assert.notNull(oldValue, "'oldValue' must not be null."); - Assert.notNull(newValue, "'newValue' must not be null."); - return this.region.replace(key, oldValue, newValue); - } - - @Override - public String get(String key) { - Assert.notNull(key, KEY_MUST_NOT_BE_NULL); - return this.region.get(key); - } - - @Override - public String remove(String key) { - Assert.notNull(key, KEY_MUST_NOT_BE_NULL); - return this.region.remove(key); - } - - @Override - public void addListener(MetadataStoreListener listener) { - Assert.notNull(listener, "'listener' must not be null"); - this.cacheListener.listeners.add(listener); - } - - @Override - public void removeListener(MetadataStoreListener listener) { - this.cacheListener.listeners.remove(listener); - } - - private static class GemfireCacheListener extends CacheListenerAdapter { - - private final List listeners = new CopyOnWriteArrayList<>(); - - GemfireCacheListener() { - } - - @Override - public void afterCreate(EntryEvent event) { - this.listeners.forEach(listener -> listener.onAdd(event.getKey(), event.getNewValue())); - } - - @Override - public void afterUpdate(EntryEvent event) { - this.listeners.forEach(listener -> listener.onUpdate(event.getKey(), event.getNewValue())); - } - - @Override - public void afterDestroy(EntryEvent event) { - this.listeners.forEach(listener -> listener.onRemove(event.getKey(), event.getOldValue())); - } - - } - -} diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/metadata/package-info.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/metadata/package-info.java deleted file mode 100644 index 5454827492..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/metadata/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides classes for the Gemfire MetadataStore. - */ -package org.springframework.integration.gemfire.metadata; diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/outbound/CacheWritingMessageHandler.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/outbound/CacheWritingMessageHandler.java deleted file mode 100644 index 018e6d364c..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/outbound/CacheWritingMessageHandler.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.outbound; - -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.geode.GemFireCheckedException; -import org.apache.geode.GemFireException; -import org.apache.geode.cache.Region; - -import org.springframework.data.gemfire.GemfireCallback; -import org.springframework.data.gemfire.GemfireTemplate; -import org.springframework.expression.EvaluationContext; -import org.springframework.expression.Expression; -import org.springframework.expression.spel.standard.SpelExpressionParser; -import org.springframework.integration.expression.ExpressionUtils; -import org.springframework.integration.handler.AbstractMessageHandler; -import org.springframework.messaging.Message; -import org.springframework.util.Assert; - -/** - * A {@link org.springframework.messaging.MessageHandler} implementation that writes to a - * GemFire Region. The Message's payload must be an instance of {@link Map} or - * {@link #cacheEntryExpressions} must be provided. - * - * @author Mark Fisher - * @author David Turanski - * @author Artem Bilan - * @author Gary Russell - * - * @since 2.1 - */ -public class CacheWritingMessageHandler extends AbstractMessageHandler { - - private static final SpelExpressionParser PARSER = new SpelExpressionParser(); - - private final Map cacheEntryExpressions = new LinkedHashMap(); - - private final GemfireTemplate gemfireTemplate = new GemfireTemplate(); - - private volatile EvaluationContext evaluationContext; - - @SuppressWarnings("rawtypes") - public CacheWritingMessageHandler(Region region) { - Assert.notNull(region, "region must not be null"); - this.gemfireTemplate.setRegion(region); - } - - @Override - public String getComponentType() { - return "gemfire:outbound-channel-adapter"; - } - - @Override - protected void onInit() { - super.onInit(); - this.gemfireTemplate.afterPropertiesSet(); - this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory()); - } - - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected void handleMessageInternal(Message message) { - Object payload = message.getPayload(); - Map cacheValues = (this.cacheEntryExpressions.size() > 0) ? evaluateCacheEntries(message) : null; - - if (cacheValues == null) { - Assert.state(payload instanceof Map, - "If cache entry expressions are not configured, then payload must be a Map"); - cacheValues = (Map) payload; - } - - final Map map = cacheValues; - - this.gemfireTemplate.execute(new GemfireCallback() { - - @Override - public Object doInGemfire(Region region) throws GemFireCheckedException, GemFireException { - region.putAll(map); - return null; - } - - }); - } - - private Map evaluateCacheEntries(Message message) { - if (this.cacheEntryExpressions.size() == 0) { - return null; - } - else { - Map cacheValues = new HashMap(); - for (Entry expressionEntry : this.cacheEntryExpressions.entrySet()) { - cacheValues.put(expressionEntry.getKey().getValue(this.evaluationContext, message), - expressionEntry.getValue().getValue(this.evaluationContext, message)); - } - return cacheValues; - } - } - - public void setCacheEntries(Map cacheEntries) { - Assert.notNull(cacheEntries, "'cacheEntries' must not be null"); - if (this.cacheEntryExpressions.size() > 0) { - this.cacheEntryExpressions.clear(); - } - - for (Entry cacheEntry : cacheEntries.entrySet()) { - this.cacheEntryExpressions.put(PARSER.parseExpression(cacheEntry.getKey()), - PARSER.parseExpression(cacheEntry.getValue())); - } - } - - public void setCacheEntryExpressions(Map cacheEntryExpressions) { - Assert.notNull(cacheEntryExpressions, "'cacheEntryExpressions' must not be null"); - if (this.cacheEntryExpressions.size() > 0) { - this.cacheEntryExpressions.clear(); - } - this.cacheEntryExpressions.putAll(cacheEntryExpressions); - } - -} diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/outbound/package-info.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/outbound/package-info.java deleted file mode 100644 index 67906692f3..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/outbound/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides classes supporting outbound endpoints. - */ -package org.springframework.integration.gemfire.outbound; diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/store/GemfireMessageStore.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/store/GemfireMessageStore.java deleted file mode 100644 index 93f73bf4a6..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/store/GemfireMessageStore.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2002-2021 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 - * - * https://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.gemfire.store; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.apache.geode.cache.Region; - -import org.springframework.integration.store.AbstractKeyValueMessageStore; -import org.springframework.util.Assert; -import org.springframework.util.PatternMatchUtils; - -/** - * Gemfire implementation of the key/value style - * {@link org.springframework.integration.store.MessageStore} and - * {@link org.springframework.integration.store.MessageGroupStore}. - * - * @author Mark Fisher - * @author Oleg Zhurakousky - * @author David Turanski - * @author Artem Bilan - * @author Gary Russell - * - * @since 2.1 - */ -public class GemfireMessageStore extends AbstractKeyValueMessageStore { - - private static final String ID_MUST_NOT_BE_NULL = "'id' must not be null"; - - private final Region messageStoreRegion; - - /** - * Provides the region to be used for the message store. This is useful when - * using a configured region. This is also required if using a client region - * on a remote cache server. - * @param messageStoreRegion The region. - */ - public GemfireMessageStore(Region messageStoreRegion) { - this(messageStoreRegion, ""); - } - - /** - * Construct a {@link GemfireMessageStore} instance based on the provided. - * @param messageStoreRegion the region to use. - * @param prefix the key prefix to use, allowing the same region to be used for - * multiple stores. - * @since 4.3.12 - */ - public GemfireMessageStore(Region messageStoreRegion, String prefix) { - super(prefix); - Assert.notNull(messageStoreRegion, "'messageStoreRegion' must not be null"); - this.messageStoreRegion = messageStoreRegion; - } - - @Override - protected Object doRetrieve(Object id) { - Assert.notNull(id, ID_MUST_NOT_BE_NULL); - return this.messageStoreRegion.get(id); - } - - @Override - protected void doStore(Object id, Object objectToStore) { - Assert.notNull(id, ID_MUST_NOT_BE_NULL); - Assert.notNull(objectToStore, "'objectToStore' must not be null"); - this.messageStoreRegion.put(id, objectToStore); - } - - @Override - protected void doStoreIfAbsent(Object id, Object objectToStore) { - Assert.notNull(id, ID_MUST_NOT_BE_NULL); - Assert.notNull(objectToStore, "'objectToStore' must not be null"); - Object present = this.messageStoreRegion.putIfAbsent(id, objectToStore); - if (present != null && logger.isDebugEnabled()) { - logger.debug("The message: [" + present + "] is already present in the store. " + - "The [" + objectToStore + "] is ignored."); - } - } - - @Override - protected Object doRemove(Object id) { - Assert.notNull(id, ID_MUST_NOT_BE_NULL); - return this.messageStoreRegion.remove(id); - } - - @Override - protected void doRemoveAll(Collection ids) { - this.messageStoreRegion.removeAll(ids); - } - - @Override - protected Collection doListKeys(String keyPattern) { - Assert.hasText(keyPattern, "'keyPattern' must not be empty"); - Collection keys = this.messageStoreRegion.keySet(); - List keyList = new ArrayList(); - for (Object key : keys) { - String keyValue = key.toString(); - if (PatternMatchUtils.simpleMatch(keyPattern, keyValue)) { - keyList.add(keyValue); - } - } - return keyList; - } - -} diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/store/package-info.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/store/package-info.java deleted file mode 100644 index 4b9f37ad31..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/store/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides classes releated to storing messages. - */ -package org.springframework.integration.gemfire.store; diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/util/GemfireLockRegistry.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/util/GemfireLockRegistry.java deleted file mode 100644 index c23f8d5836..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/util/GemfireLockRegistry.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2014-2019 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 - * - * https://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.gemfire.util; - -import java.util.concurrent.locks.Lock; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.Scope; - -import org.springframework.integration.support.locks.LockRegistry; -import org.springframework.util.Assert; - -/** - * Implementation of {@link LockRegistry} providing a distributed lock using Gemfire. - * - * @author Artem Bilan - * @since 4.0 - */ -public class GemfireLockRegistry implements LockRegistry { - - public static final String LOCK_REGISTRY_REGION = "LockRegistry"; - - private final Region region; - - public GemfireLockRegistry(Cache cache) { - Assert.notNull(cache, "'cache' must not be null"); - this.region = cache.createRegionFactory().setScope(Scope.GLOBAL).create(LOCK_REGISTRY_REGION); - } - - public GemfireLockRegistry(Region region) { - Assert.notNull(region, "'region' must not be null"); - this.region = region; - } - - @Override - public Lock obtain(Object lockKey) { - return this.region.getDistributedLock(lockKey); - } - -} diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/util/package-info.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/util/package-info.java deleted file mode 100644 index fe86a3b804..0000000000 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/util/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Provides utility classes. - */ -package org.springframework.integration.gemfire.util; diff --git a/spring-integration-gemfire/src/main/resources/META-INF/spring.handlers b/spring-integration-gemfire/src/main/resources/META-INF/spring.handlers deleted file mode 100644 index 0e5c816b48..0000000000 --- a/spring-integration-gemfire/src/main/resources/META-INF/spring.handlers +++ /dev/null @@ -1 +0,0 @@ -http\://www.springframework.org/schema/integration/gemfire=org.springframework.integration.gemfire.config.xml.GemfireIntegrationNamespaceHandler \ No newline at end of file diff --git a/spring-integration-gemfire/src/main/resources/META-INF/spring.schemas b/spring-integration-gemfire/src/main/resources/META-INF/spring.schemas deleted file mode 100644 index 77c8c378a1..0000000000 --- a/spring-integration-gemfire/src/main/resources/META-INF/spring.schemas +++ /dev/null @@ -1,22 +0,0 @@ -http\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-2.1.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -http\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-2.2.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -http\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-3.0.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -http\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-4.0.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -http\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-4.1.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -http\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-4.2.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -http\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-4.3.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -http\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-5.0.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -http\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-5.1.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -http\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-5.2.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -http\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -https\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-2.1.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -https\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-2.2.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -https\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-3.0.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -https\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-4.0.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -https\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-4.1.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -https\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-4.2.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -https\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-4.3.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -https\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-5.0.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -https\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-5.1.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -https\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire-5.2.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd -https\://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire.xsd=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd diff --git a/spring-integration-gemfire/src/main/resources/META-INF/spring.tooling b/spring-integration-gemfire/src/main/resources/META-INF/spring.tooling deleted file mode 100644 index 54d874b910..0000000000 --- a/spring-integration-gemfire/src/main/resources/META-INF/spring.tooling +++ /dev/null @@ -1,4 +0,0 @@ -# Tooling related information for the integration gemfire namespace -http\://www.springframework.org/schema/integration/gemfire@name=integration gemfire Namespace -http\://www.springframework.org/schema/integration/gemfire@prefix=int-gfe -http\://www.springframework.org/schema/integration@icon=org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.gif diff --git a/spring-integration-gemfire/src/main/resources/org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.gif b/spring-integration-gemfire/src/main/resources/org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.gif deleted file mode 100644 index 210e0764fa..0000000000 Binary files a/spring-integration-gemfire/src/main/resources/org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.gif and /dev/null differ diff --git a/spring-integration-gemfire/src/main/resources/org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd b/spring-integration-gemfire/src/main/resources/org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd deleted file mode 100644 index 5a9e080dac..0000000000 --- a/spring-integration-gemfire/src/main/resources/org/springframework/integration/gemfire/config/xml/spring-integration-gemfire.xsd +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - - - - - - - - Configures a Message Producing Endpoint for the - 'org.springframework.integration.gemfire.inbound.CacheListeningMessageProducer' that backed by a - GemFire CacheListener - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Configures a 'SourcePollingChannelAdapter' Endpoint for the - 'org.springframework.integration.gemfire.inbound.ContinuousQueryMessageProducer' - that backed by a - Spring Gemfire QueryListener - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Configures a Consumer Endpoint for the - 'org.springframework.integration.gemfire.outbound.CacheWritingMessageHandler' that - writes Message to a Gemfire cache - - - - - - - A map of SpEL expressions used to create cache entries. If not - provided, payload must be a Map - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Identifies the channel to which error messages will be sent if a failure occurs in this - component's invocation. If no "error-channel" reference is provided, this component will - propagate Exceptions to the caller. To completely suppress Exceptions, provide a - reference to the "nullChannel" here. - - - - - - - - - - - - - - - - diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/TestCacheListenerLogger.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/TestCacheListenerLogger.java deleted file mode 100644 index f34a912cad..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/TestCacheListenerLogger.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.geode.cache.EntryEvent; -import org.apache.geode.cache.util.CacheListenerAdapter; - -/** - * (this is the CacheLogger class that ships in the Spring-Gemfire samples) - * - * @author Costin Leau - */ -public class TestCacheListenerLogger extends CacheListenerAdapter { - - private static final Log log = LogFactory.getLog(TestCacheListenerLogger.class); - - @Override - public void afterCreate(EntryEvent event) { - log.info("Added " + messageLog(event) + " to the cache"); - } - - @Override - public void afterDestroy(EntryEvent event) { - log.info("Removed " + messageLog(event) + " from the cache"); - } - - @Override - public void afterUpdate(EntryEvent event) { - log.info("Updated " + messageLog(event) + " in the cache"); - } - - private String messageLog(EntryEvent event) { - Object key = event.getKey(); - Object value = event.getNewValue(); - - if (event.getOperation().isUpdate()) { - return "[" + key + "] from [" + event.getOldValue() + "] to [" + event.getNewValue() + "]"; - } - return "[" + key + "=" + value + "]"; - } -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParserTests-context.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParserTests-context.xml deleted file mode 100644 index 0fd7c94027..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParserTests-context.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - true - - - - - - - - - - - - - - diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParserTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParserTests.java deleted file mode 100644 index 7ae8af9797..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParserTests.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.config.xml; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.integration.gemfire.config.xml.ParserTestUtil.createFakeParserContext; -import static org.springframework.integration.gemfire.config.xml.ParserTestUtil.loadXMLFrom; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.w3c.dom.Element; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; -import org.springframework.integration.gemfire.inbound.ContinuousQueryMessageProducer; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Dan Oxlade - * @author Liujiong - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration -@DirtiesContext -public class GemfireCqInboundChannelAdapterParserTests { - - private GemfireCqInboundChannelAdapterParser underTest = new GemfireCqInboundChannelAdapterParser(); - - @Autowired - @Qualifier("withDurable") - ContinuousQueryMessageProducer adapter; - - @Test(expected = BeanDefinitionParsingException.class) - public void cqListenerContainerIsARequiredAttribute() throws Exception { - String xml = ""; - Element element = loadXMLFrom(xml).getDocumentElement(); - underTest.doParse(element, createFakeParserContext(), null); - } - - @Test(expected = BeanDefinitionParsingException.class) - public void queryIsARequiredAttribute() throws Exception { - String xml = ""; - Element element = loadXMLFrom(xml).getDocumentElement(); - underTest.doParse(element, createFakeParserContext(), null); - } - - @Test - public void testPhase() { - assertThat(adapter.getPhase()).isEqualTo(2); - } - - @Test - public void testAutoStartup() { - assertThat(adapter.isAutoStartup()).isEqualTo(false); - } -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParserTests-context.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParserTests-context.xml deleted file mode 100644 index 9fbfb57ba0..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParserTests-context.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParserTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParserTests.java deleted file mode 100644 index 5a610a82ee..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParserTests.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.config.xml; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.integration.gemfire.config.xml.ParserTestUtil.createFakeParserContext; -import static org.springframework.integration.gemfire.config.xml.ParserTestUtil.loadXMLFrom; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.w3c.dom.Element; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; -import org.springframework.integration.gemfire.inbound.CacheListeningMessageProducer; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Dan Oxlade - * @author Liujiong - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration -@DirtiesContext -public class GemfireInboundChannelAdapterParserTests { - - private GemfireInboundChannelAdapterParser underTest = new GemfireInboundChannelAdapterParser(); - - @Autowired - @Qualifier("channel1.adapter") - CacheListeningMessageProducer adapter1; - - @Test(expected = BeanDefinitionParsingException.class) - public void regionIsARequiredAttribute() throws Exception { - String xml = ""; - Element element = loadXMLFrom(xml).getDocumentElement(); - underTest.doParse(element, createFakeParserContext(), null); - } - - @Test - public void testPhase() { - assertThat(adapter1.getPhase()).isEqualTo(2); - } - - @Test - public void testAutoStart() { - assertThat(adapter1.isAutoStartup()).isEqualTo(false); - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireOutboundChannelAdapterParserTests-context.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireOutboundChannelAdapterParserTests-context.xml deleted file mode 100644 index 8d9bd6df9f..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireOutboundChannelAdapterParserTests-context.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireOutboundChannelAdapterParserTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireOutboundChannelAdapterParserTests.java deleted file mode 100644 index 5278cca383..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/GemfireOutboundChannelAdapterParserTests.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.config.xml; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.integration.gemfire.config.xml.ParserTestUtil.createFakeParserContext; -import static org.springframework.integration.gemfire.config.xml.ParserTestUtil.loadXMLFrom; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.w3c.dom.Element; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; -import org.springframework.context.ApplicationContext; -import org.springframework.integration.config.ConsumerEndpointFactoryBean; -import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.support.GenericMessage; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Dan Oxlade - * @author Liujiong - * @author Artem Bilan - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration -@DirtiesContext -public class GemfireOutboundChannelAdapterParserTests { - - private final GemfireOutboundChannelAdapterParser underTest = new GemfireOutboundChannelAdapterParser(); - - private static final CountDownLatch adviceCalled = new CountDownLatch(1); - - @Autowired - @Qualifier("adapter") - ConsumerEndpointFactoryBean adapter1; - - @Autowired - ApplicationContext ctx; - - @Test(expected = BeanDefinitionParsingException.class) - public void regionIsARequiredAttribute() throws Exception { - String xml = ""; - Element element = loadXMLFrom(xml).getDocumentElement(); - underTest.parseConsumer(element, createFakeParserContext()); - } - - @Test - public void withAdvice() throws InterruptedException { - adapter1.start(); - MessageChannel channel = ctx.getBean("input", MessageChannel.class); - channel.send(new GenericMessage("foo")); - assertThat(adviceCalled.await(10, TimeUnit.SECONDS)).isTrue(); - } - - @Test - public void testPhase() { - assertThat(adapter1.getPhase()).isEqualTo(2); - } - - @Test - public void testAutoStart() { - assertThat(adapter1.isAutoStartup()).isEqualTo(false); - } - - public static class FooAdvice extends AbstractRequestHandlerAdvice { - - @Override - protected Object doInvoke(ExecutionCallback callback, Object target, Message message) { - adviceCalled.countDown(); - return null; - } - - } -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/ParserTestUtil.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/ParserTestUtil.java deleted file mode 100644 index a0ba6dd826..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/config/xml/ParserTestUtil.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.config.xml; - -import org.springframework.beans.factory.parsing.FailFastProblemReporter; -import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.beans.factory.xml.XmlReaderContext; -import org.springframework.core.io.InputStreamResource; - -/** - * @author Dan Oxlade - * @author Gary Russell - */ -class ParserTestUtil { - - private ParserTestUtil() { - super(); - } - - static ParserContext createFakeParserContext() { - return new ParserContext( - new XmlReaderContext(thisClassAsResource(), new FailFastProblemReporter(), null, null, null, null), - null); - } - - static InputStreamResource thisClassAsResource() { - return new InputStreamResource( - ParserTestUtil.class.getResourceAsStream(ParserTestUtil.class.getSimpleName() + ".class")); - } - - static org.w3c.dom.Document loadXMLFrom(String xml) throws org.xml.sax.SAXException, java.io.IOException { - return loadXMLFrom(new java.io.ByteArrayInputStream(xml.getBytes())); - } - - static org.w3c.dom.Document loadXMLFrom(java.io.InputStream is) - throws org.xml.sax.SAXException, java.io.IOException { - javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - javax.xml.parsers.DocumentBuilder builder = null; - try { - builder = factory.newDocumentBuilder(); - } - catch (javax.xml.parsers.ParserConfigurationException ex) { - } - org.w3c.dom.Document doc = builder.parse(is); - is.close(); - return doc; - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/fork/CacheServerProcess.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/fork/CacheServerProcess.java deleted file mode 100644 index 134ff97d2c..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/fork/CacheServerProcess.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2013-2019 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 - * - * https://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.gemfire.fork; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.Date; -import java.util.Properties; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.RegionShortcut; -import org.apache.geode.cache.Scope; -import org.apache.geode.cache.server.CacheServer; - -/** - * @author Costin Leau - * @author David Turanski - * @author Gunnar Hillert - * @author Soby Chacko - * @author Gary Russell - * - * Runs as a standalone Java app. - * Modified from SGF implementation for testing client/server CQ features - */ -public class CacheServerProcess { - - private static final Log logger = LogFactory.getLog(CacheServerProcess.class); - - private CacheServerProcess() { - super(); - } - - public static void main(String[] args) throws Exception { - - Properties props = new Properties(); - props.setProperty("name", "CacheServer at " + new Date()); - props.setProperty("log-level", "info"); - - logger.info("Connecting to the distributed system and creating the cache."); - - Cache cache = new CacheFactory(props).create(); - - // Create region. - Region region = cache.createRegionFactory(RegionShortcut.REPLICATE) - .setScope(Scope.DISTRIBUTED_ACK) - .create("test"); - - logger.info("Test region, " + region.getFullPath() + ", created in cache."); - - // Start Cache Server. - CacheServer server = cache.addCacheServer(); - server.setPort(40404); - logger.info("Starting server"); - server.start(); - ForkUtil.createControlFile(CacheServerProcess.class.getName()); - logger.info("Waiting for shutdown"); - - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); - bufferedReader.readLine(); - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/fork/ForkUtil.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/fork/ForkUtil.java deleted file mode 100644 index cfd2cfa814..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/fork/ForkUtil.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2011-2019 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 - * - * https://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.gemfire.fork; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintStream; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Utility for forking Java processes. Modified from the SGF version for SI - * - * @author Costin Leau - * @author David Turanski - * @author Gary Russell - * - * - */ -public class ForkUtil { - - private static final Log logger = LogFactory.getLog(ForkUtil.class); - - private static String TEMP_DIR = System.getProperty("java.io.tmpdir"); - - private ForkUtil() { - super(); - } - - public static OutputStream cloneJVM(String argument) { - String cp = System.getProperty("java.class.path"); - String home = System.getProperty("java.home"); - - Process proc = null; - String java = home + "/bin/java".replace("\\", "/"); - - String argClass = argument; - - String[] cmdArray = {java, "-cp", cp, argClass}; - try { - // ProcessBuilder builder = new ProcessBuilder(cmd, argCp, - // argClass); - // builder.redirectErrorStream(true); - proc = Runtime.getRuntime().exec(cmdArray); - } - catch (IOException ioe) { - throw new IllegalStateException("Cannot start command " + cmdArray, ioe); - } - - logger.info("Started fork"); - final Process p = proc; - - final BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); - final BufferedReader ebr = new BufferedReader(new InputStreamReader(p.getErrorStream())); - final AtomicBoolean run = new AtomicBoolean(true); - - Thread reader = copyStdXxx(br, run, System.out); - Thread errReader = copyStdXxx(ebr, run, System.err); - - reader.start(); - errReader.start(); - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - logger.info("Stopping fork..."); - run.set(false); - if (p != null) { - p.destroy(); - } - - try { - p.waitFor(); - } - catch (InterruptedException e) { - // ignore - } - logger.info("Fork stopped"); - } - }); - - return proc.getOutputStream(); - } - - private static Thread copyStdXxx(final BufferedReader br, - final AtomicBoolean run, final PrintStream out) { - Thread reader = new Thread(() -> { - try { - String line = null; - do { - while ((line = br.readLine()) != null) { - out.println("[FORK] " + line); - } - } while (run.get()); - } - catch (Exception ex) { - // ignore and exit - } - }); - return reader; - } - - public static OutputStream cacheServer() { - return startCacheServer("org.springframework.integration.gemfire.fork.CacheServerProcess"); - } - - public static OutputStream cacheServer(String className) { - return startCacheServer(className); - } - - private static OutputStream startCacheServer(String className) { - - if (controlFileExists(className)) { - deleteControlFile(className); - } - OutputStream os = cloneJVM(className); - int maxTime = 60000; - int time = 0; - while (!controlFileExists(className) && time < maxTime) { - try { - Thread.sleep(500); - time += 500; - } - catch (InterruptedException ex) { - // ignore and move on - } - } - if (controlFileExists(className)) { - logger.info("Started cache server"); - } - else { - throw new RuntimeException("could not fork cache server"); - } - return os; - } - - public static boolean deleteControlFile(String name) { - String path = TEMP_DIR + File.separator + name; - return new File(path).delete(); - } - - public static boolean createControlFile(String name) throws IOException { - String path = TEMP_DIR + File.separator + name; - return new File(path).createNewFile(); - } - - public static boolean controlFileExists(String name) { - String path = TEMP_DIR + File.separator + name; - return new File(path).exists(); - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducerTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducerTests.java deleted file mode 100644 index 6fe29b6498..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducerTests.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.inbound; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -import org.apache.geode.cache.Region; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.data.gemfire.CacheFactoryBean; -import org.springframework.data.gemfire.GenericRegionFactoryBean; -import org.springframework.data.gemfire.RegionAttributesFactoryBean; -import org.springframework.expression.spel.standard.SpelExpressionParser; -import org.springframework.integration.channel.QueueChannel; -import org.springframework.messaging.Message; - -/** - * @author Mark Fisher - * @author Gary Russell - * @author Artem Bilan - * - * @since 2.1 - */ -public class CacheListeningMessageProducerTests { - - private static final SpelExpressionParser PARSER = new SpelExpressionParser(); - - private static CacheFactoryBean cacheFactoryBean; - - private static GenericRegionFactoryBean regionFactoryBean; - - private static Region region; - - @BeforeClass - public static void setup() throws Exception { - cacheFactoryBean = new CacheFactoryBean(); - - regionFactoryBean = new GenericRegionFactoryBean<>(); - regionFactoryBean.setName("test.receiveNewValuePayloadForCreateEvent"); - regionFactoryBean.setCache(cacheFactoryBean.getObject()); - setRegionAttributes(regionFactoryBean); - regionFactoryBean.afterPropertiesSet(); - - region = regionFactoryBean.getObject(); - } - - @AfterClass - public static void teardown() throws Exception { - regionFactoryBean.destroy(); - cacheFactoryBean.destroy(); - } - - @Test - public void receiveNewValuePayloadForCreateEvent() { - QueueChannel channel = new QueueChannel(); - CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region); - producer.setPayloadExpression(PARSER.parseExpression("key + '=' + newValue")); - producer.setOutputChannel(channel); - producer.setBeanFactory(mock(BeanFactory.class)); - producer.afterPropertiesSet(); - producer.start(); - - assertThat(channel.receive(0)).isNull(); - region.put("x", "abc"); - Message message = channel.receive(0); - assertThat(message).isNotNull(); - assertThat(message.getPayload()).isEqualTo("x=abc"); - - producer.stop(); - } - - @Test - public void receiveNewValuePayloadForUpdateEvent() { - QueueChannel channel = new QueueChannel(); - CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region); - producer.setPayloadExpression(PARSER.parseExpression("newValue")); - producer.setOutputChannel(channel); - producer.setBeanFactory(mock(BeanFactory.class)); - producer.afterPropertiesSet(); - producer.start(); - - assertThat(channel.receive(0)).isNull(); - region.put("x", "abc"); - Message message1 = channel.receive(0); - assertThat(message1).isNotNull(); - assertThat(message1.getPayload()).isEqualTo("abc"); - region.put("x", "xyz"); - Message message2 = channel.receive(0); - assertThat(message2).isNotNull(); - assertThat(message2.getPayload()).isEqualTo("xyz"); - - producer.stop(); - } - - @Test - public void receiveOldValuePayloadForDestroyEvent() { - QueueChannel channel = new QueueChannel(); - CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region); - producer.setSupportedEventTypes(EventType.DESTROYED); - producer.setPayloadExpression(PARSER.parseExpression("oldValue")); - producer.setOutputChannel(channel); - producer.setBeanFactory(mock(BeanFactory.class)); - producer.afterPropertiesSet(); - producer.start(); - - assertThat(channel.receive(0)).isNull(); - region.put("foo", "abc"); - assertThat(channel.receive(0)).isNull(); - region.destroy("foo"); - Message message2 = channel.receive(0); - assertThat(message2).isNotNull(); - assertThat(message2.getPayload()).isEqualTo("abc"); - - producer.stop(); - } - - @Test - public void receiveOldValuePayloadForInvalidateEvent() { - QueueChannel channel = new QueueChannel(); - CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region); - producer.setSupportedEventTypes(EventType.INVALIDATED); - producer.setPayloadExpression(PARSER.parseExpression("key + ' was ' + oldValue")); - producer.setOutputChannel(channel); - producer.setBeanFactory(mock(BeanFactory.class)); - producer.afterPropertiesSet(); - producer.start(); - - assertThat(channel.receive(0)).isNull(); - region.put("foo", "abc"); - assertThat(channel.receive(0)).isNull(); - region.invalidate("foo"); - Message message2 = channel.receive(0); - assertThat(message2).isNotNull(); - assertThat(message2.getPayload()).isEqualTo("foo was abc"); - - producer.stop(); - } - - private static void setRegionAttributes(GenericRegionFactoryBean regionFactoryBean) - throws Exception { - - RegionAttributesFactoryBean attributesFactoryBean = new RegionAttributesFactoryBean<>(); - attributesFactoryBean.afterPropertiesSet(); - regionFactoryBean.setAttributes(attributesFactoryBean.getObject()); - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/ContinuousQueryMessageProducerTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/ContinuousQueryMessageProducerTests.java deleted file mode 100644 index 887423c38e..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/ContinuousQueryMessageProducerTests.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.inbound; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -import org.apache.geode.cache.Operation; -import org.apache.geode.cache.query.CqEvent; -import org.apache.geode.cache.query.CqQuery; -import org.apache.geode.cache.query.cq.internal.ServerCQImpl; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer; -import org.springframework.expression.spel.standard.SpelExpressionParser; -import org.springframework.integration.channel.DirectChannel; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageHandler; -import org.springframework.messaging.MessagingException; - -/** - * @author David Turanski - * @author Artem Bilan - * - * @since 2.1 - */ -public class ContinuousQueryMessageProducerTests { - - private static final SpelExpressionParser PARSER = new SpelExpressionParser(); - - private ContinuousQueryMessageProducer cqMessageProducer; - - private CqMessageHandler handler; - - @BeforeEach - void setUp() { - ContinuousQueryListenerContainer queryListenerContainer = mock(ContinuousQueryListenerContainer.class); - this.cqMessageProducer = new ContinuousQueryMessageProducer(queryListenerContainer, "foo"); - DirectChannel outputChannel = new DirectChannel(); - this.cqMessageProducer.setOutputChannel(outputChannel); - this.cqMessageProducer.setBeanFactory(mock(BeanFactory.class)); - this.handler = new CqMessageHandler(); - outputChannel.subscribe(this.handler); - } - - @Test - void testMessageProduced() { - CqEvent cqEvent = event(Operation.CREATE, "hello"); - this.cqMessageProducer.onEvent(cqEvent); - assertThat(this.handler.count).isEqualTo(1); - assertThat(this.handler.payload).isEqualTo(cqEvent); - } - - @Test - void testMessageNotProducedForUnsupportedEventType() { - CqEvent cqEvent = event(Operation.DESTROY, "hello"); - this.cqMessageProducer.onEvent(cqEvent); - assertThat(this.handler.count).isEqualTo(0); - } - - @Test - void testMessageProducedForAddedEventType() { - CqEvent cqEvent = event(Operation.DESTROY, null); - this.cqMessageProducer.setSupportedEventTypes(CqEventType.DESTROYED); - this.cqMessageProducer.onEvent(cqEvent); - assertThat(this.handler.count).isEqualTo(1); - assertThat(this.handler.payload).isEqualTo(cqEvent); - } - - @Test - void testPayloadExpression() { - CqEvent cqEvent = event(Operation.CREATE, "hello"); - this.cqMessageProducer.setPayloadExpression(PARSER.parseExpression("newValue.toUpperCase() + ', WORLD'")); - this.cqMessageProducer.afterPropertiesSet(); - this.cqMessageProducer.onEvent(cqEvent); - assertThat(this.handler.count).isEqualTo(1); - assertThat(this.handler.payload).isEqualTo("HELLO, WORLD"); - } - - CqEvent event(final Operation operation, final Object value) { - return new CqEvent() { - - final CqQuery cq = new ServerCQImpl(); - - final byte[] ba = new byte[0]; - - final Object key = new Object(); - - final Exception ex = new Exception(); - - public Operation getBaseOperation() { - return operation; - } - - public CqQuery getCq() { - return this.cq; - } - - public byte[] getDeltaValue() { - return this.ba; - } - - public Object getKey() { - return this.key; - } - - public Object getNewValue() { - return value; - } - - public Operation getQueryOperation() { - return operation; - } - - public Throwable getThrowable() { - return this.ex; - } - - }; - } - - private static class CqMessageHandler implements MessageHandler { - - int count; - - Object payload; - - public void handleMessage(Message message) throws MessagingException { - this.count++; - this.payload = message.getPayload(); - } - - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests-context.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests-context.xml deleted file mode 100644 index 4496137f62..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests-context.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests.java deleted file mode 100644 index b34c831b11..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CqInboundChannelAdapterTests.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2002-2020 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 - * - * https://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.gemfire.inbound; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.geode.cache.Region; -import org.apache.geode.cache.query.CqEvent; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.integration.gemfire.fork.ForkUtil; -import org.springframework.integration.test.util.TestUtils; -import org.springframework.messaging.Message; -import org.springframework.messaging.PollableChannel; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; - -/** - * @author David Turanski - * @author Gary Russell - * @author Artem Bilan - * - */ -@SpringJUnitConfig -@DirtiesContext -public class CqInboundChannelAdapterTests { - - @Autowired - @Qualifier("test") - Region region; - - @Autowired - ConfigurableApplicationContext applicationContext; - - @Autowired - PollableChannel outputChannel1; - - @Autowired - PollableChannel outputChannel2; - - @Autowired - ContinuousQueryMessageProducer withDurable; - - static OutputStream os; - - @BeforeAll - public static void startUp() { - os = ForkUtil.cacheServer(); - } - - @Test - public void testCqEvent() { - assertThat(TestUtils.getPropertyValue(withDurable, "durable", Boolean.class)).isTrue(); - region.put("one", 1); - Message msg = outputChannel1.receive(10000); - assertThat(msg).isNotNull(); - assertThat(msg.getPayload() instanceof CqEvent).isTrue(); - } - - @Test - public void testPayloadExpression() { - region.put("one", 1); - Message msg = outputChannel2.receive(10000); - assertThat(msg).isNotNull(); - assertThat(msg.getPayload()).isEqualTo(1); - } - - @AfterAll - public static void cleanUp() { - sendSignal(); - } - - public static void sendSignal() { - try { - os.write("\n".getBytes()); - os.flush(); - } - catch (IOException ex) { - throw new IllegalStateException("Cannot communicate with forked VM", ex); - } - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests-context.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests-context.xml deleted file mode 100644 index e8cc98d87a..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests-context.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests.java deleted file mode 100644 index 299a237109..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2002-2020 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 - * - * https://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.gemfire.inbound; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.geode.cache.EntryEvent; -import org.apache.geode.cache.Region; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageHandler; -import org.springframework.messaging.MessagingException; -import org.springframework.messaging.SubscribableChannel; -import org.springframework.messaging.support.ErrorMessage; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; - -/** - * @author David Turanski - * @author Artem Bilan - * - * @since 2.1 - */ -@SpringJUnitConfig -@DirtiesContext -public class GemfireInboundChannelAdapterTests { - - @Autowired - SubscribableChannel channel1; - - @Autowired - SubscribableChannel channel2; - - @Autowired - SubscribableChannel channel3; - - @Autowired - SubscribableChannel errorChannel; - - @Autowired - @Qualifier("region1") - Region region1; - - @Autowired - @Qualifier("region2") - Region region2; - - @Autowired - @Qualifier("region3") - Region region3; - - @Test - public void testGemfireInboundChannelAdapterWithExpression() { - - EventHandler eventHandler1 = new EventHandler(); - channel1.subscribe(eventHandler1); - - region1.put("payload", "payload"); - - assertThat(eventHandler1.event).isEqualTo("payload"); - } - - @Test - public void testGemfireInboundChannelAdapterDefault() { - EventHandler eventHandler2 = new EventHandler(); - channel2.subscribe(eventHandler2); - - region2.put("payload", "payload"); - - assertThat(eventHandler2.event instanceof EntryEvent).isTrue(); - EntryEvent event = (EntryEvent) eventHandler2.event; - assertThat(event.getNewValue()).isEqualTo("payload"); - } - - @Test - public void testErrorChannel() { - channel3.subscribe(message -> { - throw new MessagingException("got an error"); - }); - ErrorHandler errorHandler = new ErrorHandler(); - errorChannel.subscribe(errorHandler); - - region3.put("payload", "payload"); - - assertThat(errorHandler.count).isEqualTo(1); - } - - static class ErrorHandler implements MessageHandler { - - public int count = 0; - - @Override - public void handleMessage(Message message) throws MessagingException { - assertThat(message).isInstanceOf(ErrorMessage.class); - count++; - } - - } - - static class EventHandler implements MessageHandler { - - public Object event = null; - - @Override - public void handleMessage(Message message) throws MessagingException { - event = message.getPayload(); - } - - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStoreCacheListenerTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStoreCacheListenerTests.java deleted file mode 100644 index de13fb5ee4..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStoreCacheListenerTests.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2017-2019 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 - * - * https://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.gemfire.metadata; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.Region; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.springframework.integration.metadata.MetadataStoreListenerAdapter; -import org.springframework.util.Assert; - -/** - * @author Venil Noronha - * - * @since 5.0 - * - */ -public class GemfireMetadataStoreCacheListenerTests { - - private static Cache cache; - - private static GemfireMetadataStore metadataStore; - - private static Region region; - - @BeforeClass - public static void startUp() throws Exception { - cache = new CacheFactory().create(); - metadataStore = new GemfireMetadataStore(cache); - region = cache.getRegion(GemfireMetadataStore.KEY); - } - - @AfterClass - public static void cleanUp() { - if (region != null) { - region.close(); - } - if (cache != null) { - cache.close(); - Assert.isTrue(cache.isClosed(), "Cache did not close after close() call"); - } - } - - @Before - @After - public void setup() { - if (region != null) { - region.clear(); - } - } - - @Test - public void testAdd() throws InterruptedException { - String testKey = "key"; - String testValue = "value"; - - CountDownLatch latch = new CountDownLatch(1); - AtomicReference actualKey = new AtomicReference<>(); - AtomicReference actualValue = new AtomicReference<>(); - metadataStore.addListener(new MetadataStoreListenerAdapter() { - - @Override - public void onAdd(String key, String value) { - actualKey.set(key); - actualValue.set(value); - latch.countDown(); - } - - }); - - metadataStore.put(testKey, testValue); - latch.await(10, TimeUnit.SECONDS); - - assertThat(actualKey.get()).isEqualTo(testKey); - assertThat(actualValue.get()).isEqualTo(testValue); - } - - @Test - public void testRemove() throws InterruptedException { - String testKey = "key"; - String testValue = "value"; - - CountDownLatch latch = new CountDownLatch(1); - AtomicReference actualKey = new AtomicReference<>(); - AtomicReference actualValue = new AtomicReference<>(); - metadataStore.addListener(new MetadataStoreListenerAdapter() { - - @Override - public void onRemove(String key, String oldValue) { - actualKey.set(key); - actualValue.set(oldValue); - latch.countDown(); - } - - }); - - metadataStore.put(testKey, testValue); - metadataStore.remove(testKey); - latch.await(10, TimeUnit.SECONDS); - - assertThat(actualKey.get()).isEqualTo(testKey); - assertThat(actualValue.get()).isEqualTo(testValue); - } - - @Test - public void testUpdate() throws InterruptedException { - String testKey = "key"; - String testValue = "value"; - String testNewValue = "new-value"; - - CountDownLatch latch = new CountDownLatch(1); - AtomicReference actualKey = new AtomicReference<>(); - AtomicReference actualValue = new AtomicReference<>(); - metadataStore.addListener(new MetadataStoreListenerAdapter() { - - @Override - public void onUpdate(String key, String newValue) { - actualKey.set(key); - actualValue.set(newValue); - latch.countDown(); - } - - }); - - metadataStore.put(testKey, testValue); - metadataStore.put(testKey, testNewValue); - latch.await(10, TimeUnit.SECONDS); - - assertThat(actualKey.get()).isEqualTo(testKey); - assertThat(actualValue.get()).isEqualTo(testNewValue); - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStoreTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStoreTests.java deleted file mode 100644 index 59a16d0b28..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/metadata/GemfireMetadataStoreTests.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 2014-2019 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 - * - * https://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.gemfire.metadata; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.Region; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.springframework.data.gemfire.GemfireTemplate; -import org.springframework.integration.metadata.ConcurrentMetadataStore; - -/** - * @author Artem Bilan - * @since 4.0 - * - */ -public class GemfireMetadataStoreTests { - - private static Cache cache; - - private static ConcurrentMetadataStore metadataStore; - - private static Region region; - - @BeforeClass - public static void startUp() throws Exception { - cache = new CacheFactory().create(); - metadataStore = new GemfireMetadataStore(cache); - region = cache.getRegion(GemfireMetadataStore.KEY); - } - - @AfterClass - public static void cleanUp() { - if (region != null) { - region.close(); - } - if (cache != null) { - cache.close(); - assertThat(cache.isClosed()).as("Cache did not close after close() call").isTrue(); - } - } - - @Before - @After - public void setup() { - if (region != null) { - region.clear(); - } - } - - @Test - public void testGetNonExistingKeyValue() { - String retrievedValue = metadataStore.get("does-not-exist"); - assertThat(retrievedValue).isNull(); - } - - @Test - public void testPersistKeyValue() { - metadataStore.put("GemfireMetadataStoreTests-Spring", "Integration"); - - GemfireTemplate gemfireTemplate = new GemfireTemplate(region); - - Object v = gemfireTemplate.get("GemfireMetadataStoreTests-Spring"); - assertThat(v).isEqualTo("Integration"); - } - - @Test - public void testGetValueFromMetadataStore() { - metadataStore.put("GemfireMetadataStoreTests-GetValue", "Hello Gemfire"); - - String retrievedValue = metadataStore.get("GemfireMetadataStoreTests-GetValue"); - assertThat(retrievedValue).isEqualTo("Hello Gemfire"); - } - - @Test - public void testPersistEmptyStringToMetadataStore() { - metadataStore.put("GemfireMetadataStoreTests-PersistEmpty", ""); - - String retrievedValue = metadataStore.get("GemfireMetadataStoreTests-PersistEmpty"); - assertThat(retrievedValue).isEqualTo(""); - } - - @Test - public void testPersistNullStringToMetadataStore() { - try { - metadataStore.put("GemfireMetadataStoreTests-PersistEmpty", null); - fail("Expected an IllegalArgumentException to be thrown."); - } - catch (IllegalArgumentException e) { - assertThat(e.getMessage()).isEqualTo("'value' must not be null."); - } - } - - @Test - public void testPersistWithEmptyKeyToMetadataStore() { - metadataStore.put("", "PersistWithEmptyKey"); - - String retrievedValue = metadataStore.get(""); - assertThat(retrievedValue).isEqualTo("PersistWithEmptyKey"); - } - - @Test - public void testPersistWithNullKeyToMetadataStore() { - try { - metadataStore.put(null, "something"); - fail("Expected an IllegalArgumentException to be thrown."); - - } - catch (IllegalArgumentException e) { - assertThat(e.getMessage()).isEqualTo("'key' must not be null."); - } - } - - @Test - public void testGetValueWithNullKeyFromMetadataStore() { - try { - metadataStore.get(null); - } - catch (IllegalArgumentException e) { - assertThat(e.getMessage()).isEqualTo("'key' must not be null."); - return; - } - - fail("Expected an IllegalArgumentException to be thrown."); - } - - @Test - public void testRemoveFromMetadataStore() { - String testKey = "GemfireMetadataStoreTests-Remove"; - String testValue = "Integration"; - - metadataStore.put(testKey, testValue); - - assertThat(metadataStore.remove(testKey)).isEqualTo(testValue); - assertThat(metadataStore.remove(testKey)).isNull(); - } - - @Test - public void testPersistKeyValueIfAbsent() { - metadataStore.putIfAbsent("GemfireMetadataStoreTests-Spring", "Integration"); - - GemfireTemplate gemfireTemplate = new GemfireTemplate(region); - - Object v = gemfireTemplate.get("GemfireMetadataStoreTests-Spring"); - assertThat(v).isEqualTo("Integration"); - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/CacheWritingMessageHandlerTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/CacheWritingMessageHandlerTests.java deleted file mode 100644 index af286e91bc..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/CacheWritingMessageHandlerTests.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.outbound; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.Scope; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.data.gemfire.CacheFactoryBean; -import org.springframework.expression.Expression; -import org.springframework.expression.common.LiteralExpression; -import org.springframework.integration.expression.ValueExpression; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.GenericMessage; - -/** - * @author Mark Fisher - * @author David Turanski - * @author Gunnar Hillert - * @author Gary Russell - * @author Artem Bilan - * @since 2.1 - */ -public class CacheWritingMessageHandlerTests { - - private static CacheFactoryBean cacheFactoryBean; - - private static Region region; - - @BeforeClass - public static void startUp() throws Exception { - cacheFactoryBean = new CacheFactoryBean(); - cacheFactoryBean.afterPropertiesSet(); - Cache cache = (Cache) cacheFactoryBean.getObject(); - region = cache.createRegionFactory().setScope(Scope.LOCAL).create("sig-tests"); - } - - @AfterClass - public static void cleanUp() throws Exception { - if (region != null) { - region.close(); - } - if (cacheFactoryBean != null) { - cacheFactoryBean.destroy(); - } - } - - @Before - public void prepare() { - if (region != null) { - region.clear(); - } - } - - - @Test - public void mapPayloadWritesToCache() throws Exception { - assertThat(region.size()).isEqualTo(0); - - CacheWritingMessageHandler handler = new CacheWritingMessageHandler(region); - handler.setBeanFactory(mock(BeanFactory.class)); - handler.afterPropertiesSet(); - - Map map = new HashMap(); - map.put("foo", "bar"); - Message message = MessageBuilder.withPayload(map).build(); - handler.handleMessage(message); - assertThat(region.size()).isEqualTo(1); - assertThat(region.get("foo")).isEqualTo("bar"); - } - - @Test - public void ExpressionsWriteToCache() throws Exception { - assertThat(region.size()).isEqualTo(0); - - CacheWritingMessageHandler handler = new CacheWritingMessageHandler(region); - - Map expressions = new HashMap(); - expressions.put("'foo'", "'bar'"); - expressions.put("payload.toUpperCase()", "headers['bar'].toUpperCase()"); - handler.setCacheEntries(expressions); - handler.setBeanFactory(mock(BeanFactory.class)); - handler.afterPropertiesSet(); - - Message message = MessageBuilder.withPayload("foo") - .copyHeaders(Collections.singletonMap("bar", "bar")) - .build(); - handler.handleMessage(message); - assertThat(region.size()).isEqualTo(2); - assertThat(region.get("FOO")).isEqualTo("BAR"); - assertThat(region.get("foo")).isEqualTo("bar"); - - handler.setCacheEntryExpressions(Collections.singletonMap(new LiteralExpression("baz"), - new ValueExpression(10L))); - - handler.handleMessage(new GenericMessage("test")); - assertThat(region.size()).isEqualTo(3); - assertThat(region.get("baz")).isEqualTo(10L); - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests-context.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests-context.xml deleted file mode 100644 index 4814fd1144..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests-context.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests.java deleted file mode 100644 index 82a2ba4ca4..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/outbound/GemfireOutboundChannelAdapterTests.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2002-2020 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 - * - * https://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.gemfire.outbound; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.geode.cache.Region; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; - -/** - * @author David Turanski - * @author Artem Bilan - * - * @since 2.1 - */ - -@SpringJUnitConfig -@DirtiesContext -public class GemfireOutboundChannelAdapterTests { - - @Autowired - MessageChannel cacheChannel1; - - @Autowired - @Qualifier("region1") - Region region1; - - @Autowired - MessageChannel cacheChannel2; - - @Autowired - @Qualifier("region2") - Region region2; - - @Autowired - MessageChannel cacheChainChannel; - - - @BeforeEach - public void setUp() { - region1.clear(); - region2.clear(); - } - - @Test - public void testWriteMapPayload() { - Map map = new HashMap<>(); - map.put("foo", "bar"); - - Message message = MessageBuilder.withPayload(map).build(); - cacheChannel1.send(message); - assertThat(region1.size()).isEqualTo(1); - assertThat(region1.get("foo")).isEqualTo("bar"); - } - - @Test - public void testWriteExpressions() { - Message message = MessageBuilder.withPayload("Hello").build(); - cacheChannel2.send(message); - assertThat(region2.size()).isEqualTo(2); - assertThat(region2.get("HELLO")).isEqualTo("hello"); - assertThat(region2.get("foo")).isEqualTo("bar"); - } - - @Test - public void testWriteWithinChain() { - Map map = new HashMap<>(); - map.put("foo", "bar"); - - Message message = MessageBuilder.withPayload(map).build(); - cacheChainChannel.send(message); - assertThat(region1.size()).isEqualTo(1); - assertThat(region1.get("foo")).isEqualTo("bar"); - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/DelayerHandlerRescheduleIntegrationTests-context.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/DelayerHandlerRescheduleIntegrationTests-context.xml deleted file mode 100644 index 8aa9f5baad..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/DelayerHandlerRescheduleIntegrationTests-context.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/DelayerHandlerRescheduleIntegrationTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/DelayerHandlerRescheduleIntegrationTests.java deleted file mode 100644 index 195fe87b70..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/DelayerHandlerRescheduleIntegrationTests.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2013-2019 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 - * - * https://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.gemfire.store; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -import java.util.concurrent.TimeUnit; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.Scope; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import org.springframework.context.support.AbstractApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.data.gemfire.CacheFactoryBean; -import org.springframework.integration.context.IntegrationContextUtils; -import org.springframework.integration.handler.DelayHandler; -import org.springframework.integration.store.MessageGroup; -import org.springframework.integration.store.MessageGroupStore; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.integration.test.support.LongRunningIntegrationTest; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.PollableChannel; -import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; - - -/** - * @author Artem Bilan - * @author Gary Russell - * - * @since 3.0 - */ -public class DelayerHandlerRescheduleIntegrationTests { - - public static final String DELAYER_ID = "delayerWithGemfireMS"; - - public static Region region; - - private static CacheFactoryBean cacheFactoryBean; - - @ClassRule - public static LongRunningIntegrationTest longTests = new LongRunningIntegrationTest(); - - @BeforeClass - public static void startUp() throws Exception { - cacheFactoryBean = new CacheFactoryBean(); - cacheFactoryBean.afterPropertiesSet(); - Cache cache = (Cache) cacheFactoryBean.getObject(); - region = cache.createRegionFactory().setScope(Scope.LOCAL).create("sig-tests"); - } - - @AfterClass - public static void cleanUp() throws Exception { - if (region != null) { - region.close(); - } - if (cacheFactoryBean != null) { - cacheFactoryBean.destroy(); - } - } - - @Test - public void testDelayerHandlerRescheduleWithGemfireMessageStore() throws Exception { - AbstractApplicationContext context = new ClassPathXmlApplicationContext( - "DelayerHandlerRescheduleIntegrationTests-context.xml", this.getClass()); - MessageChannel input = context.getBean("input", MessageChannel.class); - MessageGroupStore messageStore = context.getBean("messageStore", MessageGroupStore.class); - - String delayerMessageGroupId = DELAYER_ID + ".messageGroupId"; - - Message message1 = MessageBuilder.withPayload("test1").build(); - input.send(message1); - input.send(MessageBuilder.withPayload("test2").build()); - - // Emulate restart and check Cache state before next start - // Interrupt taskScheduler as quickly as possible - ThreadPoolTaskScheduler taskScheduler = - (ThreadPoolTaskScheduler) IntegrationContextUtils.getTaskScheduler(context); - taskScheduler.shutdown(); - taskScheduler.getScheduledExecutor().awaitTermination(10, TimeUnit.SECONDS); - context.close(); - - try { - context.getBean("input", MessageChannel.class); - fail("IllegalStateException expected"); - } - catch (Exception e) { - assertThat(e instanceof IllegalStateException).isTrue(); - assertThat(e.getMessage().contains("BeanFactory not initialized or already closed - call 'refresh'")) - .isTrue(); - } - - assertThat(messageStore.getMessageGroupCount()).isEqualTo(1); - assertThat(messageStore.iterator().next().getGroupId()).isEqualTo(delayerMessageGroupId); - assertThat(messageStore.messageGroupSize(delayerMessageGroupId)).isEqualTo(2); - assertThat(messageStore.getMessageCountForAllMessageGroups()).isEqualTo(2); - MessageGroup messageGroup = messageStore.getMessageGroup(delayerMessageGroupId); - Message messageInStore = messageGroup.getMessages().iterator().next(); - Object payload = messageInStore.getPayload(); - - // INT-3049 - assertThat(payload instanceof DelayHandler.DelayedMessageWrapper).isTrue(); - assertThat(((DelayHandler.DelayedMessageWrapper) payload).getOriginal()).isEqualTo(message1); - - context.refresh(); - - PollableChannel output = context.getBean("output", PollableChannel.class); - - Message message = output.receive(20000); - assertThat(message).isNotNull(); - - Object payload1 = message.getPayload(); - - message = output.receive(20000); - assertThat(message).isNotNull(); - Object payload2 = message.getPayload(); - assertThat(payload2).isNotSameAs(payload1); - - assertThat(messageStore.getMessageGroupCount()).isEqualTo(1); - int n = 0; - while (n++ < 200 && messageStore.messageGroupSize(delayerMessageGroupId) > 0) { - Thread.sleep(100); - } - assertThat(messageStore.messageGroupSize(delayerMessageGroupId)).isEqualTo(0); - - context.close(); - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireGroupStoreTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireGroupStoreTests.java deleted file mode 100644 index 9b9d1b292d..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireGroupStoreTests.java +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright 2007-2019 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 - * - * https://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.gemfire.store; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.Scope; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.data.gemfire.CacheFactoryBean; -import org.springframework.integration.channel.DirectChannel; -import org.springframework.integration.channel.QueueChannel; -import org.springframework.integration.history.MessageHistory; -import org.springframework.integration.store.MessageGroup; -import org.springframework.integration.store.SimpleMessageGroup; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.support.GenericMessage; - -import junit.framework.AssertionFailedError; - -/** - * @author Oleg Zhurakousky - * @author David Turanski - * @author Gary Russell - * @author Artem Bilan - * - */ -public class GemfireGroupStoreTests { - - private static CacheFactoryBean cacheFactoryBean; - - public static Region region; - - @Test - public void testNonExistingEmptyMessageGroup() throws Exception { - GemfireMessageStore store = new GemfireMessageStore(region); - MessageGroup messageGroup = store.getMessageGroup(1); - assertThat(messageGroup).isNotNull(); - assertThat(messageGroup instanceof SimpleMessageGroup).isTrue(); - assertThat(messageGroup.size()).isEqualTo(0); - } - - @Test - public void testMessageGroupWithAddedMessage() throws Exception { - GemfireMessageStore store = new GemfireMessageStore(region); - MessageGroup messageGroup = store.getMessageGroup(1); - Message message = new GenericMessage("Hello"); - messageGroup = store.addMessageToGroup(1, message); - assertThat(messageGroup.size()).isEqualTo(1); - - // make sure the store is properly rebuild from Gemfire - store = new GemfireMessageStore(region); - - messageGroup = store.getMessageGroup(1); - assertThat(messageGroup.size()).isEqualTo(1); - } - - @Test - public void testRemoveMessageFromTheGroup() throws Exception { - GemfireMessageStore store = new GemfireMessageStore(region); - MessageGroup messageGroup = store.getMessageGroup(1); - Message message = new GenericMessage("2"); - - messageGroup = store.addMessageToGroup(messageGroup.getGroupId(), new GenericMessage("1")); - messageGroup = store.getMessageGroup(1); - assertThat(messageGroup.size()).isEqualTo(1); - Thread.sleep(1); //since it adds to a local region some times CREATED_DATE ends up to be the same - // Unrealistic in a real scenario - - messageGroup = store.addMessageToGroup(messageGroup.getGroupId(), message); - messageGroup = store.getMessageGroup(1); - assertThat(messageGroup.size()).isEqualTo(2); - Thread.sleep(1); - - messageGroup = store.addMessageToGroup(messageGroup.getGroupId(), new GenericMessage("3")); - messageGroup = store.getMessageGroup(1); - assertThat(messageGroup.size()).isEqualTo(3); - - store.removeMessagesFromGroup(messageGroup.getGroupId(), message); - messageGroup = store.getMessageGroup(1); - assertThat(messageGroup.size()).isEqualTo(2); - - // make sure the store is properly rebuild from Gemfire - store = new GemfireMessageStore(region); - - messageGroup = store.getMessageGroup(1); - assertThat(messageGroup.size()).isEqualTo(2); - - } - - @Test - public void testRemoveMessageGroup() throws Exception { - GemfireMessageStore store = new GemfireMessageStore(region); - MessageGroup messageGroup = store.getMessageGroup(1); - Message message = new GenericMessage("Hello"); - messageGroup = store.addMessageToGroup(messageGroup.getGroupId(), message); - assertThat(messageGroup.size()).isEqualTo(1); - - store.removeMessageGroup(1); - MessageGroup messageGroupA = store.getMessageGroup(1); - assertThat(messageGroupA).isNotSameAs(messageGroup); - assertThat(messageGroupA.getMessages().size()).isEqualTo(0); - assertThat(messageGroupA.size()).isEqualTo(0); - - // make sure the store is properly rebuild from Gemfire - store = new GemfireMessageStore(region); - - messageGroup = store.getMessageGroup(1); - - assertThat(messageGroup.getMessages().size()).isEqualTo(0); - assertThat(messageGroup.size()).isEqualTo(0); - } - - @Test - public void testRemoveNonExistingMessageFromTheGroup() throws Exception { - GemfireMessageStore store = new GemfireMessageStore(region); - MessageGroup messageGroup = store.getMessageGroup(1); - store.addMessagesToGroup(messageGroup.getGroupId(), new GenericMessage("1")); - store.removeMessagesFromGroup(1, new GenericMessage("2")); - } - - @Test - public void testRemoveNonExistingMessageFromNonExistingTheGroup() throws Exception { - GemfireMessageStore store = new GemfireMessageStore(region); - store.removeMessagesFromGroup(1, new GenericMessage("2")); - } - - @Test - public void testCompleteMessageGroup() throws Exception { - GemfireMessageStore store = new GemfireMessageStore(region); - MessageGroup messageGroup = store.getMessageGroup(1); - Message messageToMark = new GenericMessage("1"); - store.addMessagesToGroup(messageGroup.getGroupId(), messageToMark); - store.completeGroup(messageGroup.getGroupId()); - messageGroup = store.getMessageGroup(1); - assertThat(messageGroup.isComplete()).isTrue(); - } - - @Test - public void testLastReleasedSequenceNumber() throws Exception { - GemfireMessageStore store = new GemfireMessageStore(region); - MessageGroup messageGroup = store.getMessageGroup(1); - Message messageToMark = new GenericMessage("1"); - store.addMessagesToGroup(messageGroup.getGroupId(), messageToMark); - store.setLastReleasedSequenceNumberForGroup(messageGroup.getGroupId(), 5); - messageGroup = store.getMessageGroup(1); - assertThat(messageGroup.getLastReleasedMessageSequenceNumber()).isEqualTo(5); - } - - @Test - public void testMultipleInstancesOfGroupStore() throws Exception { - GemfireMessageStore store1 = new GemfireMessageStore(region); - - GemfireMessageStore store2 = new GemfireMessageStore(region); - - Message message = new GenericMessage("1"); - store1.addMessagesToGroup(1, message); - MessageGroup messageGroup = store2.addMessageToGroup(1, new GenericMessage("2")); - - assertThat(messageGroup.getMessages().size()).isEqualTo(2); - - GemfireMessageStore store3 = new GemfireMessageStore(region); - - store3.removeMessagesFromGroup(1, message); - messageGroup = store3.getMessageGroup(1); - - assertThat(messageGroup.getMessages().size()).isEqualTo(1); - } - - @Test - public void testWithMessageHistory() throws Exception { - GemfireMessageStore store = new GemfireMessageStore(region); - - store.getMessageGroup(1); - - Message message = new GenericMessage("Hello"); - DirectChannel fooChannel = new DirectChannel(); - fooChannel.setBeanName("fooChannel"); - DirectChannel barChannel = new DirectChannel(); - barChannel.setBeanName("barChannel"); - - message = MessageHistory.write(message, fooChannel); - message = MessageHistory.write(message, barChannel); - store.addMessagesToGroup(1, message); - - message = store.getMessageGroup(1).getMessages().iterator().next(); - - MessageHistory messageHistory = MessageHistory.read(message); - assertThat(messageHistory).isNotNull(); - assertThat(messageHistory.size()).isEqualTo(2); - Properties fooChannelHistory = messageHistory.get(0); - assertThat(fooChannelHistory.get("name")).isEqualTo("fooChannel"); - assertThat(fooChannelHistory.get("type")).isEqualTo("channel"); - } - - @Test - public void testIteratorOfMessageGroups() throws Exception { - GemfireMessageStore store1 = new GemfireMessageStore(region); - GemfireMessageStore store2 = new GemfireMessageStore(region); - - store1.addMessagesToGroup(1, new GenericMessage("1")); - store2.addMessagesToGroup(2, new GenericMessage("2")); - store1.addMessagesToGroup(3, new GenericMessage("3"), new GenericMessage("3A")); - - Iterator messageGroups = store1.iterator(); - int counter = 0; - while (messageGroups.hasNext()) { - messageGroups.next(); - counter++; - } - assertThat(counter).isEqualTo(3); - - store2.removeMessageGroup(3); - - messageGroups = store1.iterator(); - counter = 0; - while (messageGroups.hasNext()) { - messageGroups.next(); - counter++; - } - assertThat(counter).isEqualTo(2); - } - - @Test - @Ignore - public void testConcurrentModifications() throws Exception { - - final GemfireMessageStore store1 = new GemfireMessageStore(region); - final GemfireMessageStore store2 = new GemfireMessageStore(region); - - final Message message = new GenericMessage("1"); - - ExecutorService executor = null; - - final List failures = new ArrayList(); - - for (int i = 0; i < 100; i++) { - executor = Executors.newCachedThreadPool(); - - executor.execute(() -> { - MessageGroup group = store1.addMessageToGroup(1, message); - if (group.getMessages().size() != 1) { - failures.add("ADD"); - throw new AssertionFailedError("Failed on ADD"); - } - }); - executor.execute(() -> { - store2.removeMessagesFromGroup(1, message); - MessageGroup group = store2.getMessageGroup(1); - if (group.getMessages().size() != 0) { - failures.add("REMOVE"); - throw new AssertionFailedError("Failed on Remove"); - } - }); - - executor.shutdown(); - executor.awaitTermination(10, TimeUnit.SECONDS); - store2.removeMessagesFromGroup(1, message); // ensures that if ADD thread executed after REMOVE, the store is empty for the next cycle - } - assertThat(failures.size() == 0).isTrue(); - } - - @Test - public void testWithAggregatorWithShutdown() { - - ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("gemfire-aggregator-config.xml", - this.getClass()); - MessageChannel input = context1.getBean("inputChannel", MessageChannel.class); - QueueChannel output = context1.getBean("outputChannel", QueueChannel.class); - - Message m1 = MessageBuilder.withPayload("1").setSequenceNumber(1).setSequenceSize(3).setCorrelationId(1) - .build(); - Message m2 = MessageBuilder.withPayload("2").setSequenceNumber(2).setSequenceSize(3).setCorrelationId(1) - .build(); - input.send(m1); - assertThat(output.receive(1000)).isNull(); - input.send(m2); - assertThat(output.receive(1000)).isNull(); - - ClassPathXmlApplicationContext context2 = new ClassPathXmlApplicationContext("gemfire-aggregator-config-a.xml", - this.getClass()); - MessageChannel inputA = context2.getBean("inputChannel", MessageChannel.class); - QueueChannel outputA = context2.getBean("outputChannel", QueueChannel.class); - - Message m3 = MessageBuilder.withPayload("3").setSequenceNumber(3).setSequenceSize(3).setCorrelationId(1) - .build(); - inputA.send(m3); - assertThat(outputA.receive(1000)).isNotNull(); - context1.close(); - context2.close(); - } - - @Test - public void testQueue() throws Exception { - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("gemfire-queue-config.xml", - this.getClass()); - - QueueChannel gemfireQueue = context.getBean("gemfireQueue", QueueChannel.class); - QueueChannel outputQueue = context.getBean("outputQueue", QueueChannel.class); - - for (int i = 0; i < 20; i++) { - gemfireQueue.send(new GenericMessage("Hello")); - Thread.sleep(1); - } - for (int i = 0; i < 20; i++) { - assertThat(outputQueue.receive(5000)).isNotNull(); - } - assertThat(outputQueue.receive(1)).isNull(); - context.close(); - } - - @Before - public void prepare() { - if (region != null) { - region.clear(); - } - } - - @BeforeClass - public static void init() throws Exception { - cacheFactoryBean = new CacheFactoryBean(); - cacheFactoryBean.afterPropertiesSet(); - Cache cache = (Cache) cacheFactoryBean.getObject(); - region = cache.createRegionFactory().setScope(Scope.LOCAL).create("sig-tests"); - } - - @AfterClass - public static void cleanup() throws Exception { - if (region != null) { - region.close(); - } - if (cacheFactoryBean != null) { - cacheFactoryBean.destroy(); - } - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireMessageStoreTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireMessageStoreTests.java deleted file mode 100644 index a89e7e0600..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/GemfireMessageStoreTests.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2002-2019 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 - * - * https://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.gemfire.store; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.Scope; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.springframework.data.gemfire.CacheFactoryBean; -import org.springframework.data.gemfire.GenericRegionFactoryBean; -import org.springframework.integration.channel.DirectChannel; -import org.springframework.integration.history.MessageHistory; -import org.springframework.integration.store.MessageGroup; -import org.springframework.integration.store.MessageGroupMetadata; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.integration.test.util.TestUtils; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.GenericMessage; - -/** - * @author Mark Fisher - * @author David Turanski - * @author Gary Russell - * @author Artem Bilan - * - * @since 2.1 - */ -public class GemfireMessageStoreTests { - - private static CacheFactoryBean cacheFactoryBean; - - private static Region region; - - @Test - public void addAndGetMessage() { - GemfireMessageStore store = new GemfireMessageStore(region); - Message message = MessageBuilder.withPayload("test").build(); - store.addMessage(message); - Message retrieved = store.getMessage(message.getHeaders().getId()); - assertThat(retrieved).isEqualTo(message); - } - - @Test - public void testRegionConstructor() throws Exception { - GenericRegionFactoryBean region = new GenericRegionFactoryBean<>(); - region.setName("someRegion"); - region.setCache(cacheFactoryBean.getObject()); - region.afterPropertiesSet(); - - GemfireMessageStore store = new GemfireMessageStore(region.getObject()); - assertThat(TestUtils.getPropertyValue(store, "messageStoreRegion")).isSameAs(region.getObject()); - - region.destroy(); - } - - @Test - public void testWithMessageHistory() { - GemfireMessageStore store = new GemfireMessageStore(region); - - Message message = new GenericMessage<>("Hello"); - DirectChannel fooChannel = new DirectChannel(); - fooChannel.setBeanName("fooChannel"); - DirectChannel barChannel = new DirectChannel(); - barChannel.setBeanName("barChannel"); - - message = MessageHistory.write(message, fooChannel); - message = MessageHistory.write(message, barChannel); - store.addMessage(message); - message = store.getMessage(message.getHeaders().getId()); - MessageHistory messageHistory = MessageHistory.read(message); - assertThat(messageHistory).isNotNull(); - assertThat(messageHistory.size()).isEqualTo(2); - Properties fooChannelHistory = messageHistory.get(0); - assertThat(fooChannelHistory.get("name")).isEqualTo("fooChannel"); - assertThat(fooChannelHistory.get("type")).isEqualTo("channel"); - } - - @Test - public void testAddAndRemoveMessagesFromMessageGroup() { - GemfireMessageStore messageStore = new GemfireMessageStore(region); - - String groupId = "X"; - List> messages = new ArrayList<>(); - for (int i = 0; i < 25; i++) { - Message message = MessageBuilder.withPayload("foo").setCorrelationId(groupId).build(); - messageStore.addMessagesToGroup(groupId, message); - messages.add(message); - } - MessageGroup group = messageStore.getMessageGroup(groupId); - assertThat(group.size()).isEqualTo(25); - messageStore.removeMessagesFromGroup(groupId, messages); - group = messageStore.getMessageGroup(groupId); - assertThat(group.size()).isEqualTo(0); - } - - @Test - public void testAddAndRemoveMessagesFromMessageGroupWithPrefix() { - GemfireMessageStore messageStore = new GemfireMessageStore(region, "foo_"); - - String groupId = "X"; - List> messages = new ArrayList<>(); - for (int i = 0; i < 25; i++) { - Message message = MessageBuilder.withPayload("foo").setCorrelationId(groupId).build(); - messageStore.addMessagesToGroup(groupId, message); - messages.add(message); - } - - MessageGroupMetadata messageGroupMetadata = - (MessageGroupMetadata) region.get("foo_" + "MESSAGE_GROUP_" + groupId); - - assertThat(messageGroupMetadata).isNotNull(); - assertThat(messageGroupMetadata.size()).isEqualTo(25); - - messageStore.removeMessagesFromGroup(groupId, messages); - MessageGroup group = messageStore.getMessageGroup(groupId); - assertThat(group.size()).isEqualTo(0); - } - - @Before - public void prepare() { - if (region != null) { - region.clear(); - } - } - - @BeforeClass - public static void init() throws Exception { - cacheFactoryBean = new CacheFactoryBean(); - Cache cache = (Cache) cacheFactoryBean.getObject(); - region = cache.createRegionFactory().setScope(Scope.LOCAL).create("sig-tests"); - } - - @AfterClass - public static void cleanup() throws Exception { - if (region != null) { - region.close(); - } - if (cacheFactoryBean != null) { - cacheFactoryBean.destroy(); - } - } - -} diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/gemfire-aggregator-config-a.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/gemfire-aggregator-config-a.xml deleted file mode 100644 index 68a3f05bed..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/gemfire-aggregator-config-a.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/gemfire-aggregator-config.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/gemfire-aggregator-config.xml deleted file mode 100644 index 68a3f05bed..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/gemfire-aggregator-config.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/gemfire-queue-config.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/gemfire-queue-config.xml deleted file mode 100644 index f4a45c2ab5..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/store/gemfire-queue-config.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/util/AggregatorWithGemfireLocksTests-context.xml b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/util/AggregatorWithGemfireLocksTests-context.xml deleted file mode 100644 index 67095fd458..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/util/AggregatorWithGemfireLocksTests-context.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/util/AggregatorWithGemfireLocksTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/util/AggregatorWithGemfireLocksTests.java deleted file mode 100644 index 80c8c9e0d9..0000000000 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/util/AggregatorWithGemfireLocksTests.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2014-2019 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 - * - * https://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.gemfire.util; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.integration.IntegrationMessageHeaderAccessor; -import org.springframework.integration.aggregator.ReleaseStrategy; -import org.springframework.integration.store.MessageGroup; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.PollableChannel; -import org.springframework.messaging.support.GenericMessage; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -/** - * @author Gary Russell - * @author Artem Bilan - * @since 4.0 - * - */ -@ContextConfiguration -@RunWith(SpringJUnit4ClassRunner.class) -@DirtiesContext -public class AggregatorWithGemfireLocksTests { - - @Autowired - private LatchingReleaseStrategy releaseStrategy; - - @Autowired - private MessageChannel in; - - @Autowired - private MessageChannel in2; - - @Autowired - private PollableChannel out; - - private volatile Exception exception; - - @Test - public void testLockSingleGroup() throws Exception { - this.releaseStrategy.reset(1); - Executors.newSingleThreadExecutor().execute(asyncSend("foo", 1, 1)); - Executors.newSingleThreadExecutor().execute(asyncSend("bar", 2, 1)); - assertThat(this.releaseStrategy.latch2.await(10, TimeUnit.SECONDS)).isTrue(); - this.releaseStrategy.latch1.countDown(); - assertThat(this.out.receive(10000)).isNotNull(); - assertThat(this.releaseStrategy.maxCallers.get()).isEqualTo(1); - assertThat(this.exception) - .as("Unexpected exception:" + (this.exception != null ? this.exception.toString() : "")).isNull(); - } - - @Test - public void testLockThreeGroups() throws Exception { - this.releaseStrategy.reset(3); - Executors.newSingleThreadExecutor().execute(asyncSend("foo", 1, 1)); - Executors.newSingleThreadExecutor().execute(asyncSend("bar", 2, 1)); - Executors.newSingleThreadExecutor().execute(asyncSend("foo", 1, 2)); - Executors.newSingleThreadExecutor().execute(asyncSend("bar", 2, 2)); - Executors.newSingleThreadExecutor().execute(asyncSend("foo", 1, 3)); - Executors.newSingleThreadExecutor().execute(asyncSend("bar", 2, 3)); - assertThat(this.releaseStrategy.latch2.await(10, TimeUnit.SECONDS)).isTrue(); - this.releaseStrategy.latch1.countDown(); - this.releaseStrategy.latch1.countDown(); - this.releaseStrategy.latch1.countDown(); - assertThat(this.out.receive(10000)).isNotNull(); - assertThat(this.out.receive(10000)).isNotNull(); - assertThat(this.out.receive(10000)).isNotNull(); - assertThat(this.releaseStrategy.maxCallers.get()).isEqualTo(3); - assertThat(this.exception) - .as("Unexpected exception:" + (this.exception != null ? this.exception.toString() : "")).isNull(); - } - - @Test - public void testDistributedAggregator() throws Exception { - this.releaseStrategy.reset(1); - Executors.newSingleThreadExecutor().execute(asyncSend("foo", 1, 1)); - Executors.newSingleThreadExecutor().execute(() -> { - try { - in2.send(new GenericMessage("bar", stubHeaders(2, 2, 1))); - } - catch (Exception e) { - exception = e; - } - }); - assertThat(this.releaseStrategy.latch2.await(10, TimeUnit.SECONDS)).isTrue(); - this.releaseStrategy.latch1.countDown(); - assertThat(this.out.receive(10000)).isNotNull(); - assertThat(this.releaseStrategy.maxCallers.get()).isEqualTo(1); - assertThat(this.exception) - .as("Unexpected exception:" + (this.exception != null ? this.exception.toString() : "")).isNull(); - } - - private Runnable asyncSend(final String payload, final int sequence, final int correlation) { - return () -> { - try { - in.send(new GenericMessage(payload, stubHeaders(sequence, 2, correlation))); - } - catch (Exception e) { - exception = e; - } - }; - } - - private Map stubHeaders(int sequenceNumber, int sequenceSize, int correlationId) { - Map headers = new HashMap(); - headers.put(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, sequenceNumber); - headers.put(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE, sequenceSize); - headers.put(IntegrationMessageHeaderAccessor.CORRELATION_ID, correlationId); - return headers; - } - - public static class LatchingReleaseStrategy implements ReleaseStrategy { - - private volatile CountDownLatch latch1; - - private volatile CountDownLatch latch2; - - private volatile AtomicInteger callers; - - private volatile AtomicInteger maxCallers; - - @Override - public boolean canRelease(MessageGroup group) { - synchronized (this) { - this.callers.incrementAndGet(); - this.maxCallers.set(Math.max(this.maxCallers.get(), this.callers.get())); - } - this.latch2.countDown(); - try { - this.latch1.await(10, TimeUnit.SECONDS); - } - catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - this.callers.decrementAndGet(); - return group.size() > 1; - } - - public void reset(int expectedConcurrency) { - this.latch1 = new CountDownLatch(expectedConcurrency); - this.latch2 = new CountDownLatch(expectedConcurrency); - this.callers = new AtomicInteger(); - this.maxCallers = new AtomicInteger(); - } - - } - -} diff --git a/spring-integration-gemfire/src/test/resources/log4j2-test.xml b/spring-integration-gemfire/src/test/resources/log4j2-test.xml deleted file mode 100644 index d56e00716b..0000000000 --- a/spring-integration-gemfire/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/src/reference/asciidoc/aggregator.adoc b/src/reference/asciidoc/aggregator.adoc index 3b46abc2c1..eb26b982c1 100644 --- a/src/reference/asciidoc/aggregator.adoc +++ b/src/reference/asciidoc/aggregator.adoc @@ -477,7 +477,7 @@ Note that the actual time to expire an empty group is also affected by the reape It used to obtain a `Lock` based on the `groupId` for concurrent operations on the `MessageGroup`. By default, an internal `DefaultLockRegistry` is used. Use of a distributed `LockRegistry`, such as the `ZookeeperLockRegistry`, ensures only one instance of the aggregator can operate on a group concurrently. -See <<./redis.adoc#redis-lock-registry,Redis Lock Registry>>, <<./gemfire.adoc#gemfire-lock-registry,Gemfire Lock Registry>>, and <<./zookeeper.adoc#zk-lock-registry,Zookeeper Lock Registry>> for more information. +See <<./redis.adoc#redis-lock-registry,Redis Lock Registry>> or <<./zookeeper.adoc#zk-lock-registry,Zookeeper Lock Registry>> for more information. <21> A timeout (in milliseconds) to force the `MessageGroup` complete when the `ReleaseStrategy` does not release the group when the current message arrives. This attribute provides a built-in time-based release strategy for the aggregator when there is a need to emit a partial result (or discard the group) if a new message does not arrive for the `MessageGroup` within the timeout which counts from the time the last message arrived. To set up a timeout which counts from the time the `MessageGroup` was created see `group-timeout-expression` information. diff --git a/src/reference/asciidoc/changes-2.0-2.1.adoc b/src/reference/asciidoc/changes-2.0-2.1.adoc index e6f998f48d..309e657370 100644 --- a/src/reference/asciidoc/changes-2.0-2.1.adoc +++ b/src/reference/asciidoc/changes-2.0-2.1.adoc @@ -22,14 +22,6 @@ Now you have the ability to use any scripting language that supports JSR-223 inc For further details, see <<./scripting.adoc#scripting,Scripting Support>>. -[[x2.1-new-gemfire-support]] -===== GemFire Support - -Spring Integration provides support for https://www.vmware.com/products/pivotal-gemfire.html[GemFire] by providing inbound adapters for entry and continuous query events, an outbound adapter to write entries to the cache, and https://docs.spring.io/spring-integration/api/org/springframework/integration/store/MessageStore.html[`MessageStore`] and https://docs.spring.io/spring-integration/api/org/springframework/integration/store/MessageGroupStore.html[`MessageGroupStore`] implementations. -Spring integration leverages the https://spring.io/projects/spring-data-gemfire[Spring Gemfire] project, providing a thin wrapper over its components. - -For further details, see <<./gemfire.adoc#gemfire,Pivotal GemFire and Apache Geode Support>>. - [[x2.1-new-amqp-support]] ===== AMQP Support diff --git a/src/reference/asciidoc/changes-3.0-4.0.adoc b/src/reference/asciidoc/changes-3.0-4.0.adoc index 81c1abd20f..e9475a0e93 100644 --- a/src/reference/asciidoc/changes-3.0-4.0.adoc +++ b/src/reference/asciidoc/changes-3.0-4.0.adoc @@ -101,12 +101,12 @@ For more information, see <<./security.adoc#security,Security in Spring Integrat The Redis support now provides the `` component to perform generic Redis commands by using the `RedisConnection#execute` method. For more information, see <<./redis.adoc#redis-outbound-gateway,Redis Outbound Command Gateway>>. -[[x4.0-redis-gemfire-lock-registry]] -===== `RedisLockRegistry` and `GemfireLockRegistry` +[[x4.0-redis-lock-registry]] +===== `RedisLockRegistry` -The `RedisLockRegistry` and `GemfireLockRegistry` are now available to support global locks visible to multiple application instances and servers. +The `RedisLockRegistry` is now available to support global locks visible to multiple application instances and servers. These can be used with aggregating message handlers across multiple application instances such that group release occurs on only one instance. -For more information, see <<./redis.adoc#redis-lock-registry,Redis Lock Registry>>, <<./gemfire.adoc#gemfire-lock-registry,Gemfire Lock Registry>>, and <<./aggregator.adoc#aggregator,Aggregator>>. +For more information, see <<./redis.adoc#redis-lock-registry,Redis Lock Registry>> and <<./aggregator.adoc#aggregator,Aggregator>>. [[x4.0-poller-annotation]] ===== `@Poller` @@ -130,12 +130,6 @@ We added a new twitter endpoint: ``. Unlike the search inbound adapter, which polls by using the same search query each time, the outbound gateway allows on-demand customized queries. For more information, see https://github.com/spring-projects/spring-integration-extensions/tree/main/spring-integration-social-twitter[Spring Integration Social Twitter]. -[[x4.0-gemfire-metadata]] -===== Gemfire Metadata Store - -We added the `GemfireMetadataStore`, letting it be used, for example, in an `AbstractPersistentAcceptOnceFileListFilter` implementation in a multiple application instance or server environment. -For more information, see <<./meta-data-store.adoc#metadata-store,Metadata Store>>, <<./file.adoc#file-reading,Reading Files>>, <<./ftp.adoc#ftp-inbound,FTP Inbound Channel Adapter>>, and <<./sftp.adoc#sftp-inbound,SFTP Inbound Channel Adapter>>. - [[x4.0-bridge-annotations]] ===== `@BridgeFrom` and `@BridgeTo` Annotations diff --git a/src/reference/asciidoc/changes-4.3-5.0.adoc b/src/reference/asciidoc/changes-4.3-5.0.adoc index 0b1fa4a31e..305b20d614 100644 --- a/src/reference/asciidoc/changes-4.3-5.0.adoc +++ b/src/reference/asciidoc/changes-4.3-5.0.adoc @@ -271,11 +271,6 @@ We added a `ByteArrayElasticRawDeserializer` without `maxMessageSize` to control See <<./ip.adoc#ip,TCP and UDP Support>> for more information. -===== Gemfire Changes - -The `GemfireMetadataStore` now implements `ListenableMetadataStore`, letting you listen to cache events by providing `MetadataStoreListener` instances to the store. -See <<./gemfire.adoc#gemfire,Pivotal GemFire and Apache Geode Support>> for more information. - ===== JDBC Changes The `JdbcMessageChannelStore` now provides a setter for `ChannelMessageStorePreparedStatementSetter`, letting you customize message insertion in the store. diff --git a/src/reference/asciidoc/endpoint-summary.adoc b/src/reference/asciidoc/endpoint-summary.adoc index f015c8a07c..adea5554dd 100644 --- a/src/reference/asciidoc/endpoint-summary.adoc +++ b/src/reference/asciidoc/endpoint-summary.adoc @@ -78,12 +78,6 @@ The following table summarizes the various endpoints with quick links to the app | N | <<./ftp.adoc#ftp-outbound-gateway,FTP Outbound Gateway>> -| *Gemfire* -| <<./gemfire.adoc#gemfire-inbound,Inbound Channel Adapter>> and <<./gemfire.adoc#gemfire-cq,Continuous Query Inbound Channel Adapter>> -| <<./gemfire.adoc#gemfire-outbound,Outbound Channel Adapter>> -| N -| N - | *GraphQL* | N | N diff --git a/src/reference/asciidoc/ftp.adoc b/src/reference/asciidoc/ftp.adoc index 38d28f5d9e..1d925e5864 100644 --- a/src/reference/asciidoc/ftp.adoc +++ b/src/reference/asciidoc/ftp.adoc @@ -353,7 +353,7 @@ The default `MetadataStore` is a `SimpleMetadataStore`, which stores state in me Since version 4.1.5, these filters have a new property (`flushOnUpdate`) that causes them to flush the metadata store on every update (if the store implements `Flushable`). -IMPORTANT: Further, if you use a distributed `MetadataStore` (such as <<./redis.adoc#redis-metadata-store,Redis>> or <<./gemfire.adoc#gemfire-metadata-store,GemFire>>), you can have multiple instances of the same adapter or application and be sure that each file is processed only once. +IMPORTANT: Further, if you use a distributed `MetadataStore` (such as <<./redis.adoc#redis-metadata-store,Redis>>), you can have multiple instances of the same adapter or application and be sure that each file is processed only once. The actual local filter is a `CompositeFileListFilter` that contains the supplied filter and a pattern filter that prevents processing files that are in the process of being downloaded (based on the `temporary-file-suffix`). Files are downloaded with this suffix (the default is `.writing`), and the file is renamed to its final name when the transfer is complete, making it 'visible' to the filter. diff --git a/src/reference/asciidoc/gemfire.adoc b/src/reference/asciidoc/gemfire.adoc deleted file mode 100644 index 9847188cdc..0000000000 --- a/src/reference/asciidoc/gemfire.adoc +++ /dev/null @@ -1,295 +0,0 @@ -[[gemfire]] -== VMware Tanzu GemFire and Apache Geode Support - -Spring Integration provides support for VMware Tanzu GemFire and Apache Geode. - -You need to include this dependency into your project: - -==== -[source, xml, subs="normal", role="primary"] -.Maven ----- - - org.springframework.integration - spring-integration-gemfire - {project-version} - ----- -[source, groovy, subs="normal", role="secondary"] -.Gradle ----- -compile "org.springframework.integration:spring-integration-gemfire:{project-version}" ----- -==== - -GemFire is a distributed data management platform that provides a key-value data grid along with advanced distributed system features, such as event processing, continuous querying, and remote function execution. -This guide assumes some familiarity with the commercial https://tanzu.vmware.com/gemfire[VMware Tanzu GemFire] or Open Source https://geode.apache.org[Apache Geode]. - -Spring integration provides support for GemFire by implementing inbound adapters for entry and continuous query events, an outbound adapter to write entries to the cache, and message and metadata stores and `GemfireLockRegistry` implementations. -Spring integration leverages the https://projects.spring.io/spring-data-gemfire[Spring Data for VMware Tanzu GemFire] project, providing a thin wrapper over its components. - -Starting with version 5.1, the Spring Integration GemFire module uses the https://github.com/spring-projects/spring-data-geode[Spring Data for Apache Geode] transitive dependency by default. -To switch to the commercial VMware Tanzu GemFire-based Spring Data for VMware Tanzu GemFire, exclude `spring-data-geode` from dependencies and add `spring-data-gemfire`, as the following Maven snippet shows: - -==== -[source,xml] ----- - - org.springframework.integration - spring-integration-gemfire - - - org.springframework.data - spring-data-geode - - - - - - org.springframework.data - spring-data-gemfire - ----- -==== - -To configure the 'int-gfe' namespace, include the following elements within the headers of your XML configuration file: - -==== -[source,xml] ----- -xmlns:int-gfe="http://www.springframework.org/schema/integration/gemfire" -xsi:schemaLocation="http://www.springframework.org/schema/integration/gemfire - https://www.springframework.org/schema/integration/gemfire/spring-integration-gemfire.xsd" ----- -==== - -[[gemfire-inbound]] -=== Inbound Channel Adapter - -The inbound channel adapter produces messages on a channel when triggered by a GemFire `EntryEvent`. -GemFire generates events whenever an entry is `CREATED`, `UPDATED`, `DESTROYED`, or `INVALIDATED` in the associated region. -The inbound channel adapter lets you filter on a subset of these events. -For example, you may want to produce messages only in response to an entry being created. -In addition, the inbound channel adapter can evaluate a SpEL expression if, for example, you want your message payload to contain an event property such as the new entry value. -The following example shows how to configure an inbound channel adapter with a SpEL language (in the `expression` attribute): - -==== -[source,xml] ----- - - - ----- -==== - -The preceding configuration creates a GemFire `Cache` and `Region` by using Spring GemFire's 'gfe' namespace. -The `inbound-channel-adapter` element requires a reference to the GemFire region on which the adapter listens for events. -Optional attributes include `cache-events`, which can contain a comma-separated list of event types for which a message is produced on the input channel. -By default, `CREATED` and `UPDATED` are enabled. -If no `channel` attribute is provided, the channel is created from the `id` attribute. -This adapter also supports an `error-channel`. -The GemFire https://geode.apache.org/releases/latest/javadoc/org/apache/geode/cache/EntryEvent.html[`EntryEvent`] is the `#root` object of the `expression` evaluation. -The following example shows an expression that replaces a value for a key: - -==== -[source] ----- -expression="new something.MyEvent(key, oldValue, newValue)" ----- -==== - -If the `expression` attribute is not provided, the message payload is the GemFire `EntryEvent` itself. - -NOTE: This adapter conforms to Spring Integration conventions. - -[[gemfire-cq]] -=== Continuous Query Inbound Channel Adapter - -The continuous query inbound channel adapter produces messages on a channel when triggered by a GemFire continuous query or `CqEvent` event. -In release `1.1`, Spring Data introduced continuous query support, including `ContinuousQueryListenerContainer`, which provides a nice abstraction over the GemFire native API. -This adapter requires a reference to a `ContinuousQueryListenerContainer` instance, creates a listener for a given `query`, and executes the query. -The continuous query acts as an event source that fires whenever its result set changes state. - -NOTE: GemFire queries are written in OQL and are scoped to the entire cache (not just one region). -Additionally, continuous queries require a remote (that is, running in a separate process or remote host) cache server. -See the https://gemfire82.docs.VMware Tanzu.io/docs-gemfire/gemfire_nativeclient/continuous-querying/continuous-querying.html[GemFire documentation] for more information on implementing continuous queries. - -The following configuration creates a GemFire client cache (recall that a remote cache server is required for this implementation and its address is configured as a child element of the pool), a client region, and a `ContinuousQueryListenerContainer` that uses Spring Data: - -==== -[source,xml] ----- - - - - - - - - - - - ----- -==== - -The continuous query inbound channel adapter requires a `cq-listener-container` attribute, which must contain a reference to the `ContinuousQueryListenerContainer`. -Optionally, it accepts an `expression` attribute that uses SpEL to transform the `CqEvent` or extract an individual property as needed. -The `cq-inbound-channel-adapter` provides a `query-events` attribute that contains a comma-separated list of event types for which a message is produced on the input channel. -The available event types are `CREATED`, `UPDATED`, `DESTROYED`, `REGION_DESTROYED`, and `REGION_INVALIDATED`. -By default, `CREATED` and `UPDATED` are enabled. -Additional optional attributes include `query-name` (which provides an optional query name), `expression` (which works as described in the preceding section), and `durable` (a boolean value indicating if the query is durable -- it is false by default). -If you do not provide a `channel`, the channel is created from the `id` attribute. -This adapter also supports an `error-channel`. - -NOTE: This adapter conforms to Spring Integration conventions. - -[[gemfire-outbound]] -=== Outbound Channel Adapter - -The outbound channel adapter writes cache entries that are mapped from the message payload. -In its simplest form, it expects a payload of type `java.util.Map` and puts the map entries into its configured region. -The following example shows how to configure an outbound channel adapter: - -==== -[source,xml] ----- - ----- -==== - -Given the preceding configuration, an exception is thrown if the payload is not a `Map`. -Additionally, you can configure the outbound channel adapter to create a map of cache entries by using SpEL. -The following example shows how to do so: - -==== -[source,xml] ----- - - - - - - ----- -==== - -In the preceding configuration, the inner element (`cache-entries`) is semantically equivalent to a Spring 'map' element. -The adapter interprets the `key` and `value` attributes as SpEL expressions with the message as the evaluation context. -Note that this can contain arbitrary cache entries (not only those derived from the message) and that literal values must be enclosed in single quotes. -In the preceding example, if the message sent to `cacheChannel` has a `String` payload with a value `Hello`, two entries (`[HELLO:hello, thing1:thing2]`) are written (either created or updated) in the cache region. -This adapter also supports the `order` attribute, which may be useful if it is bound to a `PublishSubscribeChannel`. - -[[gemfire-message-store]] -=== Gemfire Message Store - -As described in EIP, a https://www.enterpriseintegrationpatterns.com/MessageStore.html[message store] lets you persist messages. -This can be useful when dealing with components that have a capability to buffer messages (`QueueChannel`, `Aggregator`, `Resequencer`, and others) if reliability is a concern. -In Spring Integration, the `MessageStore` strategy interface also provides the foundation for the https://www.enterpriseintegrationpatterns.com/StoreInLibrary.html[claim check] pattern, which is described in EIP as well. - -Spring Integration's Gemfire module provides `GemfireMessageStore`, which is an implementation of both the `MessageStore` strategy (mainly used by the `QueueChannel` and `ClaimCheck` patterns) and the `MessageGroupStore` strategy (mainly used by the `Aggregator` and `Resequencer` patterns). - -The following example configures the cache and region by using the `spring-gemfire` namespace (not to be confused with the `spring-integration-gemfire` namespace): - -==== -[source,xml] ----- - - - - - - - - - - - - - - ----- -==== - -Often, it is desirable for the message store to be maintained in one or more remote cache servers in a client-server configuration. -In this case, you should configure a client cache, a client region, and a client pool and inject the region into the `MessageStore`. -The following example shows how to do so: - -==== -[source,xml] ----- - - - - - - - - - - - ----- -==== - -Note that the `pool` element is configured with the address of a cache server (you can substitute a locator here). -The region is configured as a 'PROXY' so that no data is stored locally. -The region's `id` corresponds to a region with the same name in the cache server. - -Starting with version 4.3.12, the `GemfireMessageStore` supports the key `prefix` option to allow distinguishing between instances of the store on the same GemFire region. - -[[gemfire-lock-registry]] -=== Gemfire Lock Registry - -Starting with version 4.0, the `GemfireLockRegistry` is available. -Certain components (for example, the aggregator and the resequencer) use a lock obtained from a `LockRegistry` instance to ensure that only one thread is manipulating a group at any given time. -The `DefaultLockRegistry` performs this function within a single component. -You can now configure an external lock registry on these components. -When you use a shared `MessageGroupStore` with the `GemfireLockRegistry`, it can provide this functionality across multiple application instances, such that only one instance can manipulate the group at a time. - -NOTE: One of the `GemfireLockRegistry` constructors requires a `Region` as an argument. -It is used to obtain a `Lock` from the `getDistributedLock()` method. -This operation requires `GLOBAL` scope for the `Region`. -Another constructor requires a `Cache`, and the `Region` is created with `GLOBAL` scope and with the name, `LockRegistry`. - -[[gemfire-metadata-store]] -=== Gemfire Metadata Store - -Version 4.0 introduced a new Gemfire-based `MetadataStore` (<<./meta-data-store.adoc#metadata-store,Metadata Store>>) implementation. -You can use the `GemfireMetadataStore` to maintain metadata state across application restarts. -This new `MetadataStore` implementation can be used with adapters such as: - -* <<./feed.adoc#feed-inbound-channel-adapter,Feed Inbound Channel Adapter>> -* <<./file.adoc#file-reading,Reading Files>> -* <<./ftp.adoc#ftp-inbound,FTP Inbound Channel Adapter>> -* <<./sftp.adoc#sftp-inbound,SFTP Inbound Channel Adapter>> - -To get these adapters to use the new `GemfireMetadataStore`, declare a Spring bean with a bean name of `metadataStore`. -The feed inbound channel adapter automatically picks up and use the declared `GemfireMetadataStore`. - -NOTE: The `GemfireMetadataStore` also implements `ConcurrentMetadataStore`, letting it be reliably shared across multiple application instances, where only one instance can store or modify a key's value. -These methods give various levels of concurrency guarantees based on the scope and data policy of the region. -They are implemented in the peer cache and client-server cache but are disallowed in peer regions that have `NORMAL` or `EMPTY` data policies. - -NOTE: Since version 5.0, the `GemfireMetadataStore` also implements `ListenableMetadataStore`, which lets you listen to cache events by providing `MetadataStoreListener` instances to the store, as the following example shows: - -==== -[source,java] ----- -GemfireMetadataStore metadataStore = new GemfireMetadataStore(cache); -metadataStore.addListener(new MetadataStoreListenerAdapter() { - - @Override - public void onAdd(String key, String value) { - ... - } - -}); ----- -==== diff --git a/src/reference/asciidoc/index-single.adoc b/src/reference/asciidoc/index-single.adoc index aae9dab800..3b8b091766 100644 --- a/src/reference/asciidoc/index-single.adoc +++ b/src/reference/asciidoc/index-single.adoc @@ -49,8 +49,6 @@ include::./file.adoc[] include::./ftp.adoc[] -include::./gemfire.adoc[] - include::./graphql.adoc[] include::./http.adoc[] diff --git a/src/reference/asciidoc/index.adoc b/src/reference/asciidoc/index.adoc index 04872fe658..ddcb9cdaf8 100644 --- a/src/reference/asciidoc/index.adoc +++ b/src/reference/asciidoc/index.adoc @@ -38,7 +38,6 @@ Welcome to the Spring Integration reference documentation! <<./feed.adoc#feed,Feed Adapter>> :: RSS and Atom channel adapters <<./file.adoc#files,File Support>> :: Channel adapters and gateways for file system support <<./ftp.adoc#ftp,FTP/FTPS Adapters>> :: Channel adapters and gateways for FTP protocol -<<./gemfire.adoc#gemfire,Apache Geode Support>> :: Apache Geode channel adapters, message store <<./graphql.adoc#graphql,GraphQL Support>> :: Channel adapters for GraphQL <<./http.adoc#http,HTTP Support>> :: Channel adapters and gateways for HTTP communication <<./jdbc.adoc#jdbc,JDBC Support>> :: Channel adapters and gateways for JDBC, message and metadata stores diff --git a/src/reference/asciidoc/message-store.adoc b/src/reference/asciidoc/message-store.adoc index 79faaa3b7f..e04e78d15d 100644 --- a/src/reference/asciidoc/message-store.adoc +++ b/src/reference/asciidoc/message-store.adoc @@ -43,7 +43,6 @@ The following is a complete list of supported implementations: * <<./jdbc.adoc#jdbc-message-store,JDBC Message Store>>: Uses an RDBMS to store messages * <<./redis.adoc#redis-message-store,Redis Message Store>>: Uses a Redis key/value datastore to store messages * <<./mongodb.adoc#mongodb-message-store,MongoDB Message Store>>: Uses a MongoDB document store to store messages -* <<./gemfire.adoc#gemfire-message-store,Gemfire Message Store>>: Uses a Gemfire distributed cache to store messages [IMPORTANT] ===== diff --git a/src/reference/asciidoc/meta-data-store.adoc b/src/reference/asciidoc/meta-data-store.adoc index aa12b669f4..8ee0a86ac6 100644 --- a/src/reference/asciidoc/meta-data-store.adoc +++ b/src/reference/asciidoc/meta-data-store.adoc @@ -14,7 +14,6 @@ This means that, upon restart, you may end up with duplicate entries. If you need to persist metadata between application context restarts, the framework provides the following persistent `MetadataStores`: * `PropertiesPersistingMetadataStore` -* <<./gemfire.adoc#gemfire-metadata-store,Gemfire Metadata Store>> * <<./jdbc.adoc#jdbc-metadata-store,JDBC Metadata Store>> * <<./mongodb.adoc#mongodb-metadata-store,MongoDB Metadata Store>> * <<./redis.adoc#redis-metadata-store,Redis Metadata Store>> diff --git a/src/reference/asciidoc/sftp.adoc b/src/reference/asciidoc/sftp.adoc index c397d7a311..09d6a33dd1 100644 --- a/src/reference/asciidoc/sftp.adoc +++ b/src/reference/asciidoc/sftp.adoc @@ -326,7 +326,7 @@ The default `MetadataStore` is a `SimpleMetadataStore` that stores state in memo Since version 4.1.5, these filters have a new property called `flushOnUpdate`, which causes them to flush the metadata store on every update (if the store implements `Flushable`). -IMPORTANT: Further, if you use a distributed `MetadataStore` (such as <<./redis.adoc#redis-metadata-store,Redis Metadata Store>> or <<./gemfire.adoc#gemfire-metadata-store,Gemfire Metadata Store>>), you can have multiple instances of the same adapter or application and be sure that one and only one instance processes a file. +IMPORTANT: Further, if you use a distributed `MetadataStore` (such as <<./redis.adoc#redis-metadata-store,Redis Metadata Store>>), you can have multiple instances of the same adapter or application and be sure that one and only one instance processes a file. The actual local filter is a `CompositeFileListFilter` that contains the supplied filter and a pattern filter that prevents processing files that are in the process of being downloaded (based on the `temporary-file-suffix`). Files are downloaded with this suffix (the default is `.writing`), and the files are renamed to their final names when the transfer is complete, making them 'visible' to the filter. diff --git a/src/reference/asciidoc/testing.adoc b/src/reference/asciidoc/testing.adoc index 7e2282524a..2338b4c565 100644 --- a/src/reference/asciidoc/testing.adoc +++ b/src/reference/asciidoc/testing.adoc @@ -30,7 +30,7 @@ Examples of such tools include the following: * There are tools for embedded MongoDB and Redis. * Tomcat and Jetty have embedded libraries to test real HTTP, Web Services, or WebSockets. * The `FtpServer` and `SshServer` from the Apache Mina project can be used for testing the FTP and SFTP protocols. -* Gemfire and Hazelcast can be run as real-data grid nodes in the tests. +* Hazelcast can be run as real-data grid nodes in the tests. * The Curator Framework provides a `TestingServer` for Zookeeper interaction. * Apache Kafka provides admin tools to embed a Kafka Broker in the tests. * The GreenMail is an open source, intuitive and easy-to-use test suite of email servers for testing purposes. diff --git a/src/reference/asciidoc/whats-new.adoc b/src/reference/asciidoc/whats-new.adoc index c03c99dc37..ce20d6d284 100644 --- a/src/reference/asciidoc/whats-new.adoc +++ b/src/reference/asciidoc/whats-new.adoc @@ -86,18 +86,23 @@ See <<./gateway.adoc#async-gateway, Asynchronous Gateway>> for more information. The `integrationGlobalProperties` bean is now declared by the framework as an instance of `org.springframework.integration.context.IntegrationProperties` instead of the previously deprecated `java.util.Properties`. -[[x6.0-http]] -=== HTTP Changes - -The `#cookies` variable for expression evaluation context, exposed in the `HttpRequestHandlingEndpointSupport`, is now a `MultiValueMap` to carry all the values for cookies set by the client. -See <<./http.adoc#http,HTTP Support>> for more information. - [[x6.0-rmi]] === RMI Removal The `spring-integration-rmi` module has been removed altogether after being deprecated in previous versions. There is no replacement: it is recommended to migrate to more secure network and application protocols, such as WebSockets, RSockets, gRPC or REST. +[[x6.0-gemfire]] +=== GemFire Removal + +The `spring-integration-gemfire` module has been removed altogether since there is no Spring Data `2022.0.0` support for VMware GemFire or Apache Geode. + +[[x6.0-http]] +=== HTTP Changes + +The `#cookies` variable for expression evaluation context, exposed in the `HttpRequestHandlingEndpointSupport`, is now a `MultiValueMap` to carry all the values for cookies set by the client. +See <<./http.adoc#http,HTTP Support>> for more information. + === Apache Kafka Changes When providing a `RetryTemplate` on the inbound gateway or message-driven channel adapter, if an `errorChannel` is also provided, an `ErrorMessageSendingRecoverer` is automatically configured.