I have two spring boot services running in two different VMs on two different virtual network.
One service runs on and pushes notifications to a channel in Azure RediscCache.
Optional<Long> hasMessageSent = redisStringTemplate.convertAndSend(syncQueue, GSON.toJson(data))
.onErrorReturn(-1L).blockOptional(Duration.ofMinutes(BLOCK_MINUTES));
if (!hasMessageSent.isPresent() || hasMessageSent.get() < 0) {
LOG.warn("Unable to send the sync message.");
return false;
}
2nd service subscribes to the above channel to receive the notifications.
public void subscriberToChannel() {
LOG.debug("Subscribing to channel " + syncQueue);
redisTemplate.listenToChannel(syncQueue).name("SYNCQUEUER").doOnNext(msg -> {
LOG.debug("New message received: '" + msg.toString());
buildOrUpdateNotifications(getNotification(msg.getMessage()));
}).doOnError(e -> LOG.error("Error while listening at the channel, will continue.", e)).subscribe();
}
The above setup works fine if I have both publisher and subscriber run from the same machine.
When I moved the publisher i.e.,1st service to a VM; subscriberi.e., 2nd service has stopped receiving the messages.
I could see from the redis console that publisher is indeed pushing the messages to the channel but subscriber does not receive them.
I can confirm that in all the scenarios, publisher and subscribe are connected to the same Azure Redis Cache instance.
While it does not make sense for the subscriber not to receive the message, I am wondering, is there something I am missing here? does channel have any limitation on the network it is running on? I checked with 'CLIENT LIST' command; publisher lives at 20.x.x.x and subscriber at 183.x.x.x.