Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fmachado091/a429b65a2e70ea2d8744c0e727d86254 to your computer and use it in GitHub Desktop.
Save fmachado091/a429b65a2e70ea2d8744c0e727d86254 to your computer and use it in GitHub Desktop.
public abstract class PubSubPublisher {
private static final Logger LOGGER = LoggerFactory.getLogger(PubSubPublisher.class);
private final PubSubTemplate pubSubTemplate;
protected PubSubPublisher(PubSubTemplate pubSubTemplate) {
this.pubSubTemplate = pubSubTemplate;
}
protected abstract String topic();
public void publish(String message) {
LOGGER.info("Publishing to topic [{}]. Message: [{}]", topic(), message);
pubSubTemplate.publish(topic(), message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment