| <!DOCTYPE HTML> |
| <html lang="en" > |
| |
| <head> |
| |
| <meta charset="UTF-8"> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
| <title>Using Core | ActiveMQ Artemis Documentation</title> |
| <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> |
| <meta name="description" content=""> |
| <meta name="generator" content="GitBook 2.1.0"> |
| |
| |
| <meta name="HandheldFriendly" content="true"/> |
| <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> |
| <meta name="apple-mobile-web-app-capable" content="yes"> |
| <meta name="apple-mobile-web-app-status-bar-style" content="black"> |
| <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png"> |
| <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon"> |
| |
| <link rel="stylesheet" href="gitbook/style.css"> |
| |
| |
| |
| |
| |
| |
| <link rel="next" href="./jms-core-mapping.html" /> |
| |
| |
| <link rel="prev" href="./using-jms.html" /> |
| |
| |
| |
| </head> |
| <body> |
| |
| |
| <div class="book" data-level="8" data-basepath="." data-revision="Wed Sep 23 2015 12:51:51 GMT+0100 (BST)"> |
| |
| |
| <div class="book-summary"> |
| <div class="book-search"> |
| <input type="text" placeholder="Type to search" class="form-control" /> |
| </div> |
| <ul class="summary"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <li class="chapter " data-level="0" data-path="index.html"> |
| |
| |
| <a href="./index.html"> |
| <i class="fa fa-check"></i> |
| |
| Introduction |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="1" data-path="notice.html"> |
| |
| |
| <a href="./notice.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>1.</b> |
| |
| Legal Notice |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="2" data-path="preface.html"> |
| |
| |
| <a href="./preface.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>2.</b> |
| |
| Preface |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="3" data-path="project-info.html"> |
| |
| |
| <a href="./project-info.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>3.</b> |
| |
| Project Info |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="4" data-path="messaging-concepts.html"> |
| |
| |
| <a href="./messaging-concepts.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>4.</b> |
| |
| Messaging Concepts |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="5" data-path="architecture.html"> |
| |
| |
| <a href="./architecture.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>5.</b> |
| |
| Architecture |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="6" data-path="using-server.html"> |
| |
| |
| <a href="./using-server.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>6.</b> |
| |
| Using the Server |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="7" data-path="using-jms.html"> |
| |
| |
| <a href="./using-jms.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>7.</b> |
| |
| Using JMS |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter active" data-level="8" data-path="using-core.html"> |
| |
| |
| <a href="./using-core.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>8.</b> |
| |
| Using Core |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="9" data-path="jms-core-mapping.html"> |
| |
| |
| <a href="./jms-core-mapping.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>9.</b> |
| |
| Mapping JMS Concepts to the Core API |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="10" data-path="client-classpath.html"> |
| |
| |
| <a href="./client-classpath.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>10.</b> |
| |
| The Client Classpath |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="11" data-path="examples.html"> |
| |
| |
| <a href="./examples.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>11.</b> |
| |
| Examples |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="12" data-path="wildcard-routing.html"> |
| |
| |
| <a href="./wildcard-routing.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>12.</b> |
| |
| Routing Messages With Wild Cards |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="13" data-path="wildcard-syntax.html"> |
| |
| |
| <a href="./wildcard-syntax.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>13.</b> |
| |
| Understanding the Apache ActiveMQ Artemis Wildcard Syntax |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="14" data-path="filter-expressions.html"> |
| |
| |
| <a href="./filter-expressions.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>14.</b> |
| |
| Filter Expressions |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="15" data-path="persistence.html"> |
| |
| |
| <a href="./persistence.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>15.</b> |
| |
| Persistence |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="16" data-path="configuring-transports.html"> |
| |
| |
| <a href="./configuring-transports.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>16.</b> |
| |
| Configuring Transports |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="17" data-path="connection-ttl.html"> |
| |
| |
| <a href="./connection-ttl.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>17.</b> |
| |
| Detecting Dead Connections |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="18" data-path="slow-consumers.html"> |
| |
| |
| <a href="./slow-consumers.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>18.</b> |
| |
| Detecting Slow Consumers |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="19" data-path="transaction-config.html"> |
| |
| |
| <a href="./transaction-config.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>19.</b> |
| |
| Resource Manager Configuration |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="20" data-path="flow-control.html"> |
| |
| |
| <a href="./flow-control.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>20.</b> |
| |
| Flow Control |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="21" data-path="send-guarantees.html"> |
| |
| |
| <a href="./send-guarantees.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>21.</b> |
| |
| Guarantees of sends and commits |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="22" data-path="undelivered-messages.html"> |
| |
| |
| <a href="./undelivered-messages.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>22.</b> |
| |
| Message Redelivery and Undelivered Messages |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="23" data-path="message-expiry.html"> |
| |
| |
| <a href="./message-expiry.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>23.</b> |
| |
| Message Expiry |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="24" data-path="large-messages.html"> |
| |
| |
| <a href="./large-messages.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>24.</b> |
| |
| Large Messages |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="25" data-path="paging.html"> |
| |
| |
| <a href="./paging.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>25.</b> |
| |
| Paging |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="26" data-path="queue-attributes.html"> |
| |
| |
| <a href="./queue-attributes.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>26.</b> |
| |
| Queue Attributes |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="27" data-path="scheduled-messages.html"> |
| |
| |
| <a href="./scheduled-messages.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>27.</b> |
| |
| Scheduled Messages |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="28" data-path="last-value-queues.html"> |
| |
| |
| <a href="./last-value-queues.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>28.</b> |
| |
| Last-Value Queues |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="29" data-path="message-grouping.html"> |
| |
| |
| <a href="./message-grouping.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>29.</b> |
| |
| Message Grouping |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="30" data-path="pre-acknowledge.html"> |
| |
| |
| <a href="./pre-acknowledge.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>30.</b> |
| |
| Extra Acknowledge Modes |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="31" data-path="management.html"> |
| |
| |
| <a href="./management.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>31.</b> |
| |
| Management |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="32" data-path="security.html"> |
| |
| |
| <a href="./security.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>32.</b> |
| |
| Security |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="33" data-path="resource-limits.html"> |
| |
| |
| <a href="./resource-limits.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>33.</b> |
| |
| Resource Limits |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="34" data-path="jms-bridge.html"> |
| |
| |
| <a href="./jms-bridge.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>34.</b> |
| |
| The JMS Bridge |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="35" data-path="client-reconnection.html"> |
| |
| |
| <a href="./client-reconnection.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>35.</b> |
| |
| Client Reconnection and Session Reattachment |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="36" data-path="diverts.html"> |
| |
| |
| <a href="./diverts.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>36.</b> |
| |
| Diverting and Splitting Message Flows |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="37" data-path="core-bridges.html"> |
| |
| |
| <a href="./core-bridges.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>37.</b> |
| |
| Core Bridges |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="38" data-path="duplicate-detection.html"> |
| |
| |
| <a href="./duplicate-detection.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>38.</b> |
| |
| Duplicate Message Detection |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="39" data-path="clusters.html"> |
| |
| |
| <a href="./clusters.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>39.</b> |
| |
| Clusters |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="40" data-path="ha.html"> |
| |
| |
| <a href="./ha.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>40.</b> |
| |
| High Availability and Failover |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="41" data-path="graceful-shutdown.html"> |
| |
| |
| <a href="./graceful-shutdown.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>41.</b> |
| |
| Graceful Server Shutdown |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="42" data-path="libaio.html"> |
| |
| |
| <a href="./libaio.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>42.</b> |
| |
| Libaio Native Libraries |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="43" data-path="thread-pooling.html"> |
| |
| |
| <a href="./thread-pooling.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>43.</b> |
| |
| Thread management |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="44" data-path="logging.html"> |
| |
| |
| <a href="./logging.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>44.</b> |
| |
| Logging |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="45" data-path="rest.html"> |
| |
| |
| <a href="./rest.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>45.</b> |
| |
| REST Interface |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="46" data-path="embedding-activemq.html"> |
| |
| |
| <a href="./embedding-activemq.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>46.</b> |
| |
| Embedding Apache ActiveMQ Artemis |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="47" data-path="spring-integration.html"> |
| |
| |
| <a href="./spring-integration.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>47.</b> |
| |
| Spring Integration |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="48" data-path="aerogear-integration.html"> |
| |
| |
| <a href="./aerogear-integration.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>48.</b> |
| |
| AeroGear Integration |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="49" data-path="vertx-integration.html"> |
| |
| |
| <a href="./vertx-integration.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>49.</b> |
| |
| VertX Integration |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="50" data-path="intercepting-operations.html"> |
| |
| |
| <a href="./intercepting-operations.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>50.</b> |
| |
| Intercepting Operations |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="51" data-path="protocols-interoperability.html"> |
| |
| |
| <a href="./protocols-interoperability.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>51.</b> |
| |
| Protocols and Interoperability |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="52" data-path="tools.html"> |
| |
| |
| <a href="./tools.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>52.</b> |
| |
| Tools |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="53" data-path="maven-plugin.html"> |
| |
| |
| <a href="./maven-plugin.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>53.</b> |
| |
| Maven Plugin |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="54" data-path="perf-tuning.html"> |
| |
| |
| <a href="./perf-tuning.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>54.</b> |
| |
| Troubleshooting and Performance Tuning |
| </a> |
| |
| |
| |
| </li> |
| |
| <li class="chapter " data-level="55" data-path="configuration-index.html"> |
| |
| |
| <a href="./configuration-index.html"> |
| <i class="fa fa-check"></i> |
| |
| <b>55.</b> |
| |
| Configuration Reference |
| </a> |
| |
| |
| |
| </li> |
| |
| |
| |
| |
| <li class="divider"></li> |
| <li> |
| <a href="https://www.gitbook.com" target="blank" class="gitbook-link"> |
| Published with GitBook |
| </a> |
| </li> |
| |
| </ul> |
| </div> |
| |
| <div class="book-body"> |
| <div class="body-inner"> |
| <div class="book-header"> |
| <!-- Actions Left --> |
| <a href="#" class="btn pull-left toggle-summary" aria-label="Table of Contents"><i class="fa fa-align-justify"></i></a> |
| <a href="#" class="btn pull-left toggle-search" aria-label="Search"><i class="fa fa-search"></i></a> |
| |
| <div id="font-settings-wrapper" class="dropdown pull-left"> |
| <a href="#" class="btn toggle-dropdown" aria-label="Font Settings"><i class="fa fa-font"></i> |
| </a> |
| <div class="dropdown-menu font-settings"> |
| <div class="dropdown-caret"> |
| <span class="caret-outer"></span> |
| <span class="caret-inner"></span> |
| </div> |
| |
| <div class="buttons"> |
| <button type="button" id="reduce-font-size" class="button size-2">A</button> |
| <button type="button" id="enlarge-font-size" class="button size-2">A</button> |
| </div> |
| |
| <div class="buttons font-family-list"> |
| <button type="button" data-font="0" class="button">Serif</button> |
| <button type="button" data-font="1" class="button">Sans</button> |
| </div> |
| |
| <div class="buttons color-theme-list"> |
| <button type="button" id="color-theme-preview-0" class="button size-3" data-theme="0">White</button> |
| <button type="button" id="color-theme-preview-1" class="button size-3" data-theme="1">Sepia</button> |
| <button type="button" id="color-theme-preview-2" class="button size-3" data-theme="2">Night</button> |
| </div> |
| </div> |
| |
| </div> |
| |
| <!-- Actions Right --> |
| |
| <div class="dropdown pull-right"> |
| <a href="#" class="btn toggle-dropdown" aria-label="Share"><i class="fa fa-share-alt"></i> |
| </a> |
| <div class="dropdown-menu font-settings dropdown-left"> |
| <div class="dropdown-caret"> |
| <span class="caret-outer"></span> |
| <span class="caret-inner"></span> |
| </div> |
| <div class="buttons"> |
| <button type="button" data-sharing="twitter" class="button"> |
| Share on Twitter |
| </button> |
| <button type="button" data-sharing="google-plus" class="button"> |
| Share on Google |
| </button> |
| <button type="button" data-sharing="facebook" class="button"> |
| Share on Facebook |
| </button> |
| <button type="button" data-sharing="weibo" class="button"> |
| Share on Weibo |
| </button> |
| <button type="button" data-sharing="instapaper" class="button"> |
| Share on Instapaper |
| </button> |
| </div> |
| </div> |
| </div> |
| |
| |
| |
| <a href="#" target="_blank" class="btn pull-right google-plus-sharing-link sharing-link" data-sharing="google-plus" aria-label="Google"><i class="fa fa-google-plus"></i></a> |
| |
| |
| <a href="#" target="_blank" class="btn pull-right facebook-sharing-link sharing-link" data-sharing="facebook" aria-label="Facebook"><i class="fa fa-facebook"></i></a> |
| |
| |
| <a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="twitter" aria-label="Twitter"><i class="fa fa-twitter"></i></a> |
| |
| |
| |
| |
| |
| <!-- Title --> |
| <h1> |
| <i class="fa fa-circle-o-notch fa-spin"></i> |
| <a href="./" >ActiveMQ Artemis Documentation</a> |
| </h1> |
| </div> |
| |
| <div class="page-wrapper" tabindex="-1"> |
| <div class="page-inner"> |
| |
| |
| <section class="normal" id="section-"> |
| |
| <h1 id="using-core">Using Core</h1> |
| <p>Apache ActiveMQ Artemis core is a completely JMS-agnostic messaging system with its own |
| non-JMS API. We call this the <em>core API</em>.</p> |
| <p>If you don't want to use JMS you can use the core API directly. The core |
| API provides all the functionality of JMS but without much of the |
| complexity. It also provides features that are not available using JMS.</p> |
| <h2 id="core-messaging-concepts">Core Messaging Concepts</h2> |
| <p>Some of the core messaging concepts are similar to JMS concepts, but |
| core messaging concepts differ in some ways. In general the core |
| messaging API is simpler than the JMS API, since we remove distinctions |
| between queues, topics and subscriptions. We'll discuss each of the |
| major core messaging concepts in turn, but to see the API in detail, |
| please consult the Javadoc.</p> |
| <h3 id="message">Message</h3> |
| <ul> |
| <li><p>A message is the unit of data which is sent between clients and |
| servers.</p> |
| </li> |
| <li><p>A message has a body which is a buffer containing convenient methods |
| for reading and writing data into it.</p> |
| </li> |
| <li><p>A message has a set of properties which are key-value pairs. Each |
| property key is a string and property values can be of type integer, |
| long, short, byte, byte[], String, double, float or boolean.</p> |
| </li> |
| <li><p>A message has an <em>address</em> it is being sent to. When the message |
| arrives on the server it is routed to any queues that are bound to |
| the address - if the queues are bound with any filter, the message |
| will only be routed to that queue if the filter matches. An address |
| may have many queues bound to it or even none. There may also be |
| entities other than queues, like <em>diverts</em> bound to addresses.</p> |
| </li> |
| <li><p>Messages can be either durable or non durable. Durable messages in a |
| durable queue will survive a server crash or restart. Non durable |
| messages will never survive a server crash or restart.</p> |
| </li> |
| <li><p>Messages can be specified with a priority value between 0 and 9. 0 |
| represents the lowest priority and 9 represents the highest. |
| Apache ActiveMQ Artemis will attempt to deliver higher priority messages before |
| lower priority ones.</p> |
| </li> |
| <li><p>Messages can be specified with an optional expiry time. Apache ActiveMQ Artemis |
| will not deliver messages after its expiry time has been exceeded.</p> |
| </li> |
| <li><p>Messages also have an optional timestamp which represents the time |
| the message was sent.</p> |
| </li> |
| <li><p>Apache ActiveMQ Artemis also supports the sending/consuming of very large messages |
| much larger than can fit in available RAM at any one time.</p> |
| </li> |
| </ul> |
| <h3 id="address">Address</h3> |
| <p>A server maintains a mapping between an address and a set of queues. |
| Zero or more queues can be bound to a single address. Each queue can be |
| bound with an optional message filter. When a message is routed, it is |
| routed to the set of queues bound to the message's address. If any of |
| the queues are bound with a filter expression, then the message will |
| only be routed to the subset of bound queues which match that filter |
| expression.</p> |
| <p>Other entities, such as <em>diverts</em> can also be bound to an address and |
| messages will also be routed there.</p> |
| <blockquote> |
| <p><strong>Note</strong></p> |
| <p>In core, there is no concept of a Topic, Topic is a JMS only term. |
| Instead, in core, we just deal with <em>addresses</em> and <em>queues</em>.</p> |
| <p>For example, a JMS topic would be implemented by a single address to |
| which many queues are bound. Each queue represents a subscription of |
| the topic. A JMS Queue would be implemented as a single address to |
| which one queue is bound - that queue represents the JMS queue.</p> |
| </blockquote> |
| <h3 id="queue">Queue</h3> |
| <p>Queues can be durable, meaning the messages they contain survive a |
| server crash or restart, as long as the messages in them are durable. |
| Non durable queues do not survive a server restart or crash even if the |
| messages they contain are durable.</p> |
| <p>Queues can also be temporary, meaning they are automatically deleted |
| when the client connection is closed, if they are not explicitly deleted |
| before that.</p> |
| <p>Queues can be bound with an optional filter expression. If a filter |
| expression is supplied then the server will only route messages that |
| match that filter expression to any queues bound to the address.</p> |
| <p>Many queues can be bound to a single address. A particular queue is only |
| bound to a maximum of one address.</p> |
| <h3 id="serverlocator">ServerLocator</h3> |
| <p>Clients use <code>ServerLocator</code> instances to create <code>ClientSessionFactory</code> |
| instances. <code>ServerLocator</code> instances are used to locate servers and |
| create connections to them.</p> |
| <p>In JMS terms think of a <code>ServerLocator</code> in the same way you would a JMS |
| Connection Factory.</p> |
| <p><code>ServerLocator</code> instances are created using the <code>ActiveMQClient</code> factory |
| class.</p> |
| <h3 id="clientsessionfactory">ClientSessionFactory</h3> |
| <p>Clients use <code>ClientSessionFactory</code> instances to create <code>ClientSession</code> |
| instances. <code>ClientSessionFactory</code> instances are basically the connection |
| to a server</p> |
| <p>In JMS terms think of them as JMS Connections.</p> |
| <p><code>ClientSessionFactory</code> instances are created using the <code>ServerLocator</code> |
| class.</p> |
| <h3 id="clientsession">ClientSession</h3> |
| <p>A client uses a ClientSession for consuming and producing messages and |
| for grouping them in transactions. ClientSession instances can support |
| both transactional and non transactional semantics and also provide an |
| <code>XAResource</code> interface so messaging operations can be performed as part |
| of a |
| <a href="http://www.oracle.com/technetwork/java/javaee/tech/jta-138684.html" target="_blank">JTA</a> |
| transaction.</p> |
| <p>ClientSession instances group ClientConsumers and ClientProducers.</p> |
| <p>ClientSession instances can be registered with an optional |
| <code>SendAcknowledgementHandler</code>. This allows your client code to be |
| notified asynchronously when sent messages have successfully reached the |
| server. This unique Apache ActiveMQ Artemis feature, allows you to have full guarantees |
| that sent messages have reached the server without having to block on |
| each message sent until a response is received. Blocking on each |
| messages sent is costly since it requires a network round trip for each |
| message sent. By not blocking and receiving send acknowledgements |
| asynchronously you can create true end to end asynchronous systems which |
| is not possible using the standard JMS API. For more information on this |
| advanced feature please see the section [Guarantees of sends and commits]{send-guarantees.md).</p> |
| <h3 id="clientconsumer">ClientConsumer</h3> |
| <p>Clients use <code>ClientConsumer</code> instances to consume messages from a queue. |
| Core Messaging supports both synchronous and asynchronous message |
| consumption semantics. <code>ClientConsumer</code> instances can be configured with |
| an optional filter expression and will only consume messages which match |
| that expression.</p> |
| <h3 id="clientproducer">ClientProducer</h3> |
| <p>Clients create <code>ClientProducer</code> instances on <code>ClientSession</code> instances |
| so they can send messages. ClientProducer instances can specify an |
| address to which all sent messages are routed, or they can have no |
| specified address, and the address is specified at send time for the |
| message.</p> |
| <blockquote> |
| <p><strong>Warning</strong></p> |
| <p>Please note that ClientSession, ClientProducer and ClientConsumer |
| instances are <em>designed to be re-used</em>.</p> |
| <p>It's an anti-pattern to create new ClientSession, ClientProducer and |
| ClientConsumer instances for each message you produce or consume. If |
| you do this, your application will perform very poorly. This is |
| discussed further in the section on performance tuning <a href="perf-tuning.html">Performance Tuning</a>.</p> |
| </blockquote> |
| <h2 id="a-simple-example-of-using-core">A simple example of using Core</h2> |
| <p>Here's a very simple program using the core messaging API to send and |
| receive a message. Logically it's comprised of two sections: firstly |
| setting up the producer to write a message to an <em>addresss</em>, and |
| secondly, creating a <em>queue</em> for the consumer, creating the consumer and |
| <em>starting</em> it.</p> |
| <pre><code class="lang-java">ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(<span class="hljs-keyword">new</span> TransportConfiguration( |
| InVMConnectorFactory.class.getName())); |
| |
| <span class="hljs-comment">// In this simple example, we just use one session for both producing and receiving</span> |
| |
| ClientSessionFactory factory = locator.createClientSessionFactory(); |
| ClientSession session = factory.createSession(); |
| |
| <span class="hljs-comment">// A producer is associated with an address ...</span> |
| |
| ClientProducer producer = session.createProducer(<span class="hljs-string">"example"</span>); |
| ClientMessage message = session.createMessage(<span class="hljs-keyword">true</span>); |
| message.getBodyBuffer().writeString(<span class="hljs-string">"Hello"</span>); |
| |
| <span class="hljs-comment">// We need a queue attached to the address ...</span> |
| |
| session.createQueue(<span class="hljs-string">"example"</span>, <span class="hljs-string">"example"</span>, <span class="hljs-keyword">true</span>); |
| |
| <span class="hljs-comment">// And a consumer attached to the queue ...</span> |
| |
| ClientConsumer consumer = session.createConsumer(<span class="hljs-string">"example"</span>); |
| |
| <span class="hljs-comment">// Once we have a queue, we can send the message ...</span> |
| |
| producer.send(message); |
| |
| <span class="hljs-comment">// We need to start the session before we can -receive- messages ...</span> |
| |
| session.start(); |
| ClientMessage msgReceived = consumer.receive(); |
| |
| System.out.println(<span class="hljs-string">"message = "</span> + msgReceived.getBodyBuffer().readString()); |
| |
| session.close(); |
| </code></pre> |
| |
| |
| </section> |
| |
| |
| </div> |
| </div> |
| </div> |
| |
| |
| <a href="./using-jms.html" class="navigation navigation-prev " aria-label="Previous page: Using JMS"><i class="fa fa-angle-left"></i></a> |
| |
| |
| <a href="./jms-core-mapping.html" class="navigation navigation-next " aria-label="Next page: Mapping JMS Concepts to the Core API"><i class="fa fa-angle-right"></i></a> |
| |
| </div> |
| </div> |
| |
| |
| <script src="gitbook/app.js"></script> |
| |
| <script> |
| require(["gitbook"], function(gitbook) { |
| var config = {"fontSettings":{"theme":null,"family":"sans","size":2}}; |
| gitbook.start(config); |
| }); |
| </script> |
| |
| |
| </body> |
| |
| </html> |