Skip to content

Commit 8543919

Browse files
committed
* Use [^GROUP_] in the pattern for messages count
**Cherry-pick to `6.1.x`**
1 parent 3ddd5e9 commit 8543919

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

spring-integration-core/src/main/java/org/springframework/integration/store/AbstractKeyValueMessageStore.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
4646

4747
protected static final String MESSAGE_KEY_PREFIX = "MESSAGE_";
4848

49-
protected static final String MESSAGE_GROUP_KEY_PREFIX = "GROUP_OF_MESSAGES_";
49+
protected static final String MESSAGE_GROUP_KEY_PREFIX = "MESSAGE_GROUP_";
5050

5151
private final String messagePrefix;
5252

@@ -77,7 +77,7 @@ protected AbstractKeyValueMessageStore(String prefix) {
7777
* @return the prefix for keys
7878
* @since 4.3.12
7979
*/
80-
protected String getMessagePrefix() {
80+
public String getMessagePrefix() {
8181
return this.messagePrefix;
8282
}
8383

@@ -167,11 +167,10 @@ public Message<?> removeMessage(UUID id) {
167167
@Override
168168
@ManagedAttribute
169169
public long getMessageCount() {
170-
Collection<?> messageIds = doListKeys(this.messagePrefix + '*');
170+
Collection<?> messageIds = doListKeys(this.messagePrefix + "[^GROUP_]*");
171171
return (messageIds != null) ? messageIds.size() : 0;
172172
}
173173

174-
175174
// MessageGroupStore methods
176175

177176
/**

spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/store/HazelcastMessageStore.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2022 the original author or authors.
2+
* Copyright 2017-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -76,8 +76,8 @@ protected Object doRemove(Object id) {
7676
@Override
7777
protected Collection<?> doListKeys(String keyPattern) {
7878
Assert.hasText(keyPattern, "'keyPattern' must not be empty");
79-
return this.map.keySet(Predicates.like(QueryConstants.KEY_ATTRIBUTE_NAME.value(),
80-
keyPattern.replaceAll("\\*", "%")));
79+
return this.map.keySet(Predicates.regex(QueryConstants.KEY_ATTRIBUTE_NAME.value(),
80+
keyPattern.replaceAll("\\*", ".+")));
8181
}
8282

8383
}

spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/store/HazelcastMessageStoreTests.java

-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public void clean() {
6969

7070
@Test
7171
public void testWithMessageHistory() {
72-
7372
Message<?> message = new GenericMessage<>("Hello");
7473
DirectChannel fooChannel = new DirectChannel();
7574
fooChannel.setBeanName("fooChannel");
@@ -107,7 +106,6 @@ public void testAddAndRemoveMessagesFromMessageGroup() {
107106

108107
@Test
109108
public void addAndGetMessage() {
110-
111109
Message<?> message = MessageBuilder.withPayload("test").build();
112110
store.addMessage(message);
113111
Message<?> retrieved = store.getMessage(message.getHeaders().getId());

spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageGroupStoreTests.java

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ static void setupConnection() {
8282
@AfterEach
8383
void setUpTearDown() {
8484
StringRedisTemplate template = RedisContainerTest.createStringRedisTemplate(redisConnectionFactory);
85-
template.delete(template.keys("GROUP_OF_MESSAGES_*"));
8685
template.delete(template.keys("MESSAGE_*"));
8786
}
8887

0 commit comments

Comments
 (0)