blob: c1f6473a2346dd6474e9bc4fe46d667cd9a5e596 [file] [log] [blame]
<!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> &gt; <a href="containers">Containers</a> &gt; <a href="jboss-integration">JBoss Integration</a> &gt; <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&amp;modificationDate=1117021488000&amp;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&amp;modificationDate=1117021488000&amp;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>&lt;message-driven&gt;
...
&lt;ejb-name&gt;TopicDurableMDB&lt;/ejb-name&gt;
&lt;ejb-class&gt;com.panacya.platform.service.bus.mdb.SimpleMessageReceiverBean&lt;/ejb-class&gt;
&lt;messaging-type&gt;javax.jms.MessageListener&lt;/messaging-type&gt;
...
&lt;activation-config&gt;
&lt;activation-config-property&gt;
&lt;activation-config-property-name&gt;Destination&lt;/activation-config-property-name&gt;
&lt;activation-config-property-value&gt;topic.testTopic&lt;/activation-config-property-value&gt;
&lt;/activation-config-property&gt;
&lt;activation-config-property&gt;
&lt;activation-config-property-name&gt;DestinationType&lt;/activation-config-property-name&gt;
&lt;activation-config-property-value&gt;javax.jms.Topic&lt;/activation-config-property-value&gt;
&lt;/activation-config-property&gt;
...
&lt;/activation-config&gt;
...
&lt;/message-driven&gt;
</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>&lt;inbound-resourceadapter&gt;
...
&lt;activationspec&gt;
&lt;activationspec-class&gt;org.activemq.ra.ActiveMQActivationSpec&lt;/activationspec-class&gt;
&lt;required-config-property&gt;
&lt;config-property-name&gt;Destination&lt;/config-property-name&gt;
&lt;/required-config-property&gt;
&lt;required-config-property&gt;
&lt;config-property-name&gt;DestinationType&lt;/config-property-name&gt;
&lt;/required-config-property&gt;
&lt;/activationspec&gt;
...
&lt;/inbound-resourceadapter&gt;
</code></pre></div></div>
<p>In the <a href="inbound-communication.data/ejb-jar.xml?version=3&amp;modificationDate=1117021488000&amp;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&amp;modificationDate=1117021488000&amp;api=v2">jboss.xml</a> file.</p>
<p>Three things are needed in the <a href="inbound-communication.data/jboss.xml?version=3&amp;modificationDate=1117021488000&amp;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>&lt;invoker-proxy-binding&gt;
&lt;name&gt;activemq-message-driven-bean&lt;/name&gt;
&lt;invoker-mbean&gt;default&lt;/invoker-mbean&gt;
&lt;proxy-factory&gt;org.jboss.ejb.plugins.inflow.JBossMessageEndpointFactory&lt;/proxy-factory&gt;
...
&lt;/invoker-proxy-binding&gt;
</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>&lt;container-configuration&gt;
&lt;container-name&gt;ActiveMQ Classic Message Driven Bean&lt;/container-name&gt;
&lt;call-logging&gt;false&lt;/call-logging&gt;
&lt;invoker-proxy-binding-name&gt;activemq-message-driven-bean&lt;/invoker-proxy-binding-name&gt;
...
&lt;/container-configuration&gt;
</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>&lt;message-driven&gt;
&lt;ejb-name&gt;TopicDurableMDB&lt;/ejb-name&gt;
&lt;resource-adapter-name&gt;activemq-ra-1.2-SNAPSHOT.rar&lt;/resource-adapter-name&gt;
&lt;configuration-name&gt;ActiveMQ Classic Message Driven Bean&lt;/configuration-name&gt;
&lt;/message-driven&gt;
</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&amp;modificationDate=1117021355000&amp;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 &copy; 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>