| <!DOCTYPE html> |
| <html lang="English"> |
| <head> |
| <meta charset="utf-8"> |
| <meta name="viewport" content="width=device-width,initial-scale=1"> |
| <title>How to run eventmesh-sdk-java demo | EventMesh</title> |
| <meta name="generator" content="VuePress 1.7.1"> |
| <link rel="icon" href="/logo.png"> |
| <meta name="description" content="EventMesh"> |
| |
| <link rel="preload" href="/assets/css/0.styles.992cb7aa.css" as="style"><link rel="preload" href="/assets/js/app.141e6f9f.js" as="script"><link rel="preload" href="/assets/js/2.706fd1a1.js" as="script"><link rel="preload" href="/assets/js/21.6a3d0d97.js" as="script"><link rel="prefetch" href="/assets/js/10.f33f460f.js"><link rel="prefetch" href="/assets/js/11.a1abc765.js"><link rel="prefetch" href="/assets/js/12.d4a647c6.js"><link rel="prefetch" href="/assets/js/13.f06f88de.js"><link rel="prefetch" href="/assets/js/14.940a2bbe.js"><link rel="prefetch" href="/assets/js/15.1ed69544.js"><link rel="prefetch" href="/assets/js/16.d9824024.js"><link rel="prefetch" href="/assets/js/17.b3325889.js"><link rel="prefetch" href="/assets/js/18.08619497.js"><link rel="prefetch" href="/assets/js/19.e1fc838f.js"><link rel="prefetch" href="/assets/js/20.e4fe1ce3.js"><link rel="prefetch" href="/assets/js/22.643939a7.js"><link rel="prefetch" href="/assets/js/23.6599270d.js"><link rel="prefetch" href="/assets/js/24.67ba9674.js"><link rel="prefetch" href="/assets/js/25.f0733376.js"><link rel="prefetch" href="/assets/js/26.be745610.js"><link rel="prefetch" href="/assets/js/27.366b15c2.js"><link rel="prefetch" href="/assets/js/28.050d6443.js"><link rel="prefetch" href="/assets/js/29.53dcbee4.js"><link rel="prefetch" href="/assets/js/3.9bd2565c.js"><link rel="prefetch" href="/assets/js/30.ff6d7aa2.js"><link rel="prefetch" href="/assets/js/31.a4fab623.js"><link rel="prefetch" href="/assets/js/32.d33f13c0.js"><link rel="prefetch" href="/assets/js/33.6dfecd74.js"><link rel="prefetch" href="/assets/js/34.051228b6.js"><link rel="prefetch" href="/assets/js/35.437b425d.js"><link rel="prefetch" href="/assets/js/4.f08d96e9.js"><link rel="prefetch" href="/assets/js/5.485e1ca5.js"><link rel="prefetch" href="/assets/js/6.1d6ced8e.js"><link rel="prefetch" href="/assets/js/7.a563de49.js"><link rel="prefetch" href="/assets/js/8.78d19d07.js"><link rel="prefetch" href="/assets/js/9.9966f27a.js"> |
| <link rel="stylesheet" href="/assets/css/0.styles.992cb7aa.css"> |
| </head> |
| <body> |
| <div id="app" data-server-rendered="true"><div class="theme-container no-sidebar"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">EventMesh</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/en/community/" class="nav-link"> |
| Community |
| </a></div><div class="nav-item"><a href="/en/blog/" class="nav-link"> |
| Blog |
| </a></div><div class="nav-item"><a href="/en/documentation/" class="nav-link"> |
| Documentation |
| </a></div><div class="nav-item"><a href="https://github.com/WeBankFinTech/EventMesh" target="_blank" rel="noopener noreferrer" class="nav-link external"> |
| Github |
| <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Languages" class="dropdown-title"><span class="title">Languages</span> <span class="arrow down"></span></button> <button type="button" aria-label="Languages" class="mobile-dropdown-title"><span class="title">Languages</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/en/instructions/eventmesh-sdk-java-quickstart.html" aria-current="page" class="nav-link router-link-exact-active router-link-active"> |
| English |
| </a></li><li class="dropdown-item"><!----> <a href="/cn/" class="nav-link"> |
| 简体中文 |
| </a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/en/community/" class="nav-link"> |
| Community |
| </a></div><div class="nav-item"><a href="/en/blog/" class="nav-link"> |
| Blog |
| </a></div><div class="nav-item"><a href="/en/documentation/" class="nav-link"> |
| Documentation |
| </a></div><div class="nav-item"><a href="https://github.com/WeBankFinTech/EventMesh" target="_blank" rel="noopener noreferrer" class="nav-link external"> |
| Github |
| <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Languages" class="dropdown-title"><span class="title">Languages</span> <span class="arrow down"></span></button> <button type="button" aria-label="Languages" class="mobile-dropdown-title"><span class="title">Languages</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/en/instructions/eventmesh-sdk-java-quickstart.html" aria-current="page" class="nav-link router-link-exact-active router-link-active"> |
| English |
| </a></li><li class="dropdown-item"><!----> <a href="/cn/" class="nav-link"> |
| 简体中文 |
| </a></li></ul></div></div> <!----></nav> <!----> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="how-to-run-eventmesh-sdk-java-demo"><a href="#how-to-run-eventmesh-sdk-java-demo" class="header-anchor">#</a> How to run eventmesh-sdk-java demo</h2> <blockquote><p>Eventmesh-sdk-java , as the client, communicated with eventmesh-runtime, used to complete the sending and receiving of message.</p> <p>Eventmesh-sdk-java supports async msg and broadcast msg. Async msg means the producer just sends msg and does not care reply msg.Broadcast msg means the producer send msg once and all the consumer subscribed the broadcast topic will receive the msg.</p> <p>Eventmesh-sdk-java supports the protocol of HTTP and TCP.</p></blockquote> <p>TCP demos and Http demos are both under the <strong>eventmesh-test</strong> module.</p> <p><strong>prerequisite</strong>:after download the source code you should copy <code>/conf/application.properties</code> and <code>/conf/log4j2.xml</code> to the <code>resources</code> directory</p> <p><img src="/assets/img/eventmesh-test-structure.74a6b4c8.png" alt="image-test-structure"></p> <h3 id="_1-tcp-demo"><a href="#_1-tcp-demo" class="header-anchor">#</a> 1. TCP DEMO</h3> <h4 id="async-msg"><a href="#async-msg" class="header-anchor">#</a> Async msg</h4> <ul><li><p>create topic FT0-e-80010000-01-1 on rocketmq-console</p></li> <li><p>start consumer ,subscribe topic in previous step.</p></li></ul> <div class="language- extra-class"><pre class="language-text"><code>Run the main method of com.webank.eventmesh.tcp.demo.AsyncSubscribe |
| </code></pre></div><ul><li>start producer, send message</li></ul> <div class="language- extra-class"><pre class="language-text"><code>Run the main method of com.webank.eventmesh.tcp.demo.AsyncPublish |
| </code></pre></div><h4 id="broadcast-msg"><a href="#broadcast-msg" class="header-anchor">#</a> Broadcast msg</h4> <ul><li><p>create topic FT0-e-80030000-01-3 on rocketmq-console</p></li> <li><p>start consumer ,subscribe topic in previous step.</p></li></ul> <div class="language- extra-class"><pre class="language-text"><code>Run the main method of com.webank.eventmesh.tcp.demo.AsyncSubscribeBroadcast |
| </code></pre></div><ul><li>start producer, send broadcast message</li></ul> <div class="language- extra-class"><pre class="language-text"><code>Run the main method of com.webank.eventmesh.tcp.demo.AsyncPublishBroadcast |
| </code></pre></div><h3 id="_2-http-demo"><a href="#_2-http-demo" class="header-anchor">#</a> 2. HTTP DEMO</h3> <blockquote><p>As to http, eventmesh-sdk-java implements the pub and sub for async event .</p> <p>In the demo ,the field of <code>content</code> of the java class <code>LiteMessage</code> represents a special protocal, so if you want to use http-client of eventmesh-sdk-java, you just need to design the content of protocal and supply the consumer appliacation at the same time.</p></blockquote> <h4 id="async-event"><a href="#async-event" class="header-anchor">#</a> Async event</h4> <blockquote><p>producer send the event to consumer and don't need waiting response msg from consumer</p></blockquote> <ul><li><p>create topic FT0-e-80010001-01-1 on rocketmq-console</p></li> <li><p>start consumer, subscribe topic</p> <p>Async consumer demo is a spring boot application demo, you can easily run this demo to start service and subscribe the topic.</p></li></ul> <div class="language- extra-class"><pre class="language-text"><code>Run the main method of com.webank.eventmesh.http.demo.sub.SpringBootDemoApplication |
| </code></pre></div><ul><li>start producer, produce msg</li></ul> <div class="language- extra-class"><pre class="language-text"><code>Run the main method of com.webank.eventmesh.http.demo.AsyncPublishInstance |
| </code></pre></div></div> <footer class="page-edit"><!----> <!----></footer> <!----> </main></div><div class="global-ui"></div></div> |
| <script src="/assets/js/app.141e6f9f.js" defer></script><script src="/assets/js/2.706fd1a1.js" defer></script><script src="/assets/js/21.6a3d0d97.js" defer></script> |
| </body> |
| </html> |