<?xml version="1.0" encoding="UTF-8"?>

<rss version='2.0'
     xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">
    <channel>
        <!-- This XML Feed shows details for the page Ben Hale&#039;s Blog -->
        <creativeCommons:license>http://creativecommons.org/licenses/by-sa/2.5/
          </creativeCommons:license>
        <title>Ben Hale&#039;s Blog</title>
        <description>&lt;p&gt;Musings from Spring&amp;#8217;s front lines&lt;/p&gt;
</description>
                <category>Spring</category>

        <pubDate>Mon, 08 May 2006 17:29:31 -0700</pubDate>
        <lastBuildDate>Mon, 08 May 2006 17:29:31 -0700</lastBuildDate>
            
        <item>
            <title>Moving to the Interface21 team blog</title>
            <link>http://swik.net/Spring/Ben+Hale%27s+Blog/Moving+to+the+Interface21+team+blog/icqd</link>
            <description>&lt;p&gt;As part of an ongoing effort to better brand Interface21 as a company, I&amp;#8217;m deprecating my individual company blog and moving to the Interface21 team blog.  You&amp;#8217;ll find it at &lt;a href=&quot;http://blog.interface21.com&quot;&gt;http://blog.interface21.com&lt;/a&gt;.  All of my currently existing posts are there and I&amp;#8217;ll be posting from there very shortly.&lt;/p&gt;
&lt;p&gt;I realize that this may mean some updates to RSS feeds in the like, but I think it provides a much greater value and simply listening to my ramblings.  In addition to me you&amp;#8217;ll have the likes of Keith Donald, Colin Sampaleanu, Mark Fisher, and the rest of the Interface21 staff posting and generally improving the community.&lt;/p&gt;
&lt;p&gt;Again, sorry for the inconvience, but I&amp;#8217;m pretty sure you&amp;#8217;ll be happier in the end.
&lt;/p&gt;
</description>
            
            <pubDate>Tue, 01 Aug 2006 09:02:33 -0700</pubDate>
        </item>
            
        <item>
            <title>Atlanta DevCon 2006</title>
            <link>http://swik.net/Spring/Ben+Hale%27s+Blog/Atlanta+DevCon+2006/d5gz</link>
            <description>&lt;p&gt;I just got finished with my &lt;i&gt;Spring 2.0: New and Noteworthy&lt;/i&gt; talk at Atlanta DevCon 2006.  Let me be the first to say that the conference was great.  The site and organizers were all top notch.  I&amp;#8217;d like to give a special shout-out to Burr Sutter for putting on one heck of a conference.  You know that things are going well when the conference center doesn&amp;#8217;t have a wireless network but you can get the one from the cafe next door.  That&amp;#8217;s good karma!  The JUG members were all very knowledgeable (even the ones that didn&amp;#8217;t know about Spring) and asked great questions.  I fielded questions about EJB 3, JPA, ESB, Spring learning curves, Java 5, and Spring Web Flow; every one a great question.&lt;/p&gt;
&lt;p&gt;For those of you that weren&amp;#8217;t able to make it, I&amp;#8217;m posting the slides from that talk in a couple of formats.  I&amp;#8217;ve decided to post the &lt;a href=&quot;http://blog.springframework.com/benh/wp-content/uploads/2006/05/Atlanta%20DevCon%202006.zip&quot;&gt;Keynote&lt;/a&gt; file for all you fellow Mac users out there as well as &lt;a href=&quot;http://blog.springframework.com/benh/wp-content/uploads/2006/05/Atlanta%20DevCon%202006.pdf&quot;&gt;PDFs&lt;/a&gt; and the very cool &lt;a href=&quot;http://blog.springframework.com/benh/wp-content/uploads/2006/05/Atlanta%20DevCon%202006.html&quot;&gt;exported HTML&lt;/a&gt; that Keynote creates.&lt;/p&gt;
&lt;p&gt;Feel free to use the comments to ask me about some of the new and noteworthy features of Spring 2.0.
&lt;/p&gt;
</description>
            
            <pubDate>Thu, 25 May 2006 23:54:57 -0700</pubDate>
        </item>
            
        <item>
            <title>Message Flow Tracing with AspectJ and JMX</title>
            <link>http://swik.net/Spring/Ben+Hale%27s+Blog/Message+Flow+Tracing+with+AspectJ+and+JMX/die9</link>
            <description>&lt;p&gt;In a project that I used to work on we had a system that would receive messages from a device and make decisions on whether that information would be passed to the user.  There were multiple decision levels and one of the problems we always found ourselves asking was if a message was being lost on it&amp;#8217;s way through the system.&lt;/p&gt;
