Sync docs from master to gh-pages
This commit is contained in:
@@ -417,7 +417,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
||||
<div id="preamble">
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>This project allows a user to develop and run messaging microservices using Spring Integration and run them locally, or in the cloud, or even on Spring XD. Just create <code>MessageChannels</code> "input" and/or "output" and add <code>@EnableModule</code> and run your app as a Spring Boot app (single application context). You just need to connect to the physical broker for the bus, which is automatic if the relevant bus implementation is available on the classpath. The sample uses Redis.</p>
|
||||
<p>This project allows a user to develop and run messaging microservices using Spring Integration and run them locally, or in the cloud, or even on Spring XD. Just add <code>@EnableModule</code> and run your app as a Spring Boot app (single application context). You just need to connect to the physical broker for the bus, which is automatic if the relevant bus implementation is available on the classpath. The sample uses Redis.</p>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Here’s a sample source module (output channel only):</p>
|
||||
@@ -425,8 +425,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlight"><code class="language-java" data-lang="java">@SpringBootApplication
|
||||
@EnableModule
|
||||
@ComponentScan(basePackageClasses=ModuleDefinition.class)
|
||||
@ComponentScan(basePackageClasses=TimerSource.class)
|
||||
public class ModuleApplication {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
@@ -436,18 +435,14 @@ public class ModuleApplication {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public class ModuleDefinition {
|
||||
@EnableModule(Source.class)
|
||||
public class TimerSource {
|
||||
|
||||
@Value("${format}")
|
||||
private String format;
|
||||
|
||||
@Bean
|
||||
public MessageChannel output() {
|
||||
return new DirectChannel();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@InboundChannelAdapter(value = "output", autoStartup = "false", poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
|
||||
@InboundChannelAdapter(value = Source.OUTPUT, autoStartup = "false", poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
|
||||
public MessageSource<String> timerMessageSource() {
|
||||
return () -> new GenericMessage<>(new SimpleDateFormat(format).format(new Date()));
|
||||
}
|
||||
@@ -468,13 +463,58 @@ spring:
|
||||
outputChannelName: ${spring.application.name:ticker}</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p><code>@EnableModule</code> is parameterized by an interface (in this case <code>Source</code>) which declares input and output channels. <code>Source</code>, <code>Sink</code> and <code>Processor</code> are provided off the shelf, but you can define others. Here’s the definition of <code>Source</code></p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlight"><code class="language-java" data-lang="java">public interface Source {
|
||||
@Output("output")
|
||||
MessageChannel output();
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>The <code>@Output</code> annotation is used to identify output channels (messages leaving the module) and <code>@Input</code> is used to identify input channels (messages entering the module). It is optionally parameterized by a channel name - if the name is not provided the method name is used instead. An implementation of the interface is created for you and can be used in the application context by autowiring it, e.g. into a test case:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlight"><code class="language-java" data-lang="java">@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = ModuleApplication.class)
|
||||
@WebAppConfiguration
|
||||
@DirtiesContext
|
||||
public class ModuleApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private Source source
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
assertNotNull(this.sink.output());
|
||||
}
|
||||
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admonitionblock note">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="icon">
|
||||
<div class="title">Note</div>
|
||||
</td>
|
||||
<td class="content">
|
||||
In this case there is only one <code>Source</code> in the application context so there is no need to qualify it when it is autowired. If there is ambiguity, e.g. if you are composing one module from some others, you can use <code>@ModuleChannels</code> qualifier to inject a specific channel set. The <code>@ModuleChannels</code> qualifier takes a parameter which is the class that carries the <code>@EnableModule</code> annotation (in this case the <code>TimerSource</code>).
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="_multiple_input_or_output_channels">Multiple Input or Output Channels</h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>A module can have multiple input or output channels. Instead of just one channel named "input" or "output" you can add multiple <code>MessageChannel</code> beans named <code>input.<strong></code> or <code>output.</strong></code> and the names are converted to external channel names on the broker. The external channel names are the <code>spring.cloud.streams.[input|output]ChannelName</code> plus the <code>MessageChannel</code> bean name, period separated. In addition, the bean name can be <code>input.[queue|topic|tap]:*</code> or <code>output.[queue|topic]:*</code> (i.e. with a channel type as a colon-separated prefix), and the semantics of the external bus channel changes accordingly (a tap is like a topic). For example, you can have two <code>MessageChannels</code> called "output" and "output.topic:foo" in a module with <code>outputChannelName=bar</code>, and the result is 2 external channels called "bar" and "topic:foo.bar".</p>
|
||||
<p>A module can have multiple input or output channels all defined either as <code>@Input</code> and <code>@Output</code> methods in an interface (preferrable) or as bean definitions. Instead of just one channel named "input" or "output" you can add multiple <code>MessageChannel</code> methods annotated <code>input.<strong></code> or <code>output.</strong></code> and the names are converted to external channel names on the broker. The external channel names are the <code>spring.cloud.channels.[input|output]ChannelName</code> plus the <code>MessageChannel</code> bean name, period separated. In addition, the bean name can be <code>input.[queue|topic|tap]:*</code> or <code>output.[queue|topic]:*</code> (i.e. with a channel type as a colon-separated prefix), and the semantics of the external bus channel changes accordingly (a tap is like a topic). For example, you can have two <code>MessageChannels</code> called "output" and "output.topic:foo" in a module with <code>outputChannelName=bar</code>, and the result is 2 external channels called "bar" and "topic:foo.bar".</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -583,7 +623,7 @@ The main set of samples are "vanilla" in the sense that they are not deployable
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Last updated 2015-07-16 22:40:15 UTC
|
||||
Last updated 2015-07-17 01:46:13 UTC
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user