Author: buildbot
Date: Wed Mar 27 22:19:01 2013
New Revision: 856214

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/cache/main.pageCache
    websites/production/camel/content/guava-eventbus.html

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/camel/content/guava-eventbus.html
==============================================================================
--- websites/production/camel/content/guava-eventbus.html (original)
+++ websites/production/camel/content/guava-eventbus.html Wed Mar 27 22:19:01 
2013
@@ -147,6 +147,43 @@ eventBus.register(<span class="code-keyw
   }
 });
 </pre>
+</div></div>
+
+<h3><a shape="rect" name="GuavaEventBus-DeadEventconsiderations"></a>DeadEvent 
considerations</h3>
+
+<p>Keep in mind that due to the limitations caused by the design of the Guava 
EventBus, you cannot specify event class to be received by the listener without 
creating class annotated with <tt>@Subscribe</tt> method. This limitation 
implies that endpoint with <tt>eventClass</tt> option specified actually 
listens to all possible events (<tt>java.lang.Object</tt>) and filter 
appropriate messages programmatically at runtime. The snipped below 
demonstrates an appropriate excerpt from the Camel code base.</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<pre class="code-java">
+@Subscribe
+<span class="code-keyword">public</span> void eventReceived(<span 
class="code-object">Object</span> event) {
+  <span class="code-keyword">if</span> (eventClass == <span 
class="code-keyword">null</span> || 
eventClass.isAssignableFrom(event.getClass())) {
+    doEventReceived(event);
+...
+</pre>
+</div></div>
+
+<p>This drawback of this approach is that <tt>EventBus</tt> instance used by 
Camel will never generate <tt>com.google.common.eventbus.DeadEvent</tt> 
notifications. If you want Camel to listen only to the precisely specified 
event (and therefore enable <tt>DeadEvent</tt> support), use 
<tt>listenerInterface</tt> endpoint option. Camel will create dynamic proxy 
over the interface you specify with the latter option and listen only to 
messages specified by the interface handler methods. The example of the 
listener interface with single method handling only <tt>SpecificEvent</tt> 
instances is demonstrated below.</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<pre class="code-java">
+<span class="code-keyword">package</span> com.example;
+
+<span class="code-keyword">public</span> <span 
class="code-keyword">interface</span> CustomListener {
+
+  @Subscribe
+  void eventReceived(SpecificEvent event);
+
+}
+</pre>
+</div></div>
+
+<p>The listener presented above could be used in the endpoint definition as 
follows.</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<pre class="code-java">
+from(<span 
class="code-quote">"guava-eventbus:busName?listenerInterface=com.example.CustomListener"</span>).to(<span
 class="code-quote">"seda:queue"</span>);
+</pre>
 </div></div></div>
         </td>
         <td valign="top">


Reply via email to