diff --git a/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/store/HazelcastMessageStore.java b/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/store/HazelcastMessageStore.java index 408407e..2ff361d 100644 --- a/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/store/HazelcastMessageStore.java +++ b/spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/store/HazelcastMessageStore.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-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. @@ -23,8 +23,8 @@ import org.springframework.util.Assert; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.map.IMap; -import com.hazelcast.query.Predicate; -import com.hazelcast.query.impl.predicates.SqlPredicate; +import com.hazelcast.query.Predicates; +import com.hazelcast.query.QueryConstants; /** * The Hazelcast {@link IMap}-based {@link AbstractKeyValueMessageStore} implementation. @@ -77,9 +77,7 @@ public class HazelcastMessageStore extends AbstractKeyValueMessageStore { protected Collection doListKeys(String keyPattern) { Assert.hasText(keyPattern, "'keyPattern' must not be empty"); keyPattern = keyPattern.replaceAll("\\*", "%"); - @SuppressWarnings("unchecked") - Predicate sqlPredicate = new SqlPredicate("__key like " + keyPattern); - return this.map.values(sqlPredicate); + return this.map.keySet(Predicates.like(QueryConstants.KEY_ATTRIBUTE_NAME.value(), keyPattern)); } } diff --git a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/store/HazelcastMessageStoreTests.java b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/store/HazelcastMessageStoreTests.java index 88fb325..7cc308d 100644 --- a/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/store/HazelcastMessageStoreTests.java +++ b/spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/store/HazelcastMessageStoreTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2020 the original author or authors. + * Copyright 2017-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. @@ -132,4 +132,18 @@ public class HazelcastMessageStoreTests { assertThat(size).isEqualTo(2); } + @Test + public void messageStoreIterator() { + Message message1 = MessageBuilder.withPayload("test").build(); + Message message2 = MessageBuilder.withPayload("test").build(); + store.addMessageToGroup("test", message1); + store.addMessageToGroup("test", message2); + int groupCount = 0; + for (MessageGroup messageGroup : store) { + assertThat(messageGroup.size()).isEqualTo(2); + groupCount++; + } + assertThat(groupCount).isEqualTo(1); + } + }