&lt;p&gt;Before we moved to Spring, it was nearly impossible to tell the answer to that question.  Attempts were made to use logging, but the sheer volume of messages that decisions were made on made it tedious at best.  Other attempts were made using debuggers but a combination of the volume and the timing changes led to only intermittent success.&lt;/p&gt;
&lt;p&gt;Unfortunately I left before we could implement a more suitable solution but if I had, here is what it probably would have been like.  At the end I&amp;#8217;ll discuss some of the extensions that might be useful in this kind of effort.&lt;/p&gt;
&lt;p&gt;To start, we&amp;#8217;ve got a set of interfaces and their implementations:&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package flowtracingexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;interface&lt;/span&gt; Component1 &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; forwardCall&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package flowtracingexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;co2&quot;&gt;import java.util.Random;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; DefaultComponent1 &lt;span class=&quot;kw2&quot;&gt;implements&lt;/span&gt; Component1 &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; Component2 child;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3ARandom+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;Random&lt;/span&gt;&lt;/a&gt; r = &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3ARandom+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;Random&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; DefaultComponent1&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Component2 child&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;child&lt;/span&gt; = child;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; forwardCall&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;r.&lt;span class=&quot;me1&quot;&gt;nextBoolean&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; child.&lt;span class=&quot;me1&quot;&gt;forwardCall&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package flowtracingexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;interface&lt;/span&gt; Component2 &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; forwardCall&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package flowtracingexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;co2&quot;&gt;import java.util.Random;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; DefaultComponent2 &lt;span class=&quot;kw2&quot;&gt;implements&lt;/span&gt; Component2 &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; Component3 child;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3ARandom+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;Random&lt;/span&gt;&lt;/a&gt; r = &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3ARandom+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;Random&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; DefaultComponent2&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Component3 child&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;child&lt;/span&gt; = child;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; forwardCall&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;r.&lt;span class=&quot;me1&quot;&gt;nextBoolean&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; child.&lt;span class=&quot;me1&quot;&gt;forwardCall&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package flowtracingexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;interface&lt;/span&gt; Component3 &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; forwardCall&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package flowtracingexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; DefaultComponent3 &lt;span class=&quot;kw2&quot;&gt;implements&lt;/span&gt; Component3 &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; forwardCall&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This is a very simple example, but the gist is that using the &lt;span style=&quot;font-family:courier&quot;&gt;fowardCall()&lt;/span&gt; method messages are passed 50% of the time to the next child component (ascending numerical order in this case).  Note that there is no logic involving tracing in these POJOs.&lt;/p&gt;
&lt;p&gt;To implement our tracing behaviors, we&amp;#8217;d like to have a set of counters; one for each component.  In addition we&amp;#8217;d like ways to reset the counters, start and stop monitoring, and determine if monitoring is happening.  To do this we implement a class with the counters.&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package flowtracingexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;co2&quot;&gt;import org.springframework.jmx.export.annotation.ManagedAttribute;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;co2&quot;&gt;import org.springframework.jmx.export.annotation.ManagedOperation;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;co2&quot;&gt;import org.springframework.jmx.export.annotation.ManagedResource;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;@ManagedResource&lt;br/&gt;
&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; FlowTracer &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;long&lt;/span&gt; component1Count = &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;long&lt;/span&gt; component2Count = &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;long&lt;/span&gt; component3Count = &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;boolean&lt;/span&gt; tracing = &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; @ManagedAttribute&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;long&lt;/span&gt; getComponent1Count&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;component1Count&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; @ManagedAttribute&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;long&lt;/span&gt; getComponent2Count&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;component2Count&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; @ManagedAttribute&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;long&lt;/span&gt; getComponent3Count&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;component3Count&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; @ManagedAttribute&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;boolean&lt;/span&gt; getTracing&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tracing&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; incrementComponent1Count&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tracing&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; component1Count++;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; incrementComponent2Count&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tracing&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; component2Count++;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; incrementComponent3Count&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;tracing&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; component3Count++;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; @ManagedOperation&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; resetAllComponentCount&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; resetComponent1Count&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; resetComponent2Count&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; resetComponent3Count&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; @ManagedOperation&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; resetComponent1Count&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;component1Count&lt;/span&gt; = &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; @ManagedOperation&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; resetComponent2Count&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;component2Count&lt;/span&gt; = &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; @ManagedOperation&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; resetComponent3Count&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;component3Count&lt;/span&gt; = &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; @ManagedOperation&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; startTracing&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; tracing = &lt;span class=&quot;kw2&quot;&gt;true&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; @ManagedOperation&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; stopTracing&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; tracing = &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The methods and their contents are pretty straight forward for this class.  What may be new to you are the annotations on this class.  These annotations are used by Spring&amp;#8217;s JMX support to automatically build up MBean management interfaces when each bean is deployed to the JMX MBeanServer.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/jmx/export/annotation/ManagedResource.html&quot; style=&quot;font-family:courier&quot;&gt;ManagedResource&lt;/a&gt;: Declares that this class should be exposed as a JMX MBean
&lt;li&gt;&lt;a href=&quot;http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/jmx/export/annotation/ManagedAttribute.html&quot; style=&quot;font-family:courier&quot;&gt;ManagedAttribute&lt;/a&gt;: Declares that the JavaBean property represented by this getter/setter should be a MBean attribute.  You need to annotate both the getter and setter if you want read and write access to this attribute.
&lt;li&gt;&lt;a href=&quot;http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/jmx/export/annotation/ManagedOperation.html&quot; style=&quot;font-family:courier&quot;&gt;ManagedOperation&lt;/a&gt;: Declares that this method should be exposed as an MBean operation
&lt;/ul&gt;
&lt;p&gt;Finally it&amp;#8217;s a matter of wiring the whole thing together.  First, we wire together the components that make up the flow.  Next we declare the aspects that will put the tracer on each of the components.  In this case we are using the very sweet AspectJ pointcut language.  Finally we setup the JMX exporter to autodetect instances of classes that have the &lt;span style=&quot;font-family:courier&quot;&gt;@ManagedResource&lt;/span&gt; annotation on them.&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;&lt;/span&gt;?xml &lt;span class=&quot;re0&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;1.0&amp;#8243;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;UTF-8&amp;#8243;&lt;/span&gt;?&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;xmlns&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;http://www.springframework.org/schema/beans&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; xmlns:&lt;span class=&quot;re0&quot;&gt;xsi&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;http://www.w3.org/2001/XMLSchema-instance&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; xmlns:&lt;span class=&quot;re0&quot;&gt;aop&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;http://www.springframework.org/schema/aop&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; xsi:&lt;span class=&quot;re0&quot;&gt;schemaLocation&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;http://www.springframework.org/schema/beans&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160;http://www.springframework.org/schema/beans/spring-beans.xsd&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160;http://www.springframework.org/schema/aop &lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160;http://www.springframework.org/schema/aop/spring-aop.xsd&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;coMULTI&quot;&gt;&amp;lt;!&amp;#8211; Components &amp;#8211;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;component3&amp;#8243;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;flowtracingexample.DefaultComponent3&amp;#8243;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;component2&amp;#8243;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;flowtracingexample.DefaultComponent2&amp;#8243;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;constructor&lt;/span&gt;-arg &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;component3&amp;#8243;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/bean&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;component1&amp;#8243;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;flowtracingexample.DefaultComponent1&amp;#8243;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;constructor&lt;/span&gt;-arg &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;component2&amp;#8243;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/bean&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;coMULTI&quot;&gt;&amp;lt;!&amp;#8211; Aspect &amp;#8211;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;flowTracer&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;flowtracingexample.FlowTracer&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;aop&lt;/span&gt;:config&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;aop&lt;/span&gt;:aspect &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;component1Aspect&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;flowTracer&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;aop&lt;/span&gt;:before &lt;span class=&quot;re0&quot;&gt;method&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;incrementComponent1Count&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;pointcut&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;execution(public void flowtracingexample.Component1.forwardCall())&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/aop&lt;/span&gt;:aspect&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;aop&lt;/span&gt;:aspect &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;component2Aspect&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;flowTracer&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;aop&lt;/span&gt;:before &lt;span class=&quot;re0&quot;&gt;method&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;incrementComponent2Count&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;pointcut&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;execution(public void flowtracingexample.Component2.forwardCall())&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/aop&lt;/span&gt;:aspect&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;aop&lt;/span&gt;:aspect &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;component3Aspect&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;flowTracer&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;aop&lt;/span&gt;:before &lt;span class=&quot;re0&quot;&gt;method&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;incrementComponent3Count&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;pointcut&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;execution(public void flowtracingexample.Component3.forwardCall())&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/aop&lt;/span&gt;:aspect&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/aop&lt;/span&gt;:config&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;coMULTI&quot;&gt;&amp;lt;!&amp;#8211; JMX &amp;#8211;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;org.springframework.jmx.export.MBeanExporter&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;autodetectModeName&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;value&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;AUTODETECT_ALL&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;assembler&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;attributeSource&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/property&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/bean&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/property&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;namingStrategy&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;org.springframework.jmx.export.naming.IdentityNamingStrategy&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/property&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/bean&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/beans&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The next things that we need to do is have a driver class.  In this case the driver class just sends a message at some random delay under 750ms.&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package flowtracingexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;co2&quot;&gt;import java.io.IOException;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;co2&quot;&gt;import java.util.Random;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;co2&quot;&gt;import org.springframework.context.ApplicationContext;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;co2&quot;&gt;import org.springframework.context.support.ClassPathXmlApplicationContext;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; FlowTracingExample &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;String&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;throws&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3AInterruptedException+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;InterruptedException&lt;/span&gt;&lt;/a&gt;,&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;IOException&lt;/span&gt;&lt;/a&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; ApplicationContext ctx = &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; ClassPathXmlApplicationContext&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;st0&quot;&gt;&amp;#8220;classpath:flowtracingexample/applicationContext.xml&amp;#8221;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Component1 comp = &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Component1&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; ctx.&lt;span class=&quot;me1&quot;&gt;getBean&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;#8220;component1&amp;#8243;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3ARandom+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;Random&lt;/span&gt;&lt;/a&gt; r = &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3ARandom+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;Random&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span class=&quot;me1&quot;&gt;out&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;#8220;Ready&amp;#8230;&amp;#8221;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&amp;#160; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span class=&quot;me1&quot;&gt;in&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;;;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; comp.&lt;span class=&quot;me1&quot;&gt;forwardCall&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3AThread+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;Thread&lt;/span&gt;&lt;/a&gt;.&lt;span class=&quot;me1&quot;&gt;sleep&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;r.&lt;span class=&quot;me1&quot;&gt;nextInt&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;750&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;In my case, I&amp;#8217;m going to run this application with the Java VM Management running since it gives me a free MBean server (and I like the pretty memory graphs).  If you haven&amp;#8217;t heard of this, it&amp;#8217;s &lt;a href=&quot;http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html&quot;&gt;a system property in Java 5 VMs&lt;/a&gt; that causes the VM to use JMX to manage itself.  It has beans for memory consumption, threading, and a million other things.  You start it simply by putting &lt;span style=&quot;font-family:courier&quot;&gt;-Dcom.sun.management.jmxremote&lt;/span&gt; on the command line of your running application.  In another nifty Java 5 addition, I&amp;#8217;m going to use &lt;span style=&quot;font-family:courier&quot;&gt;jconsole&lt;/span&gt; to display my results.&lt;/p&gt;
&lt;p&gt;Based on my rusty math skills, over the long term, I&amp;#8217;d expect to see Component 1 called 100%, Component 2 called 50%, and Component 3 called 25% of the time.  Lets see:&lt;/p&gt;
&lt;p&gt;&lt;img id=&quot;image13&quot; src=&quot;http://blog.springframework.com/benh/wp-content/uploads/2006/04/Tracing Screen Shot.png&quot; alt=&quot;Tracing Screen Shot&quot;/&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s good to see that I remember my probabilities right.  The best part is this still meets good design principals.  For example, none of the components know anything about the tracing because that&amp;#8217;s not what they do.  As well, all of the tracing requirements for this subsystem are contained in one class and have one implementation meeting the 1:1 requirements to implementation goal of AOP.  Finally, with the ability to turn off the tracing, any performance impact is more or less neutralized.  I know, I know incrementing an integer isn&amp;#8217;t that expensive, but if you&amp;#8217;re tracing did something expensive, it&amp;#8217;s nice to have and you don&amp;#8217;t have to worry if you want to send it into production; you can simply disable the monitoring until your customer calls in for support.&lt;/p&gt;
&lt;p&gt;So the graphs sure are pretty and maybe even tell you stuff if you know your expected percentages,   but what else could you do?  How about the last 100 messages to go by and their decisions?  How about a log of the reason that a message was dropped?  How about correlation between drop decisions and the absence of a message at the end of the pipe?  Wouldn&amp;#8217;t it be nice to know that a message had been lost (perhaps due to a threading issue) because you never intentionally dropped it but it didn&amp;#8217;t make it to the end within 500ms of its entry?  Along that same line, how about an email to the admin if the time it takes to get from one end of the pipe to the other gets over 250ms?&lt;/p&gt;
&lt;p&gt;The tracing/monitoring possibilities are endless (and pluggable!).  What will you do with it?&lt;/p&gt;
&lt;p&gt;And of course, &lt;a id=&quot;p12&quot; href=&quot;http://blog.springframework.com/benh/wp-content/uploads/2006/04/FlowTracingExample.zip&quot; title=&quot;FlowTracingExample&quot;&gt;the source code&lt;/a&gt;.
&lt;/p&gt;
</description>
            
            <pubDate>Mon, 08 May 2006 17:29:44 -0700</pubDate>
        </item>
            
        <item>
            <title>Another Reason to Love Spring 2.0: Interceptor Combining</title>
            <link>http://swik.net/Spring/Ben+Hale%27s+Blog/Another+Reason+to+Love+Spring+2.0%3A+Interceptor+Combining/die8</link>
            <description>&lt;p&gt;Recently I was working on a project that had a Swing client communicating via RMI to a service layer. The service layer was marked with transactions and everything seemed to work fine. However everytime we&amp;#8217;d get an exception at the Hibernate DAO layer, Spring would turn the exception into a runtime exception and it would get propagated all the way up the stack and across the RMI connection as a &lt;span style=&quot;font-family: courier&quot;&gt;RemoteException&lt;/span&gt;. Whenever the exception was deserialized there would be an exception on the client (separate from the &lt;span style=&quot;font-family: courier&quot;&gt;RemoteException&lt;/span&gt;.The decision was taken to simply introduce an aspect. Any exception that subclassed &lt;span style=&quot;font-family: courier&quot;&gt;ServiceAccessException&lt;/span&gt; would be let through to the client while anything else would be converted to a &lt;span style=&quot;font-family: courier&quot;&gt;FilteredServiceAccessException&lt;/span&gt; (a subclass of &lt;span style=&quot;font-family: courier&quot;&gt;ServiceAccessException&lt;/span&gt;) and then be thrown. This led to some loss in content, so we made sure to log the original exception on the server where it could be useful and let the client show a generic dialog so the user knew generally what had happened.&lt;/p&gt;
