30 lines
4.9 KiB
HTML
30 lines
4.9 KiB
HTML
<html><head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>9. Push Notifications and Spring Cloud Bus</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_config.html" title="Part II. Spring Cloud Config"><link rel="prev" href="multi__embedding_the_config_server.html" title="8. Embedding the Config Server"><link rel="next" href="multi__spring_cloud_config_client.html" title="10. Spring Cloud Config Client"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">9. Push Notifications and Spring Cloud Bus</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__embedding_the_config_server.html">Prev</a> </td><th width="60%" align="center">Part II. Spring Cloud Config</th><td width="20%" align="right"> <a accesskey="n" href="multi__spring_cloud_config_client.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="_push_notifications_and_spring_cloud_bus" href="#_push_notifications_and_spring_cloud_bus"></a>9. Push Notifications and Spring Cloud Bus</h2></div></div></div><p>Many source code repository providers (like Github, Gitlab or Bitbucket
|
|
for instance) will notify you of changes in a repository through a
|
|
webhook. You can configure the webhook via the provider’s user
|
|
interface as a URL and a set of events in which you are
|
|
interested. For instance
|
|
<a class="link" href="https://developer.github.com/v3/activity/events/types/#pushevent" target="_top">Github</a>
|
|
will POST to the webhook with a JSON body containing a list of
|
|
commits, and a header "X-Github-Event" equal to "push". If you add a
|
|
dependency on the <code class="literal">spring-cloud-config-monitor</code> library and activate
|
|
the Spring Cloud Bus in your Config Server, then a "/monitor" endpoint
|
|
is enabled.</p><p>When the webhook is activated the Config Server will send a
|
|
<code class="literal">RefreshRemoteApplicationEvent</code> targeted at the applications it thinks
|
|
might have changed. The change detection can be strategized, but by
|
|
default it just looks for changes in files that match the application
|
|
name (e.g. "foo.properties" is targeted at the "foo" application, and
|
|
"application.properties" is targeted at all applications). The strategy
|
|
if you want to override the behaviour is <code class="literal">PropertyPathNotificationExtractor</code>
|
|
which accepts the request headers and body as parameters and returns a list
|
|
of file paths that changed.</p><p>The default configuration works out of the box with Github, Gitlab or
|
|
Bitbucket. In addition to the JSON notifications from Github, Gitlab
|
|
or Bitbucket you can trigger a change notification by POSTing to
|
|
"/monitor" with a form-encoded body parameters <code class="literal">path={name}</code>. This will
|
|
broadcast to applications matching the "{name}" pattern (can contain
|
|
wildcards).</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>the <code class="literal">RefreshRemoteApplicationEvent</code> will only be transmitted if
|
|
the <code class="literal">spring-cloud-bus</code> is activated in the Config Server and in the
|
|
client application.</p></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>the default configuration also detects filesystem changes in
|
|
local git repositories (the webhook is not used in that case but as
|
|
soon as you edit a config file a refresh will be broadcast).</p></td></tr></table></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__embedding_the_config_server.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_config.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__spring_cloud_config_client.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">8. Embedding the Config Server </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> 10. Spring Cloud Config Client</td></tr></table></div></body></html> |