| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> |
| <title>ActiveMQ</title> |
| <link rel="icon" type="image/png" href="/assets/img/favicon.png"> |
| |
| <link rel="stylesheet" href="/css/main.css"> |
| <script defer src="/js/fontawesome-all.min.js" integrity="sha384-rOA1PnstxnOBLzCLMcre8ybwbTmemjzdNlILg8O7z1lUkLXozs4DHonlDtnE7fpc"></script> |
| <script src="/js/jquery.slim.min.js" integrity="sha384-5AkRS45j4ukf+JbWAfHL8P4onPA9p0KwwP7pUdjSQA3ss9edbJUJc/XcYAiheSSz"></script> |
| <script src="/js/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"></script> |
| <script src="/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"></script> |
| </head> |
| |
| <body> |
| <nav class="navbar navbar-expand-lg navbar-light fixed-top"> |
| <div class="container"> |
| <!-- <a class="navbar-brand mr-auto" href="#"><img style="height: 50px" src="assets/img/apache-feather.png" /></a> --> |
| <a class="navbar-brand mr-auto" href="/"><img src="/assets/img/activemq_logo_black_small.png" style="height: 50px"/></a> |
| <button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbarContent" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation"> |
| <span class="navbar-toggler-icon"></span> |
| </button> |
| |
| <div class="ml-auto collapse navbar-collapse" id="navbarContent"> |
| <ul class="navbar-nav ml-auto"> |
| <li class="nav-item"> |
| <a class="nav-link active" href="/news">News</a> |
| </li> |
| <li class="nav-item dropdown"> |
| <a class="nav-link" id="navbarDropdownComponents" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Components<span class="caret"></span></a> |
| <ul class="dropdown-menu dropdown-menu-center" aria-labelledby="navbarDropdownComponents"> |
| <div class="row"> |
| <div class="col-12"> |
| <ul class="multi-column-dropdown"> |
| <li class="nav-item"><a class="dropdown-item" href="/components/classic">ActiveMQ Classic</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/components/artemis/">ActiveMQ Artemis</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/components/nms">NMS Clients</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/components/cms">CMS Client</a></li> |
| </ul> |
| </div> |
| </div> |
| </ul> |
| </li> |
| <li class="nav-item dropdown"> |
| <a class="nav-link" id="navbarDropdownCommunity" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Community<span class="caret"></span></a> |
| <ul class="dropdown-menu dropdown-menu-center multi-column columns-1" aria-labelledby="navbarDropdownCommunity"> |
| <div class="row"> |
| <div class="col-12"> |
| <ul class="multi-column-dropdown"> |
| <li class="nav-item"><a class="dropdown-item" href="/contact">Contact Us</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/contributing">Contribute</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/issues">Report Issues</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/support">Get Support</a></li> |
| </ul> |
| </div> |
| </div> |
| </ul> |
| </li> |
| <li class="nav-item dropdown"> |
| <a class="nav-link" id="navbarDropdownTeam" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><img src="/assets/img/feather.png" style="height:20px">Apache<span class="caret"></span></a> |
| <ul class="dropdown-menu dropdown-menu-center multi-column columns-1" aria-labelledby="navbarDropdownTeam"> |
| <div class="row"> |
| <div class="col-sm-12"> |
| <ul class="multi-column-dropdown"> |
| <li class="nav-item"><a class="dropdown-item" href="https://www.apache.org">The Apache Software Foundation</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/licenses/">License</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/foundation/thanks.html">Thanks</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/security-advisories">Security</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/events/current-event">Events</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="https://people.apache.org/phonebook.html?pmc=activemq">PMC & Committers</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="https://whimsy.apache.org/board/minutes/ActiveMQ.html">Board Reports</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy Policy</a></li> |
| </ul> |
| </div> |
| </div> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </nav> |
| |
| <div class="content"> |
| <div class="page-title-classic"> |
| <div class="container"> |
| <h1>Inbound Communication</h1> |
| </div> |
| </div> |
| <div class="container" > |
| <div class="row" style="margin-top: 30px"> |
| <div class="col-12 classic"> |
| <p><a href="connectivity">Connectivity</a> > <a href="containers">Containers</a> > <a href="jboss-integration">JBoss Integration</a> > <a href="inbound-communication">Inbound Communication</a></p> |
| |
| <h2 id="configuring-an-mdb-to-receive-messages-from-activemq-classic">Configuring an MDB to receive messages from ActiveMQ Classic</h2> |
| |
| <p>There are three MDBs declared in the <a href="inbound-communication.data/ejb-jar.xml?version=3&modificationDate=1117021488000&api=v2">ejb-jar.xml</a> deployment descriptor. For this example, I will be explaining how to configure the <code class="language-plaintext highlighter-rouge">TopicDurableMDB</code> to be invoked by JBoss when a message is received on an ActiveMQ Classic Topic.</p> |
| |
| <h3 id="the-bean">The Bean</h3> |
| |
| <p>In the <a href="inbound-communication.data/ejb-jar.xml?version=3&modificationDate=1117021488000&api=v2">ejb-jar.xml</a> deployment descriptor, the <code class="language-plaintext highlighter-rouge">TopicDurableMDB</code> is declared as follows:</p> |
| |
| <p><strong>ejb-jar.xml</strong></p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code><message-driven> |
| ... |
| <ejb-name>TopicDurableMDB</ejb-name> |
| <ejb-class>com.panacya.platform.service.bus.mdb.SimpleMessageReceiverBean</ejb-class> |
| <messaging-type>javax.jms.MessageListener</messaging-type> |
| ... |
| <activation-config> |
| <activation-config-property> |
| <activation-config-property-name>Destination</activation-config-property-name> |
| <activation-config-property-value>topic.testTopic</activation-config-property-value> |
| </activation-config-property> |
| <activation-config-property> |
| <activation-config-property-name>DestinationType</activation-config-property-name> |
| <activation-config-property-value>javax.jms.Topic</activation-config-property-value> |
| </activation-config-property> |
| ... |
| </activation-config> |
| ... |
| </message-driven> |
| </code></pre></div></div> |
| <p>The <code class="language-plaintext highlighter-rouge">activation-config</code> element and it’s child element, <code class="language-plaintext highlighter-rouge">activation-config-property</code>, are new elements for EJBs, so you might not be familiar with them. I won’t go into to much detail about them, but it is important to understand that this is the first mechanism you use to link an MDB to a JCA.</p> |
| |
| <h3 id="the-connector">The Connector</h3> |
| |
| <p>The two <code class="language-plaintext highlighter-rouge">activation-config-properties</code> shown above link to the following elements in the <a href="http://activemq.codehaus.org/checkout/activemq/modules/ra/src/rar/META-INF/ra.xml">ra.xml</a> file, which is contained within the <a href="jboss-integration">activemq-ra-1.2.rar</a> file:</p> |
| |
| <p><strong>ra.xml</strong></p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code><inbound-resourceadapter> |
| ... |
| <activationspec> |
| <activationspec-class>org.activemq.ra.ActiveMQActivationSpec</activationspec-class> |
| <required-config-property> |
| <config-property-name>Destination</config-property-name> |
| </required-config-property> |
| <required-config-property> |
| <config-property-name>DestinationType</config-property-name> |
| </required-config-property> |
| </activationspec> |
| ... |
| </inbound-resourceadapter> |
| </code></pre></div></div> |
| <p>In the <a href="inbound-communication.data/ejb-jar.xml?version=3&modificationDate=1117021488000&api=v2">ejb-jar.xml</a> file section shown above, the value of the <code class="language-plaintext highlighter-rouge">Destination</code> property is set to <code class="language-plaintext highlighter-rouge">topic.testTopic</code>. This value is the physical name of the ActiveMQ Classic destination the <code class="language-plaintext highlighter-rouge">TopicDurableMDB</code> will be receiving messages from and not a JNDI name. In other words, the value of the <code class="language-plaintext highlighter-rouge">Destination</code> property has no meaning to JBoss. It is purely an ActiveMQ Classic setting.</p> |
| |
| <h3 id="the-glue">The Glue</h3> |
| |
| <p>In JBoss, the thing which connects an inbound JMS destination to an MDB is a JBoss container. To use ActiveMQ Classic as the inbound message source for the <code class="language-plaintext highlighter-rouge">TopicDurableMDB</code> we must configure a new JBoss container. We do this in the <a href="inbound-communication.data/jboss.xml?version=3&modificationDate=1117021488000&api=v2">jboss.xml</a> file.</p> |
| |
| <p>Three things are needed in the <a href="inbound-communication.data/jboss.xml?version=3&modificationDate=1117021488000&api=v2">jboss.xml</a> file in order to tie an MDB to a connector. They are:</p> |
| |
| <ol> |
| <li>Configure a new <code class="language-plaintext highlighter-rouge">invoker-proxy-binding</code> that declares <code class="language-plaintext highlighter-rouge">JBossMessageEndpointFactory</code> as the <code class="language-plaintext highlighter-rouge">proxy-factory</code></li> |
| <li>Configure a new MDB container which uses the new <code class="language-plaintext highlighter-rouge">invoker-proxy-binding</code></li> |
| <li>Declare which MDBs should go into the new container</li> |
| </ol> |
| |
| <p>This first snippet configures a new <code class="language-plaintext highlighter-rouge">invoker-proxy-binding</code>:</p> |
| |
| <p><strong>jboss.xml – invoker-proxy-binding</strong></p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code><invoker-proxy-binding> |
| <name>activemq-message-driven-bean</name> |
| <invoker-mbean>default</invoker-mbean> |
| <proxy-factory>org.jboss.ejb.plugins.inflow.JBossMessageEndpointFactory</proxy-factory> |
| ... |
| </invoker-proxy-binding> |
| </code></pre></div></div> |
| <p>This second snippet configures a new MDB container which uses the <code class="language-plaintext highlighter-rouge">invoker-proxy-binding</code> configured above:</p> |
| |
| <p><strong>jboss.xml – container-configuration</strong></p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code><container-configuration> |
| <container-name>ActiveMQ Classic Message Driven Bean</container-name> |
| <call-logging>false</call-logging> |
| <invoker-proxy-binding-name>activemq-message-driven-bean</invoker-proxy-binding-name> |
| ... |
| </container-configuration> |
| </code></pre></div></div> |
| <p>This third snippet links the <code class="language-plaintext highlighter-rouge">TopicDurableMDB</code> to the <a href="jboss-integration">activemq-ra-1.2.rar</a> connector and tells JBoss to put instances of <code class="language-plaintext highlighter-rouge">TopicDurableMDB</code> into the new MDB container declared above:</p> |
| |
| <p><strong>jboss.xml – TopicDurableMDB</strong></p> |
| <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code><message-driven> |
| <ejb-name>TopicDurableMDB</ejb-name> |
| <resource-adapter-name>activemq-ra-1.2-SNAPSHOT.rar</resource-adapter-name> |
| <configuration-name>ActiveMQ Classic Message Driven Bean</configuration-name> |
| </message-driven> |
| </code></pre></div></div> |
| <p>The above examples highlight the key configuration settings needed to enable MDBs deployed in JBoss to process messages from an ActiveMQ Classic destination.</p> |
| |
| <p>You can try the above example, plus a few more, by downloading the <a href="inbound-communication.data/activemq-jboss-test.zip?version=3&modificationDate=1117021355000&api=v2">activemq-jboss-test.zip</a> file which contains the complete sample project.</p> |
| |
| |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="row sitemap"> |
| <div class="col-sm-12"> |
| <div class="container"> |
| <div class="row"> |
| <div class="col-sm-12"> |
| <div class="row"> |
| <div class="col-sm-3"> |
| <div > |
| <img class="float-left" style="max-height: 100px" src="/assets/img/activemq_logo_white_vertical_small.png"/> |
| </div> |
| </div> |
| <div style="text-align: center; margin-bottom: 0px; margin-top: 30px; font-size: 65%" class="col-sm-6"> |
| <p><a href="https://www.apache.org/foundation/marks/list/">Apache, ActiveMQ, Apache ActiveMQ</a>, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. Copyright © 2024, The Apache Software Foundation. Licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p> |
| </div> |
| <div class="col-sm-3"> |
| <div > |
| <a href="https://www.apache.org"><img class="float-right" style="margin-top: 10px; max-height: 80px" src="/assets/img/apache-logo-small.png"/></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| </body> |
| </html> |