&lt;p&gt;Now this was a pretty good plan and seemed on track to work until we tried to implement it. We were using the magic way of autoproxying any bean that had &lt;span style=&quot;font-family: courier&quot;&gt;@Transactional&lt;/span&gt; on it to get our transactional proxies. We could have updated the definition of that autoproxying to make sure that the advice for this exception filtering was added (think &lt;a style=&quot;font-family: courier&quot; href=&quot;http://static.springframework.org/spring/docs/2.0-m3/api/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.html#setPreInterceptors(java.lang.Object[])&quot;&gt;setPreInterceptor&lt;/a&gt; in &lt;a style=&quot;font-family: courier&quot; href=&quot;http://static.springframework.org/spring/docs/2.0-m3/api/org/springframework/transaction/interceptor/TransactionProxyFactoryBean.html&quot;&gt;TransactionProxyFactoryBean&lt;/a&gt;) but the the autoproxying was catching more than just the service layer.&lt;/p&gt;
&lt;p&gt;So where did that leave us? We could either A) explicitly declare each use of the &lt;span style=&quot;font-family: courier&quot;&gt;TransactionProxyFactoryBean&lt;/span&gt;, B) make two different sets of autoproxying and have them be mutually exclusive for one another, or C) ignore the requirement for now and hope something magical happens. Since the product was still six months away from consumers and I try to follow the principal of the &amp;#8216;&lt;a href=&quot;http://codebetter.com/blogs/jeremy.miller/archive/2006/01/18/136648.aspx&quot;&gt;last responsible moment&lt;/a&gt;&amp;#8216; introduced to me by Jeremy Miller I decided to table the issue with choice A being my backup plan (better to have no magic than twice as much magic).&lt;/p&gt;
&lt;p&gt;Lo and behold, Spring 2.0 solved my problem. I cannot for the life of me find where I read it, but starting in one of the milestones of 2.0, when a bean is proxied the proxy factory can now detect that the bean already has a proxy and just add the intended interceptor as another interceptor (if you know where it was leave the link in the comments please). This means that I could just use the new magic (&lt;span style=&quot;font-family:courier&quot;&gt;&amp;lt;tx:annotation-driven&amp;gt;&lt;/span&gt;) and simply add an aspect with the proper pointcut that I wanted and I wouldn&amp;#8217;t have to worry about the transaction proxy and the AOP proxy getting crossed up. Not quite sure what this is all about? How about an example. First an interface and implementation.&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package interceptorcombiningexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;co2&quot;&gt;import org.springframework.transaction.annotation.Transactional;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;@Transactional&lt;br/&gt;
&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;interface&lt;/span&gt; ExampleTarget &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; exampleMethod&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package interceptorcombiningexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; DefaultExampleTarget &lt;span class=&quot;kw2&quot;&gt;implements&lt;/span&gt; ExampleTarget &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; exampleMethod&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Notice that the interface is marked &lt;span style=&quot;font-family: courier&quot;&gt;@Transactional&lt;/span&gt;. We&amp;#8217;ll use that to get some magic autoproxying later on. Next we&amp;#8217;ll take a look at the bean definitions.&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;&lt;/span&gt;?xml &lt;span class=&quot;re0&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;1.0&amp;#8243;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;UTF-8&amp;#8243;&lt;/span&gt;?&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;xmlns&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;http://www.springframework.org/schema/beans&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; xmlns:&lt;span class=&quot;re0&quot;&gt;xsi&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;http://www.w3.org/2001/XMLSchema-instance&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; xmlns:&lt;span class=&quot;re0&quot;&gt;aop&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;http://www.springframework.org/schema/aop&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; xmlns:&lt;span class=&quot;re0&quot;&gt;tx&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;http://www.springframework.org/schema/tx&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; xsi:&lt;span class=&quot;re0&quot;&gt;schemaLocation&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;http://www.springframework.org/schema/beans&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160;http://www.springframework.org/schema/beans/spring-beans.xsd&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160;http://www.springframework.org/schema/aop &lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160;http://www.springframework.org/schema/aop/spring-aop.xsd&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160;http://www.springframework.org/schema/tx&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160;http://www.springframework.org/schema/tx/spring-tx.xsd&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;tx&lt;/span&gt;:annotation-driven &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;aop&lt;/span&gt;:config&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;aop&lt;/span&gt;:aspect &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;exampleAspect&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;exampleAdvice&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;aop&lt;/span&gt;:before &lt;span class=&quot;re0&quot;&gt;method&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;exampleAdvice&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;pointcut&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;execution(* interceptorcombiningexample.ExampleTarget.exampleMethod())&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/aop&lt;/span&gt;:aspect&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/aop&lt;/span&gt;:config&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;exampleAdvice&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;interceptorcombiningexample.ExampleAdvice&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;exampleTarget&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;interceptorcombiningexample.DefaultExampleTarget&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;transactionManager&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;interceptorcombiningexample.DummyTransactionManager&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/beans&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;You&amp;#8217;ll notice that we set up annotation driven transactions which will automatically build a proxy around our &lt;span style=&quot;font-family: courier&quot;&gt;DefaultExampleTarget&lt;/span&gt;. In addition, we define another aspect that should need to proxy the same &lt;span style=&quot;font-family: courier&quot;&gt;DefaultExampleTarget&lt;/span&gt; bean. Finally lets take a look at our executable class.&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package interceptorcombiningexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;co2&quot;&gt;import org.springframework.aop.Advisor;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;co2&quot;&gt;import org.springframework.aop.framework.Advised;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;co2&quot;&gt;import org.springframework.context.ApplicationContext;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;co2&quot;&gt;import org.springframework.context.support.ClassPathXmlApplicationContext;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; InterceptorCombiningExample &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;String&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; args&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; ApplicationContext ctx = &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; ClassPathXmlApplicationContext&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;st0&quot;&gt;&amp;#8220;classpath:interceptorcombiningexample/applicationContext.xml&amp;#8221;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; ExampleTarget target = &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;ExampleTarget&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; ctx.&lt;span class=&quot;me1&quot;&gt;getBean&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;#8220;exampleTarget&amp;#8221;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;target instanceof Advised&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Advised advised = &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Advised&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; target;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span class=&quot;me1&quot;&gt;out&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; .&lt;span class=&quot;me1&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;#8220;Advisor count: &amp;#8220;&lt;/span&gt; + advised.&lt;span class=&quot;me1&quot;&gt;getAdvisors&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Advisor advisor : advised.&lt;span class=&quot;me1&quot;&gt;getAdvisors&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span class=&quot;me1&quot;&gt;out&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;#8220;Advisor type: &amp;#8220;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; + advisor.&lt;span class=&quot;me1&quot;&gt;getAdvice&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;getClass&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This class takes advantage of a nice little feature of Spring&amp;#8217;s proxy mechanism. Any Spring created proxy can be cast to the &lt;a style=&quot;font-family: courier&quot; href=&quot;http://static.springframework.org/spring/docs/2.0-m3/api/org/springframework/aop/framework/Advised.html&quot;&gt;Advised&lt;/a&gt; interface. This interface will give you access to all of the interceptors in a proxy. When we go ahead and run this class the output shows:&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;Advisor count: 3&lt;br/&gt;
Advisor type: org.springframework.aop.interceptor.ExposeInvocationInterceptor&lt;br/&gt;
Advisor type: org.springframework.transaction.interceptor.TransactionInterceptor&lt;br/&gt;
Advisor type: org.springframework.aop.aspectj.AspectJMethodBeforeAdvice&lt;/div&gt;
&lt;p&gt;From this we can see that not only was the &lt;a style=&quot;font-family: courier&quot; href=&quot;http://static.springframework.org/spring/docs/2.0-m3/api/org/springframework/transaction/interceptor/TransactionInterceptor.html&quot;&gt;TransactionInterceptor&lt;/a&gt; contained in the proxy, but also the &lt;a style=&quot;font-family: courier&quot; href=&quot;http://static.springframework.org/spring/docs/2.0-m3/api/org/springframework/aop/aspectj/AspectJMethodBeforeAdvice.html&quot;&gt;AspectJMethodBeforeAdvice&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s important to know that this shouldn&amp;#8217;t affect any implementations that already exist that attempt to do the same thing. This should just make life easier for all those who&amp;#8217;ve been waiting for the &amp;#8216;last responsible moment&amp;#8217; to solve this problem. &lt;img src=&quot;http://blog.springframework.com/benh/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;)&quot; class=&quot;wp-smiley&quot;/&gt; &lt;/p&gt;
&lt;p&gt;P.S. As in the last post, I&amp;#8217;ve included an &lt;a id=&quot;p8&quot; href=&quot;http://blog.springframework.com/benh/wp-content/uploads/2006/04/InterceptorCombiningExample.zip&quot;&gt;archive of the project&lt;/a&gt; from this example so that you can see the rest of the code if you need it.
&lt;/p&gt;
</description>
            
            <pubDate>Mon, 08 May 2006 17:29:40 -0700</pubDate>
        </item>
            
        <item>
            <title>Spring 2.0’s JMS Improvements</title>
            <link>http://swik.net/Spring/Ben+Hale%27s+Blog/Spring+2.0%E2%80%99s+JMS+Improvements/die7</link>
            <description>&lt;p&gt;With the release of Spring 1.1 the Spring community was given it’s first taste of JMS support. This support included exception translation, message conversion, and a template class much like &lt;a href=&quot;http://static.springframework.org/spring/docs/2.0-m3/api/org/springframework/jdbc/core/JdbcTemplate.html&quot; style=&quot;font-family:courier&quot;&gt;JdbcTemplate&lt;/a&gt;. This support also took care of domain unification between the JMS 1.0.2 and 1.1 specs. The centerpieces of this support are the &lt;a href=&quot;http://static.springframework.org/spring/docs/1.2.x/api/org/springframework/jms/core/JmsTemplate.html&quot; style=&quot;font-family:courier&quot;&gt;JmsTemplate&lt;/a&gt; class and it’s JMS 1.0.2 counterpart &lt;a href=&quot;http://static.springframework.org/spring/docs/1.2.x/api/org/springframework/jms/core/JmsTemplate102.html&quot; style=&quot;font-family:courier&quot;&gt;JmsTemplate102&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This support was a great improvement over using the raw JMS APIs to do enterprise messaging. However it did have a shortcoming; the &lt;span style=&quot;font-family:courier&quot;&gt;JmsTemplate&lt;/span&gt; only supported synchronous reception of messages using the &lt;a href=&quot;http://static.springframework.org/spring/docs/1.2.x/api/org/springframework/jms/core/JmsTemplate.html#receive()&quot; style=&quot;font-family:courier&quot;&gt;JmsTemplate.receive()&lt;/a&gt; methods. This behavior worked well for many people but the vast majority of users of ended up rolling their own implementations of an asynchronous consumer. In short, they wanted what EJB 2 called &lt;a href=&quot;http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/EJBConcepts5.html&quot;&gt;Message Driven Beans&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But no longer will users do without. With the release of 2.0M1 and the final 2.0 release later, native support for asynchronous reception of JMS messages has been added. The &lt;span style=&quot;font-family:courier&quot;&gt;JmsTemplate&lt;/span&gt; is still used for sending of messages at his always been, but it has now been joined by subclasses of &lt;a href=&quot;http://static.springframework.org/spring/docs/2.0-m3/api/org/springframework/jms/listener/AbstractMessageListenerContainer.html&quot; style=&quot;font-family:courier&quot;&gt;AbstractMessageListenerContainer&lt;/a&gt; such as &lt;a href=&quot;http://static.springframework.org/spring/docs/2.0-m3/api/org/springframework/jms/listener/DefaultMessageListenerContainer.html&quot; style=&quot;font-family:courier&quot;&gt;DefaultMessageListenerContainer&lt;/a&gt;, &lt;a href=&quot;http://static.springframework.org/spring/docs/2.0-m3/api/org/springframework/jms/listener/SimpleMessageListenerContainer.html&quot; style=&quot;font-family:courier&quot;&gt;SimpleMessageListenerContainer&lt;/a&gt;, and &lt;a href=&quot;http://static.springframework.org/spring/docs/2.0-m3/api/org/springframework/jms/listener/serversession/ServerSessionMessageListenerContainer.html&quot; style=&quot;font-family:courier&quot;&gt;ServerSessionMessageListener&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Let’s take a look at how to use these &lt;span style=&quot;font-family:courier&quot;&gt;MessageListenerContainer&lt;/span&gt;s. The first step is to create a class that can receive the messages. To do this, one must create a class that implements the &lt;a href=&quot;http://java.sun.com/j2ee/1.4/docs/api/javax/jms/MessageListener.html&quot; style=&quot;font-family:courier&quot;&gt;MessageListener&lt;/a&gt; interface.&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package jmsexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;co2&quot;&gt;import javax.jms.JMSException;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;co2&quot;&gt;import javax.jms.Message;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;co2&quot;&gt;import javax.jms.MessageListener;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;co2&quot;&gt;import javax.jms.TextMessage;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; ExampleListener &lt;span class=&quot;kw2&quot;&gt;implements&lt;/span&gt; MessageListener &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; onMessage&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Message message&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;message instanceof TextMessage&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;System&lt;/span&gt;&lt;/a&gt;.&lt;span class=&quot;me1&quot;&gt;out&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TextMessage&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;message&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;getText&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;JMSException e&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3ARuntimeException+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;RuntimeException&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;new&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=allinurl%3AIllegalArgumentException+java.sun.com&amp;#038;bntl=1&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;IllegalArgumentException&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;st0&quot;&gt;&amp;#8220;Message must be of type TestMessage&amp;#8221;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Once you have that, you’ll need a message producer. This code is the same as it was back before Spring 2.0, so if you have code that does this already, it should not require any changes.&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;package jmsexample;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;co2&quot;&gt;import org.springframework.jms.core.JmsTemplate;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; ExampleProducer &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; JmsTemplate jmsTemplate;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; ExampleProducer&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;JmsTemplate jmsTemplate&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;jmsTemplate&lt;/span&gt; = jmsTemplate;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; sendMessage&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; jmsTemplate.&lt;span class=&quot;me1&quot;&gt;convertAndSend&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;#8220;Example Message&amp;#8221;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Next, you need to configure your context to create a &lt;span style=&quot;font-family:courier&quot;&gt;MessageListenerContainer&lt;/span&gt; that routes messages to this bean. You’ll notice that I’m using ActiveMQ implementation classes in this example. This just happens to be one of many JMS implementations and happens to be the one that I’m most familiar with.&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;&lt;/span&gt;?xml &lt;span class=&quot;re0&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;1.0&amp;#8243;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;UTF-8&amp;#8243;&lt;/span&gt;?&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;xmlns&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;http://www.springframework.org/schema/beans&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; xmlns:&lt;span class=&quot;re0&quot;&gt;xsi&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;http://www.w3.org/2001/XMLSchema-instance&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; xsi:&lt;span class=&quot;re0&quot;&gt;schemaLocation&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;http://www.springframework.org/schema/beans&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160;http://www.springframework.org/schema/beans/spring-beans.xsd&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;messageListener&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;jmsexample.ExampleListener&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;messageProducer&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;jmsexample.ExampleProducer&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;constructor&lt;/span&gt;-arg &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;jmsTemplate&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/bean&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;jmsTemplate&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;org.springframework.jms.core.JmsTemplate&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;connectionFactory&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;connectionFactory&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;defaultDestination&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;destination&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/bean&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;destination&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;org.activemq.message.ActiveMQQueue&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;constructor&lt;/span&gt;-arg &lt;span class=&quot;re0&quot;&gt;value&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;jmsExample&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/bean&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;listenerContainer&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;org.springframework.jms.listener.DefaultMessageListenerContainer&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;connectionFactory&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;connectionFactory&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;destination&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;destination&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;messageListener&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;messageListener&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/bean&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;connectionFactory&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;org.activemq.ActiveMQConnectionFactory&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;brokerURL&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;value&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;tcp://localhost:61616&amp;#8243;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/bean&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/beans&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;I’m going to skip it for now, but obviously you’ll need to have an MQ started, and a main method that bootstraps your context. I’ve added an &lt;a id=&quot;p6&quot; href=&quot;http://blog.springframework.com/benh/wp-content/uploads/2006/04/JmsExample.zip&quot; title=&quot;JmsExample Source Code&quot;&gt;archive of the project&lt;/a&gt; from this example so that you can see the rest of the code if you need it.&lt;/p&gt;
