Files
spring-cloud-static/spring-cloud-function/1.0.0.RC2/multi/multi__dynamic_compilation.html
2018-06-04 10:40:50 +01:00

23 lines
6.0 KiB
HTML

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>4.&nbsp;Dynamic Compilation</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-function.html" title="Spring Cloud Function"><link rel="up" href="multi_spring-cloud-function.html" title="Spring Cloud Function"><link rel="prev" href="multi__building_and_running_a_function.html" title="3.&nbsp;Building and Running a Function"><link rel="next" href="multi__function_catalog_and_flexible_function_signatures.html" title="5.&nbsp;Function Catalog and Flexible Function Signatures"></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">4.&nbsp;Dynamic Compilation</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi__building_and_running_a_function.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="multi__function_catalog_and_flexible_function_signatures.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="_dynamic_compilation" href="#_dynamic_compilation"></a>4.&nbsp;Dynamic Compilation</h1></div></div></div><p>There is a sample app that uses the function compiler to create a
function from a configuration property. The vanilla "function-sample"
also has that feature. And there are some examples that you can run to
see the compilation happening at run time. To run these examples,
change into the <code class="literal">scripts</code> directory:</p><pre class="screen">cd scripts</pre><p>Also, start a RabbitMQ server locally (e.g. execute <code class="literal">rabbitmq-server</code>).</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_start_the_function_registry_service" href="#_start_the_function_registry_service"></a>4.1&nbsp;Start the Function Registry Service:</h2></div></div></div><pre class="screen">./function-registry.sh</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_register_a_function" href="#_register_a_function"></a>4.2&nbsp;Register a Function:</h2></div></div></div><pre class="screen">./registerFunction.sh -n uppercase -f "f-&gt;f.map(s-&gt;s.toString().toUpperCase())"</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_run_a_rest_microservice_using_that_function" href="#_run_a_rest_microservice_using_that_function"></a>4.3&nbsp;Run a REST Microservice using that Function:</h2></div></div></div><pre class="screen">./web.sh -f uppercase -p 9000
curl -H "Content-Type: text/plain" -H "Accept: text/plain" localhost:9000/uppercase -d foo</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_register_a_supplier" href="#_register_a_supplier"></a>4.4&nbsp;Register a Supplier:</h2></div></div></div><pre class="screen">./registerSupplier.sh -n words -f "()-&gt;Flux.just(\"foo\",\"bar\")"</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_run_a_rest_microservice_using_that_supplier" href="#_run_a_rest_microservice_using_that_supplier"></a>4.5&nbsp;Run a REST Microservice using that Supplier:</h2></div></div></div><pre class="screen">./web.sh -s words -p 9001
curl -H "Accept: application/json" localhost:9001/words</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_register_a_consumer" href="#_register_a_consumer"></a>4.6&nbsp;Register a Consumer:</h2></div></div></div><pre class="screen">./registerConsumer.sh -n print -t String -f "System.out::println"</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_run_a_rest_microservice_using_that_consumer" href="#_run_a_rest_microservice_using_that_consumer"></a>4.7&nbsp;Run a REST Microservice using that Consumer:</h2></div></div></div><pre class="screen">./web.sh -c print -p 9002
curl -X POST -H "Content-Type: text/plain" -d foo localhost:9002/print</pre></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="_run_stream_processing_microservices" href="#_run_stream_processing_microservices"></a>4.8&nbsp;Run Stream Processing Microservices:</h2></div></div></div><p>First register a streaming words supplier:</p><pre class="screen">./registerSupplier.sh -n wordstream -f "()-&gt;Flux.interval(Duration.ofMillis(1000)).map(i-&gt;\"message-\"+i)"</pre><p>Then start the source (supplier), processor (function), and sink (consumer) apps
(in reverse order):</p><pre class="screen">./stream.sh -p 9103 -i uppercaseWords -c print
./stream.sh -p 9102 -i words -f uppercase -o uppercaseWords
./stream.sh -p 9101 -s wordstream -o words</pre><p>The output will appear in the console of the sink app (one message per second, converted to uppercase):</p><pre class="screen">MESSAGE-0
MESSAGE-1
MESSAGE-2
MESSAGE-3
MESSAGE-4
MESSAGE-5
MESSAGE-6
MESSAGE-7
MESSAGE-8
MESSAGE-9
...</pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__building_and_running_a_function.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="multi__function_catalog_and_flexible_function_signatures.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.&nbsp;Building and Running a Function&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-function.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;5.&nbsp;Function Catalog and Flexible Function Signatures</td></tr></table></div></body></html>