Skip to content

Commit b705a96

Browse files
committed
GH-9441: Deprecate Hazelcast CP Subsystem usage
Fixes: #9441 * Upgrade to Hazelcast `5.5` * Deprecate `LeaderInitiator`, `HazelcastLockRegistry` since they cannot be used in Open Source due to Hazelcast CP Subsystem migration under commercial support * Deprecate `HazelcastMembershipListener` and `HazelcastLocalInstanceRegistrar` in favor of Hazelcast `Cluster` API. * Mention changes in the docs
1 parent 0f225d8 commit b705a96

17 files changed

+46
-772
lines changed

Diff for: build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ ext {
7373
greenmailVersion = '2.1.3'
7474
groovyVersion = '4.0.26'
7575
hamcrestVersion = '3.0'
76-
hazelcastVersion = '5.4.0'
76+
hazelcastVersion = '5.5.0'
7777
hibernateVersion = '6.6.13.Final'
7878
hsqldbVersion = '2.7.4'
7979
h2Version = '2.3.232'

Diff for: spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/HazelcastLocalInstanceRegistrar.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2022 the original author or authors.
2+
* Copyright 2015-2025 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.
@@ -27,7 +27,6 @@
2727
import org.apache.commons.logging.LogFactory;
2828

2929
import org.springframework.beans.factory.SmartInitializingSingleton;
30-
import org.springframework.integration.hazelcast.listener.HazelcastMembershipListener;
3130

3231
/**
3332
* This class creates an internal configuration {@link MultiMap} to cache Hazelcast instances' socket
@@ -39,7 +38,10 @@
3938
* @author Artem Bilan
4039
*
4140
* @since 6.0
41+
*
42+
* @deprecated in favor of {@link com.hazelcast.cluster.Cluster} API.
4243
*/
44+
@Deprecated(forRemoval = true, since = "6.5")
4345
public class HazelcastLocalInstanceRegistrar implements SmartInitializingSingleton {
4446

4547
private static final Log logger = LogFactory.getLog(HazelcastLocalInstanceRegistrar.class);
@@ -77,12 +79,15 @@ public HazelcastLocalInstanceRegistrar(HazelcastInstance hazelcastInstance) {
7779
this.hazelcastInstance = hazelcastInstance;
7880
}
7981

82+
@SuppressWarnings("removal")
8083
@Override
8184
public void afterSingletonsInstantiated() {
8285
if (this.hazelcastInstance == null) {
8386
if (!Hazelcast.getAllHazelcastInstances().isEmpty()) {
8487
HazelcastInstance anyHazelcastInstance = Hazelcast.getAllHazelcastInstances().iterator().next();
85-
anyHazelcastInstance.getCluster().addMembershipListener(new HazelcastMembershipListener());
88+
anyHazelcastInstance.getCluster()
89+
.addMembershipListener(
90+
new org.springframework.integration.hazelcast.listener.HazelcastMembershipListener());
8691
syncConfigurationMultiMap(anyHazelcastInstance);
8792
}
8893
else {
@@ -91,7 +96,9 @@ public void afterSingletonsInstantiated() {
9196
}
9297
else {
9398
syncConfigurationMultiMap(this.hazelcastInstance);
94-
this.hazelcastInstance.getCluster().addMembershipListener(new HazelcastMembershipListener());
99+
this.hazelcastInstance.getCluster()
100+
.addMembershipListener(
101+
new org.springframework.integration.hazelcast.listener.HazelcastMembershipListener());
95102
}
96103
}
97104

Diff for: spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/config/HazelcastIntegrationConfigurationInitializer.java

-45
This file was deleted.

Diff for: spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/config/package-info.java

-4
This file was deleted.

Diff for: spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/inbound/AbstractHazelcastMessageProducer.java

+8-32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 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.
@@ -17,10 +17,8 @@
1717
package org.springframework.integration.hazelcast.inbound;
1818

1919
import java.net.InetSocketAddress;
20-
import java.net.SocketAddress;
2120
import java.util.Collections;
2221
import java.util.HashMap;
23-
import java.util.HashSet;
2422
import java.util.Map;
2523
import java.util.Set;
2624
import java.util.UUID;
@@ -33,14 +31,12 @@
3331
import com.hazelcast.instance.EndpointQualifier;
3432
import com.hazelcast.map.AbstractIMapEvent;
3533
import com.hazelcast.map.MapEvent;
36-
import com.hazelcast.multimap.MultiMap;
3734

3835
import org.springframework.integration.endpoint.MessageProducerSupport;
3936
import org.springframework.integration.hazelcast.CacheEventType;
4037
import org.springframework.integration.hazelcast.CacheListeningPolicyType;
4138
import org.springframework.integration.hazelcast.HazelcastHeaders;
4239
import org.springframework.integration.hazelcast.HazelcastIntegrationDefinitionValidator;
43-
import org.springframework.integration.hazelcast.HazelcastLocalInstanceRegistrar;
4440
import org.springframework.integration.hazelcast.message.EntryEventMessagePayload;
4541
import org.springframework.messaging.Message;
4642
import org.springframework.util.Assert;
@@ -112,40 +108,20 @@ protected abstract class AbstractHazelcastEventListener<E> {
112108

113109
protected void sendMessage(E event, InetSocketAddress socketAddress,
114110
CacheListeningPolicyType cacheListeningPolicyType) {
115-
if (CacheListeningPolicyType.ALL == cacheListeningPolicyType || isEventAcceptable(socketAddress)) {
111+
if (CacheListeningPolicyType.ALL == cacheListeningPolicyType || isEventLocal(socketAddress)) {
116112
AbstractHazelcastMessageProducer.this.sendMessage(toMessage(event));
117113
}
118114
}
119115

120-
private boolean isEventAcceptable(final InetSocketAddress socketAddress) {
121-
final Set<HazelcastInstance> hazelcastInstanceSet = Hazelcast.getAllHazelcastInstances();
122-
final Set<SocketAddress> localSocketAddressesSet = getLocalSocketAddresses(hazelcastInstanceSet);
123-
return localSocketAddressesSet.isEmpty() ||
124-
localSocketAddressesSet.contains(socketAddress)
125-
|| isEventComingFromNonRegisteredHazelcastInstance(hazelcastInstanceSet.iterator().next(),
126-
localSocketAddressesSet, socketAddress);
127-
128-
}
129-
130-
private Set<SocketAddress> getLocalSocketAddresses(final Set<HazelcastInstance> hazelcastInstanceSet) {
131-
final Set<SocketAddress> localSocketAddressesSet = new HashSet<>();
116+
private boolean isEventLocal(InetSocketAddress socketAddress) {
117+
Set<HazelcastInstance> hazelcastInstanceSet = Hazelcast.getAllHazelcastInstances();
132118
for (HazelcastInstance hazelcastInstance : hazelcastInstanceSet) {
133-
localSocketAddressesSet.add(hazelcastInstance.getLocalEndpoint().getSocketAddress());
119+
if (socketAddress.equals(hazelcastInstance.getLocalEndpoint().getSocketAddress())) {
120+
return true;
121+
}
134122
}
135123

136-
return localSocketAddressesSet;
137-
}
138-
139-
private boolean isEventComingFromNonRegisteredHazelcastInstance(
140-
final HazelcastInstance hazelcastInstance,
141-
final Set<SocketAddress> localSocketAddressesSet,
142-
final InetSocketAddress socketAddressOfEvent) {
143-
final MultiMap<SocketAddress, SocketAddress> configMultiMap = hazelcastInstance
144-
.getMultiMap(HazelcastLocalInstanceRegistrar.SPRING_INTEGRATION_INTERNAL_CLUSTER_MULTIMAP);
145-
return configMultiMap.size() > 0
146-
&& !configMultiMap.values().contains(socketAddressOfEvent)
147-
&& localSocketAddressesSet.contains(configMultiMap.keySet().iterator().next());
148-
124+
return false;
149125
}
150126

151127
}

Diff for: spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/leader/LeaderInitiator.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the original author or authors.
2+
* Copyright 2015-2025 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.
@@ -57,7 +57,11 @@
5757
* @author Robert Höglund
5858
* @author Christian Tzolov
5959
* @author Emil Palm
60+
*
61+
* @deprecated with no replacement since this class relies on the CP Subsystem
62+
* which is not Open Source anymore since Hazelcast 5.5.
6063
*/
64+
@Deprecated(forRemoval = true, since = "6.5")
6165
public class LeaderInitiator implements SmartLifecycle, DisposableBean, ApplicationEventPublisherAware {
6266

6367
private static final LogAccessor logger = new LogAccessor(LeaderInitiator.class);

Diff for: spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/listener/HazelcastMembershipListener.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2022 the original author or authors.
2+
* Copyright 2015-2025 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.
@@ -36,7 +36,11 @@
3636
* @author Artem Bilan
3737
*
3838
* @since 6.0
39+
*
40+
* @deprecated in favor of {@link com.hazelcast.cluster.Cluster} API.
3941
*/
42+
@Deprecated(forRemoval = true, since = "6.5")
43+
@SuppressWarnings("removal")
4044
public class HazelcastMembershipListener extends MembershipAdapter {
4145

4246
@Override

Diff for: spring-integration-hazelcast/src/main/java/org/springframework/integration/hazelcast/lock/HazelcastLockRegistry.java

+5-1
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-2025 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.
@@ -27,7 +27,11 @@
2727
* A {@link LockRegistry} implementation Hazelcast distributed locks.
2828
*
2929
* @author Artem Bilan
30+
*
31+
* @deprecated with no replacement since this class relies on the CP Subsystem
32+
* which is not Open Source anymore since Hazelcast 5.5.
3033
*/
34+
@Deprecated(forRemoval = true, since = "6.5")
3135
public class HazelcastLockRegistry implements LockRegistry {
3236

3337
private final HazelcastInstance client;

Diff for: spring-integration-hazelcast/src/main/resources/META-INF/spring.factories

-2
This file was deleted.

Diff for: spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/common-config.xml

+1-11
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
55

6-
<bean id="instance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance" destroy-method="shutdown">
7-
<constructor-arg>
8-
<bean class="com.hazelcast.config.Config">
9-
<property name="CPSubsystemConfig">
10-
<bean class="com.hazelcast.config.cp.CPSubsystemConfig">
11-
<property name="CPMemberCount" value="0"/>
12-
</bean>
13-
</property>
14-
</bean>
15-
</constructor-arg>
16-
</bean>
6+
<bean id="instance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance" destroy-method="shutdown"/>
177

188
</beans>

Diff for: spring-integration-hazelcast/src/test/java/org/springframework/integration/hazelcast/inbound/config/HazelcastIntegrationInboundTestConfiguration.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2022 the original author or authors.
2+
* Copyright 2015-2025 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.
@@ -35,7 +35,6 @@
3535
import org.springframework.integration.config.EnableIntegration;
3636
import org.springframework.integration.hazelcast.DistributedSQLIterationType;
3737
import org.springframework.integration.hazelcast.HazelcastIntegrationTestUser;
38-
import org.springframework.integration.hazelcast.HazelcastLocalInstanceRegistrar;
3938
import org.springframework.integration.hazelcast.inbound.HazelcastClusterMonitorMessageProducer;
4039
import org.springframework.integration.hazelcast.inbound.HazelcastContinuousQueryMessageProducer;
4140
import org.springframework.integration.hazelcast.inbound.HazelcastDistributedSQLMessageSource;
@@ -225,11 +224,6 @@ public HazelcastInstance testHazelcastInstance() {
225224
return Hazelcast.newHazelcastInstance(hazelcastConfig());
226225
}
227226

228-
@Bean(HazelcastLocalInstanceRegistrar.BEAN_NAME)
229-
public HazelcastLocalInstanceRegistrar hazelcastLocalInstanceRegistrar() {
230-
return new HazelcastLocalInstanceRegistrar(testHazelcastInstance());
231-
}
232-
233227
@Bean
234228
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer() {
235229
final HazelcastEventDrivenMessageProducer producer =

0 commit comments

Comments
 (0)