&lt;p&gt;Finally, you just need to run your application and take a look at the output.&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;Example Message&lt;/div&gt;
&lt;p&gt;One thing to note is that so far we’ve been dealing with asynchronous reception with a single consumer thread. It is possible to multithread to your consumers (remember that you’ll still have to make them stateless or thread-safe) using the concurrent consumers property of the &lt;span style=&quot;font-family:courier&quot;&gt;MessageListenerContainer&lt;/span&gt;.&lt;/p&gt;
&lt;div class=&quot;codesnip-container&quot;&gt;
&lt;div class=&quot;codesnip&quot;&gt;&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;listenerContainer&amp;#8221;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;re0&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;org.springframework.jms.listener.DefaultMessageListenerContainer&amp;#8221;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;concurrentConsumers&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;value&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;5&amp;#8243;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;connectionFactory&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;connectionFactory&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;destination&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;destination&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;messageListener&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;st0&quot;&gt;&amp;#8220;messageListener&amp;#8221;&lt;/span&gt; &lt;span class=&quot;re2&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;sc3&quot;&gt;&lt;span class=&quot;re1&quot;&gt;&amp;lt;/bean&lt;span class=&quot;re2&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;One thing I’d like to note (from my own painful experience) is to make sure that you don’t use concurrent consumers with a Topic. Remember that in a JMS topic all messages are delivered to all consumers on a topic. This means that if you have concurrent consumers on a topic, all of them will receive the same message; typically something that you’d want to avoid. However, if you’re using a queue, obviously this would dispatch each new message to the consumers in a round-robin fashion.&lt;/p&gt;
&lt;p&gt;So, there you have it. It isn’t very flashy and is probably very similar to something you may have written at some point, but now all you have to do is use it, you don’t have to maintain it. Let me also say that this is just the tip of the iceberg. The &lt;span style=&quot;font-family:courier&quot;&gt;MessageListenerContainer&lt;/span&gt;s have the ability to take part in transactions, use custom threadpools (like the ones provided with an app server) with the new Spring &lt;a href=&quot;http://static.springframework.org/spring/docs/2.0-m3/api/org/springframework/core/task/TaskExecutor.html&quot; style=&quot;font-family:courier&quot;&gt;TaskExecutor&lt;/a&gt;abstraction, and even expose the native JMS session to the consumer. Each of those things is a topic for another post though.
&lt;/p&gt;
</description>
            
            <pubDate>Mon, 08 May 2006 17:29:37 -0700</pubDate>
        </item>
            
        <item>
            <title>Hello World!</title>
            <link>http://swik.net/Spring/Ben+Hale%27s+Blog/Hello+World%21/die6</link>
            <description>&lt;p&gt;It seemed fitting that my first post be titled ‘Hello World!’ In addition to following a strong programming tradition, it certainly describes my future. I’ve recently joined the Interface21 family and there’s lots of travel on tap.&lt;/p&gt;
&lt;p&gt;I’ve been programming in Java for about 8 years now but am a recent convert to Spring. In fact, you might consider me the model convert. In the beginning of my carreer I spent quite a bit of time working in a JSE environment and dismissing Spring as a tool to help build webapps in JEE. But one fateful trip to Scandanavia and quite a few hours with Keith Donald and my whole outlook changed. A quick conversion of my project to a spring based solution opened me up to a whole world of quick, focused, high-quality development. To skip the end, I liked Spring so much I ended up joining the company.&lt;/p&gt;
&lt;p&gt;In the formative years of my career I did quite a bit of work in network management. This domain exposed me to all sorts of interesting bits of enterprise software so you can expect me to focus quite a bit of effort in that area for the near term.
&lt;/p&gt;
</description>
            
            <pubDate>Mon, 08 May 2006 17:29:36 -0700</pubDate>
        </item>
            
    </channel>
</rss>
