|
50 | 50 | import org.keycloak.cluster.ClusterListener; |
51 | 51 | import org.keycloak.cluster.ClusterProvider; |
52 | 52 | import org.keycloak.common.util.ConcurrentMultivaluedHashMap; |
| 53 | +import org.keycloak.common.util.Retry; |
53 | 54 | import org.keycloak.executors.ExecutorsProvider; |
54 | 55 | import org.keycloak.models.KeycloakSession; |
| 56 | +import org.infinispan.client.hotrod.exceptions.HotRodClientException; |
55 | 57 |
|
56 | 58 | /** |
57 | 59 | * Impl for sending infinispan messages across cluster and listening to them |
@@ -153,7 +155,21 @@ void notify(String taskKey, ClusterEvent event, boolean ignoreSender, ClusterPro |
153 | 155 | .put(eventKey, wrappedEvent, 120, TimeUnit.SECONDS); |
154 | 156 | } else { |
155 | 157 | // Add directly to remoteCache. Will notify remote listeners on all nodes in all DCs |
156 | | - workRemoteCache.put(eventKey, wrappedEvent, 120, TimeUnit.SECONDS); |
| 158 | + Retry.executeWithBackoff((int iteration) -> { |
| 159 | + try { |
| 160 | + workRemoteCache.put(eventKey, wrappedEvent, 120, TimeUnit.SECONDS); |
| 161 | + } catch (HotRodClientException re) { |
| 162 | + if (logger.isDebugEnabled()) { |
| 163 | + logger.debugf(re, "Failed sending notification to remote cache '%s'. Key: '%s', iteration '%s'. Will try to retry the task", |
| 164 | + workRemoteCache.getName(), eventKey, iteration); |
| 165 | + } |
| 166 | + |
| 167 | + // Rethrow the exception. Retry will take care of handle the exception and eventually retry the operation. |
| 168 | + throw re; |
| 169 | + } |
| 170 | + |
| 171 | + }, 10, 10); |
| 172 | + |
157 | 173 | } |
158 | 174 | } |
159 | 175 |
|
|
0 commit comments