<?xml version="1.0"?><rss version="2.0">
<channel>
  <title>Java Beans dot Asia - jboss category</title>
  <link>http://javabeans.asia/categories/jboss/</link>
  <description>Just a few simple tutorials</description>
  <language>en</language>
  <copyright>Alexander Zagniotov</copyright>
  <lastBuildDate>Tue, 23 Feb 2010 11:04:00 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  <image>
    <url>/images/blog-image.jpg</url>
    <title>Java Beans dot Asia (jboss category)</title>
    <link>http://javabeans.asia/</link>
  </image>
  <item>
    <title>JBoss Security - JMX Console</title>
    <link>http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html</link>
	 <description>
        I was reading about JBoss security today, and came across the following page:&lt;br /&gt;
&lt;a title=&#034;Permanent Link to &amp;quot;JBoss Security vulnerability JMX Management Console&amp;quot;&#034; target=&#034;_blank&#034; href=&#034;http://goohackle.com/jboss-security-vulnerability-jmx-management-console/&#034;&gt;JBoss Security vulnerability JMX Management Console&lt;/a&gt;. The guy tells how common is to come across servers on the Internet that run completely unsecured JMX-Console.&lt;br /&gt;
&lt;br /&gt;
I gave it a try, typed few keywords in Google, and voil&amp;agrave; - &lt;br /&gt;
around one third of the Google results on the first page were links to various servers that run completely unsecured JBoss and JMX-console. Having said that, I would like to point out that I did not attempt anything naughty or malicious.&lt;br /&gt;
&lt;br /&gt;
Its still amazes me how careless some people are - leaving an open door for anyone to come in. Come on people, surely in this day and age we all know how important is to keep web applications secured. Don&#039;t be lazy, its not going to take much of your time since &lt;a target=&#034;_blank&#034; href=&#034;http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.2/doc/Server_Configuration_Guide/Inspecting_the_Server___the_JMX_Console_Web_Application-Securing_the_JMX_Console.html&#034;&gt;securing JMX-console&lt;/a&gt; its such a trivial task.&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;t=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;t=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - tutorial on writing DSL template&#034;&gt;Drools - tutorial on writing DSL template&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - Stop executing current agenda group and all rules&#034;&gt;Drools - Stop executing current agenda group and all rules&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; rel=&#034;bookmark&#034; title=&#034;Using template to deploy a JBoss queue&#034;&gt;Using template to deploy a JBoss queue&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Clustering - HASingleton service&#034;&gt;JBoss Clustering - HASingleton service&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - working with Stateless session&#034;&gt;Drools - working with Stateless session&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Clustering - How many nodes in the cluster?&#034;&gt;JBoss Clustering - How many nodes in the cluster?&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Clustering - Shared state across cluster partition&#034;&gt;JBoss Clustering - Shared state across cluster partition&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Clustering Architecture - Distributed Replicant Manager&#034;&gt;JBoss Clustering Architecture - Distributed Replicant Manager&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          I was reading about JBoss security today, and came across the following page: JBoss Security vulnerability JMX Management Console. The guy tells how common is to come across servers on the Internet that run completely unsecured JMX-Console.  I gave it a try, typed few keywords in Google, and voil&amp;agrave; -  around ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;t=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;title=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&amp;amp;t=JBoss Security - JMX Console&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>jboss</category>
    <category>xml</category>
    <comments>http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html</guid>
    <pubDate>Thu, 27 Aug 2009 02:46:00 GMT</pubDate>
  </item>
  <item>
    <title>Drools - tutorial on writing DSL template</title>
    <link>http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html</link>
	 <description>
        Few months ago I wrote a &lt;a href=&#034;http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034;&gt;post&lt;/a&gt; that describes an example that uses source DRL in conjunction with DSL template. In the current post, I want to describe and show with few examples how to write DSL template - whats allowed and whats not.&lt;br /&gt;
&lt;br /&gt;
Now, having said that, I want to say that I am not planning to repeat the whole &lt;a target=&#034;_blank&#034; href=&#034;http://www.redhat.com/docs/en-US/JBoss_SOA_Platform/4.2.2/html-single/JBoss_Rules_Manual/#id3069180&#034;&gt;JBoss Rules manual&lt;/a&gt; - the Drools team done a great job. I just want&amp;nbsp; to share from my personal experience, what I have come across while working with Drools when writing DSLs. &lt;br /&gt;
&lt;br /&gt;
There are few upcoming changes coming in the future release of Drools (version 5) in terms of DSL. For example DSL will become more powerful in terms of regular expressions - it will be possible to include regexp in the DSL tokens. &lt;a href=&#034;http://tirelli.blogspot.com/&#034; target=&#034;_blank&#034;&gt;Edson Tirelli&lt;/a&gt; posted an &lt;a target=&#034;_blank&#034; href=&#034;http://blog.athico.com/search/label/DSL%20regexp%20antlr&#034;&gt;article written by Matt Geis&lt;/a&gt; on Drools Blog, that talks about it and gives few examples.&lt;br /&gt;
&lt;br /&gt;
Since I am working with Drools 4.0.7 these days, I will describe in the current post how to write DSLs for Drools 4.0.7. &lt;br /&gt;
&lt;br /&gt;
Within a scope of Drools, DSL&#039;s job to&amp;nbsp; map (expand) DRL expressions written in natural language into underlying programming code.&lt;br /&gt;
&lt;br /&gt;
When writing DSL there several basic DO&#039;s and DONT&#039;s you should be aware of:&lt;br /&gt;
&lt;ol&gt;
    &lt;li&gt;Don&amp;rsquo;t put closing semi-column at the end of DSL expression line:
    &lt;pre class=&#034;codeSample&#034;&gt;[when]Message status is {1} = m : Message(status == {1})&lt;span class=&#034;error&#034;&gt;;&lt;/span&gt;&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;&amp;nbsp;Avoid different token names on the left hand side (before the &amp;ldquo;=&amp;rdquo;) and right hand side (after the &amp;ldquo;=&amp;rdquo;) of the DSL expansion:
    &lt;pre class=&#034;codeSample&#034;&gt;[when]Message status is {&lt;span class=&#034;error&#034;&gt;3&lt;/span&gt;} = m:Message(status == {&lt;span class=&#034;error&#034;&gt;1&lt;/span&gt;})&lt;br /&gt;[then]Log &amp;quot;{&lt;span class=&#034;error&#034;&gt;message&lt;/span&gt;}&amp;quot; = System.out.println(&amp;quot;{&lt;span class=&#034;error&#034;&gt;bobo&lt;/span&gt;}&amp;quot;);&lt;br /&gt;&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;&amp;nbsp;DSL expansion should be on one line. You can even have several expressions on the same line, but you cannot break the line. By putting expression on a new line will cause an exception during parsing:
    &lt;pre class=&#034;codeSample&#034;&gt;[when]Message id is {id} = m:Message(id == {id})&lt;br /&gt;[then]LogUpdate &amp;quot;{2}&amp;quot; = System.out.println(&amp;quot;{2}&amp;quot;);&lt;br /&gt;&lt;span class=&#034;error&#034;&gt;update(m);&lt;/span&gt;&lt;br /&gt;[when]Message status is {s} = m:Message(status == {s})&lt;br /&gt;[then]Log &amp;quot;{2}&amp;quot; = &lt;br /&gt;&lt;span class=&#034;error&#034;&gt;System.out.println(&amp;quot;{2}&amp;quot;);&lt;/span&gt;&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;Avoid having DSLs with the same name. It can create a confusion. Remember that DSL is parsed from top to bottom, so when two DSLs with the same name exist, the top one will apply during expansion since it will be matched first:
    &lt;pre class=&#034;codeSample&#034;&gt;[then]&lt;span class=&#034;error&#034;&gt;SetStatus&lt;/span&gt; {s} = System.out.println({s});&lt;br /&gt;[then]&lt;span class=&#034;error&#034;&gt;SetStatus&lt;/span&gt; {s} = m.setStatus({s});&lt;br /&gt;&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;If token has quotes on the left hand side of the DSL, then the token must have quotes on the right hand side of the DSL:
    &lt;pre class=&#034;codeSample&#034;&gt;[then]SetMessage &lt;span class=&#034;error&#034;&gt;&amp;quot;&lt;/span&gt;{msg}&lt;span class=&#034;error&#034;&gt;&amp;quot;&lt;/span&gt; = m.setStatus(&lt;span class=&#034;error&#034;&gt;&amp;quot;&lt;/span&gt;{msg}&lt;span class=&#034;error&#034;&gt;&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;&amp;nbsp;There is no room for typos:
    &lt;pre class=&#034;codeSample&#034;&gt;rule &amp;quot;set-hello&amp;quot;&lt;br /&gt;   when&lt;br /&gt;	True&lt;br /&gt;   then&lt;br /&gt;	SetMessa&lt;span class=&#034;error&#034;&gt;ge&lt;/span&gt; &amp;quot;Hello&amp;quot;&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;
    &lt;pre class=&#034;codeSample&#034;&gt;[then]SetMessa&lt;span class=&#034;error&#034;&gt;g&lt;/span&gt; &amp;quot;{msg}&amp;quot; = m.setStatus(&amp;quot;{msg}&amp;quot;);&lt;br /&gt;&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;Token names can be literal or numeric characters, or both:
    &lt;pre class=&#034;codeSample&#034;&gt;[then]Print1 &amp;quot;{&lt;span class=&#034;error&#034;&gt;1&lt;/span&gt;}&amp;quot; = System.out.println(&amp;quot;{&lt;span class=&#034;error&#034;&gt;1&lt;/span&gt;}&amp;quot;);&lt;br /&gt;[then]Print2 &amp;quot;{&lt;span class=&#034;error&#034;&gt;msg&lt;/span&gt;}&amp;quot; = System.out.println(&amp;quot;{&lt;span class=&#034;error&#034;&gt;msg&lt;/span&gt;}&amp;quot;);&lt;br /&gt;[then]Print3 &amp;quot;{&lt;span class=&#034;error&#034;&gt;23msg&lt;/span&gt;}&amp;quot; = System.out.println(&amp;quot;{&lt;span class=&#034;error&#034;&gt;23msg&lt;/span&gt;}&amp;quot;);&lt;br /&gt;&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;&amp;nbsp;If token on the left hand side has no quotes, and expression/function on the right hand side can accept parameter of type String, then the token can be placed between quotes on the right hand side:
    &lt;pre class=&#034;codeSample&#034;&gt;[then]PrintInteger {1} = System.out.println(&lt;span class=&#034;error&#034;&gt;&amp;quot;&lt;/span&gt;{1}&lt;span class=&#034;error&#034;&gt;&amp;quot;&lt;/span&gt;);&lt;br /&gt;[then]PrintInteger2 {1} = printingFunction(&lt;span class=&#034;error&#034;&gt;&amp;quot;&lt;/span&gt;{1}&lt;span class=&#034;error&#034;&gt;&amp;quot;&lt;/span&gt;);&lt;br /&gt;&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;&amp;nbsp;If you want to use declared variable in right hand side, make sure it is declared on the left hand side of the rule. Remember, DSL template is ONLY a template, it is a not a place to declare variables, declaration occurs only in DRL, DSL contains the expansion. Keep in mind that declaration and usage of the variable is per-rule basis:
    &lt;pre class=&#034;codeSample&#034;&gt;rule &amp;quot;set-hello&amp;quot;&lt;br /&gt;   when&lt;br /&gt;	Message&lt;br /&gt;   then&lt;br /&gt;	SetMessage &amp;quot;Hello&amp;quot;&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;
    &lt;pre class=&#034;codeSample&#034;&gt;&lt;span class=&#034;error&#034;&gt;[when]&lt;/span&gt;Message = &lt;span class=&#034;error&#034;&gt;m&lt;/span&gt; : Message() //declare and initialize &#039;m&#039;&lt;br /&gt;&lt;span class=&#034;error&#034;&gt;[then]&lt;/span&gt;SetMessage &amp;quot;{msg}&amp;quot; = &lt;span class=&#034;error&#034;&gt;m&lt;/span&gt;.setStatus(&amp;quot;{msg}&amp;quot;);&lt;br /&gt;&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;White spaces before the &amp;ldquo;=&amp;rdquo; and after are allowed when writing a DSL line:
    &lt;pre class=&#034;codeSample&#034;&gt;[then]SetMessage   &amp;quot;{msg}&amp;quot;  =    m.setStatus(&amp;quot;{msg}&amp;quot;);&lt;br /&gt;&lt;/pre&gt;
    &lt;/li&gt;
    &lt;li&gt;If you are using a function in the right hand side of the DSL of the expansion, then make sure you provide necessary imports in DRL source for all the objects the function is using. For example if your function gets a proxy to a JMS Queue from JBoss, then you have to include imports for all the objects associated with this operation, like you normally would do it in normal Java class. Also the function itself must be present in source DRL.&lt;/li&gt;
    &lt;li&gt;Left hand side of the rule, can evaluate boolean function instead of expression:
    &lt;pre class=&#034;codeSample&#034;&gt;rule &amp;quot;CheeseType&amp;quot;   &lt;br /&gt;   when	&lt;br /&gt;	Cheese is of type &amp;quot;silton&amp;quot;   &lt;br /&gt;   then	&lt;br /&gt;	DoSomething&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;function boolean &lt;br /&gt;	someEvaluatingFunction(Cheese cheese,String type) {&lt;br /&gt;   if (cheese.getType().equals(type))&lt;br /&gt;	return true;&lt;br /&gt;   else&lt;br /&gt;	return false;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
    &lt;pre class=&#034;codeSample&#034;&gt;[when]Cheese is of type &amp;quot;{1}&amp;quot; = &lt;br /&gt;chz:Cheese() eval(&lt;span class=&#034;error&#034;&gt;someEvaluatingFunction(chz, &amp;quot;{1}&amp;quot;)&lt;/span&gt;)&lt;br /&gt;[then]DoSomething = System.out.println(&amp;quot;Something&amp;quot;);&lt;br /&gt;&lt;/pre&gt;
    &lt;/li&gt;
&lt;/ol&gt;
If you interested in additional examples of the DRL+DSL, you can have a look at &lt;a href=&#034;http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034;&gt;another short example&lt;/a&gt; that I wrote sometime ago. Also, please dont forget to have a look at the JBoss Rules manual that i mentioned earlier.&lt;br /&gt;
&lt;br /&gt;
Cheers&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;t=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;t=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/09/01/drools_5_case_study_2_complex_event_processing.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools 5 Case Study 2 - Complex Event Processing&#034;&gt;Drools 5 Case Study 2 - Complex Event Processing&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/09/05/rule_engine_stress_testing.html&#034; rel=&#034;bookmark&#034; title=&#034;Rule Engine Stress Testing&#034;&gt;Rule Engine Stress Testing&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/22/brainteaser_drools_testing_objects.html&#034; rel=&#034;bookmark&#034; title=&#034;Brainteaser Drools: Testing Objects&#034;&gt;Brainteaser Drools: Testing Objects&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/23/feedback_by_the_drools_team.html&#034; rel=&#034;bookmark&#034; title=&#034;Feedback by the Drools Team&#034;&gt;Feedback by the Drools Team&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Security - JMX Console&#034;&gt;JBoss Security - JMX Console&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/29/drools_5_case_study_1_writing_dsl_for_drl_rule.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools 5 Case Study 1- Writing DSL for DRL rule&#034;&gt;Drools 5 Case Study 1- Writing DSL for DRL rule&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/31/drools_5_complex_event_processing.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools 5 - Complex Event Processing&#034;&gt;Drools 5 - Complex Event Processing&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - Stop executing current agenda group and all rules&#034;&gt;Drools - Stop executing current agenda group and all rules&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          Few months ago I wrote a post that describes an example that uses source DRL in conjunction with DSL template. In the current post, I want to describe and show with few examples how to write DSL template - whats allowed and whats not.  Now, having said that, I want to say that I am not planning to repeat the whole ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;t=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;title=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&amp;amp;t=Drools - tutorial on writing DSL template&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>jboss</category>
    <category>java</category>
    <category>drools</category>
    <comments>http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html</guid>
    <pubDate>Fri, 24 Oct 2008 06:34:20 GMT</pubDate>
  </item>
  <item>
    <title>Drools - Stop executing current agenda group and all rules</title>
    <link>http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html</link>
	 <description>
        Sometimes, depends on your business rules in your application, there is a need to stop current agenda group or all rules from continuing to execute. It wont help setting a focus to another agenda group, since previous agenda will still remain in a stack. So in this post I want to show how to prevent rules in a particular agenda group from continuing to execute by clearing the agenda and also how to stop all rules totally.&lt;br /&gt;
&lt;br /&gt;
Please note, in this example I am using agenda-groups to drive execution flow.&lt;br /&gt;
&lt;br /&gt;
I created a short DRL file and a DSL template to demonstrate how clearing agenda and stopping of all rules can be achieved.&lt;br /&gt;
&lt;br /&gt;
The DRL file:
&lt;pre class=&#034;java:firstline[1]&#034; name=&#034;code&#034;&gt;expander template.dsl;&lt;br /&gt;&lt;br /&gt;/*****************************************&lt;br /&gt; First default rule to kick in&lt;br /&gt;******************************************/&lt;br /&gt;rule &amp;quot;baserule&amp;quot;&lt;br /&gt;salience 100000 &lt;br /&gt;auto-focus true&lt;br /&gt;agenda-group &amp;quot;first-group&amp;quot;&lt;br /&gt;when&lt;br /&gt;      True&lt;br /&gt;then&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/*****************************************&lt;br /&gt; Second rule to kick in &lt;br /&gt;******************************************/&lt;br /&gt;rule &amp;quot;1&amp;quot;&lt;br /&gt;salience 1000 &lt;br /&gt;agenda-group &amp;quot;first-group&amp;quot;&lt;br /&gt;when&lt;br /&gt;      True&lt;br /&gt;then&lt;br /&gt;      Goto agenda &amp;quot;second-group&amp;quot;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/*****************************************&lt;br /&gt; Third rule to kick in&lt;br /&gt;******************************************/&lt;br /&gt;rule &amp;quot;2&amp;quot;&lt;br /&gt;salience 1000 &lt;br /&gt;agenda-group &amp;quot;second-group&amp;quot;&lt;br /&gt;when&lt;br /&gt;      True&lt;br /&gt;then&lt;br /&gt;      Do something   &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/*****************************************&lt;br /&gt; Fourth rule to kick in&lt;br /&gt;&amp;nbsp;&lt;br /&gt; Current rule stops agenda &amp;quot;second-group&amp;quot; &lt;br /&gt; from continuing to execute, and the &lt;br /&gt; focus will be returned back to &lt;br /&gt; agenda &amp;quot;first-group&amp;quot;&lt;br /&gt;******************************************/&lt;br /&gt;rule &amp;quot;3&amp;quot;&lt;br /&gt;salience 900 &lt;br /&gt;agenda-group &amp;quot;second-group&amp;quot;&lt;br /&gt;when&lt;br /&gt;      True&lt;br /&gt;then&lt;br /&gt;      Stop agenda &amp;quot;second-group&amp;quot; //clear current agenda  &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/*****************************************&lt;br /&gt; This rule never kicks in, since agenda&lt;br /&gt; &amp;quot;second-group&amp;quot; was cleared by rule &amp;quot;3&amp;quot;&lt;br /&gt;******************************************/&lt;br /&gt;rule &amp;quot;4&amp;quot;&lt;br /&gt;salience 800 &lt;br /&gt;agenda-group &amp;quot;second-group&amp;quot;&lt;br /&gt;when&lt;br /&gt;      True&lt;br /&gt;then&lt;br /&gt;      Do something   &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/*****************************************&lt;br /&gt; Fifth rule to kick in&lt;br /&gt;&lt;br /&gt; After clearing agenda &amp;quot;second-group&amp;quot;, the&lt;br /&gt; focus will be returned here &lt;br /&gt;******************************************/&lt;br /&gt;rule &amp;quot;5&amp;quot;&lt;br /&gt;salience 900 &lt;br /&gt;agenda-group &amp;quot;first-group&amp;quot;&lt;br /&gt;when&lt;br /&gt;      True&lt;br /&gt;then&lt;br /&gt;      Do something&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/*****************************************&lt;br /&gt; Sixth rule to kick in&lt;br /&gt; Current rule stops execution of all rules&lt;br /&gt;******************************************/&lt;br /&gt;rule &amp;quot;6&amp;quot;&lt;br /&gt;salience 800 &lt;br /&gt;agenda-group &amp;quot;first-group&amp;quot;&lt;br /&gt;when&lt;br /&gt;      True&lt;br /&gt;then&lt;br /&gt;      Stop all&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/*****************************************&lt;br /&gt; This rule never kicks in, since all rules&lt;br /&gt; execution was stopped by rule &amp;quot;6&amp;quot; &lt;br /&gt;******************************************/&lt;br /&gt;rule &amp;quot;7&amp;quot;&lt;br /&gt;salience 700 &lt;br /&gt;agenda-group &amp;quot;first-group&amp;quot;&lt;br /&gt;when&lt;br /&gt;      True&lt;br /&gt;then&lt;br /&gt;      Do something&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;
The DSL template:
&lt;pre name=&#034;code&#034; class=&#034;java:firstline[1]&#034;&gt;[when]True=eval(true)&lt;br /&gt;[then]Do something=&lt;br /&gt;      System.out.println(&amp;quot;Doing something&amp;quot;);&lt;br /&gt;[then]Stop all=drools.halt();&lt;br /&gt;[then]Goto agenda &amp;quot;{agenda}&amp;quot;=&lt;br /&gt;      drools.setFocus( &amp;quot;{agenda}&amp;quot; );&lt;br /&gt;[then]Stop agenda &amp;quot;{agenda}&amp;quot;=&lt;br /&gt;      drools.getWorkingMemory().&lt;br /&gt;		clearAgendaGroup(&amp;quot;{agenda}&amp;quot;);&lt;br /&gt;&lt;/pre&gt;
Basically what happens is: once the execution reaches &lt;em&gt;rule &amp;quot;3&amp;quot;, &lt;/em&gt;I am calling for &lt;em&gt;clearAgendaGroup()&lt;/em&gt; method to clear agenda, hence to remove it from the stack. As a result of the clearing, &lt;em&gt;rule &amp;quot;4&amp;quot; &lt;/em&gt;will never be executed. &lt;br /&gt;
&lt;br /&gt;
When focus is returned back to agenda &lt;em&gt;&amp;quot;first-group&amp;quot;&lt;/em&gt;,&amp;nbsp; it lands on &lt;em&gt;rule &amp;quot;5&amp;quot;&lt;/em&gt;. When the execution reaches &lt;em&gt;rule &amp;quot;6&amp;quot;&lt;/em&gt;, I am calling for &lt;em&gt;drools.halt()&lt;/em&gt; method to stop execution of all rules. &lt;br /&gt;
&lt;br /&gt;
Keep in mind that in Drools 3 there is no &lt;em&gt;halt()&lt;/em&gt; method. It came with Drools 4. If you want to achieve the above result of stopping all rules in Drools 3, you can call for &lt;em&gt;drools.clearAgenda();&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
You noticed that I am using &amp;quot;drools&amp;quot; object and calling some methods on that object in my DSL template. Well &amp;quot;drools&amp;quot; object is actually &lt;em&gt;KnowledgeHelper&lt;/em&gt; class, which is part of Drools library. It provides several APIs, for example method halt(), setFocus() and&amp;nbsp; getWorkingMemory().&lt;br /&gt;
&lt;br /&gt;
Keep in mind that I did not actually tested these particular DRL and DSL, but this example is based on real scenario that I have tested.&lt;br /&gt;
&lt;br /&gt;
Comments/questions/flames are welcomed&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;t=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;t=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/09/01/drools_5_case_study_2_complex_event_processing.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools 5 Case Study 2 - Complex Event Processing&#034;&gt;Drools 5 Case Study 2 - Complex Event Processing&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/09/05/rule_engine_stress_testing.html&#034; rel=&#034;bookmark&#034; title=&#034;Rule Engine Stress Testing&#034;&gt;Rule Engine Stress Testing&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/22/brainteaser_drools_testing_objects.html&#034; rel=&#034;bookmark&#034; title=&#034;Brainteaser Drools: Testing Objects&#034;&gt;Brainteaser Drools: Testing Objects&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/23/feedback_by_the_drools_team.html&#034; rel=&#034;bookmark&#034; title=&#034;Feedback by the Drools Team&#034;&gt;Feedback by the Drools Team&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Security - JMX Console&#034;&gt;JBoss Security - JMX Console&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/29/drools_5_case_study_1_writing_dsl_for_drl_rule.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools 5 Case Study 1- Writing DSL for DRL rule&#034;&gt;Drools 5 Case Study 1- Writing DSL for DRL rule&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/31/drools_5_complex_event_processing.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools 5 - Complex Event Processing&#034;&gt;Drools 5 - Complex Event Processing&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - tutorial on writing DSL template&#034;&gt;Drools - tutorial on writing DSL template&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          Sometimes, depends on your business rules in your application, there is a need to stop current agenda group or all rules from continuing to execute. It wont help setting a focus to another agenda group, since previous agenda will still remain in a stack. So in this post I want to show how to prevent rules in a ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;t=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;title=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&amp;amp;t=Drools - Stop executing current agenda group and all rules&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>jboss</category>
    <category>java</category>
    <category>drools</category>
    <comments>http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html</guid>
    <pubDate>Mon, 09 Jun 2008 06:36:00 GMT</pubDate>
  </item>
  <item>
    <title>JBoss Clustering Architecture - Distributed Replicant Manager</title>
    <link>http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html</link>
	 <description>
        My understanding of Distributed Replicant Manager (DRM) is that it allows you to attach some serialized data (stub) to a cluster node and manage it. &lt;br /&gt;
&lt;br /&gt;
Examples of this data include the list of stubs for a given RMI server. Each node has a stub to share with other nodes. The DRM enables the sharing of these stubs in the cluster, and allows one to know which node each stub belongs to.&lt;br /&gt;
&lt;br /&gt;
In case one of the nodes leaves the cluster, its stub is automatically removed from the list of replicants (stubs) that DRM maintains. &lt;br /&gt;
&lt;br /&gt;
Also for each set of replicants DRM holds an id, which is identical on all nodes in the cluster.&lt;br /&gt;
&lt;br /&gt;
I used DRM to attach a replicant to a node in the cluster. The replicant contains a String which holds a node IP that i get from &lt;em&gt;jboss.bind.address &lt;/em&gt;property. Every time my cluster is going through a topology changes, my service bean on the master node will prints out replicant list.&lt;br /&gt;
&lt;br /&gt;
My service MBean as follows:
&lt;pre name=&#034;code&#034; class=&#034;java:firstline[1]&#034;&gt;package com.example;&lt;br /&gt;&lt;br /&gt;public class CoordinatorHAService extends &lt;br /&gt;	HASingletonSupport implements &lt;br /&gt;			CoordinatorHAServiceMBean  {&lt;br /&gt;&lt;br /&gt;    private static Logger logger = &lt;br /&gt;	Logger.getLogger(CoordinatorHAService.class);&lt;br /&gt; &lt;br /&gt;	/**&lt;br /&gt;	 * Can be used instead of the constructor &lt;br /&gt;	 * defined in jboss-service.xml&lt;br /&gt;	 */&lt;br /&gt;	private static final String BIND_ADDRESS = &lt;br /&gt;		System.getProperty(&amp;quot;jboss.bind.address&amp;quot;);&lt;br /&gt;&lt;br /&gt;	/**&lt;br /&gt;	 * Custom name for this HA partition, overrides &lt;br /&gt;	 * the default HA partition name which is &lt;br /&gt;	 * canonical name of this MBean&lt;br /&gt;	 */&lt;br /&gt;	private final static &lt;br /&gt;	String COORDINATOR_HA_SERVICE_NAME = &lt;br /&gt;		&amp;quot;ServiceName:CoordinatorHAService&amp;quot;;&lt;br /&gt;	&lt;br /&gt;	/**&lt;br /&gt;	 * Current node IP&lt;br /&gt;	 */&lt;br /&gt;	private String nodeIp = null;&lt;br /&gt;&lt;br /&gt;	/**&lt;br /&gt;	 * Constructor that gets value of this node IP &lt;br /&gt;	 * from &#039;jboss.bind.address&#039; property&lt;br /&gt;	 * defined in jboss-service.xml&lt;br /&gt;	 * &lt;br /&gt;	 */&lt;br /&gt;	public CoordinatorHAService(String nodeIp) {&lt;br /&gt;		this.nodeIp = nodeIp;&lt;br /&gt;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	public void startService() throws Exception {&lt;br /&gt;&lt;br /&gt;	try {&lt;br /&gt;	/**&lt;br /&gt;	 * Call for super must be done before getting&lt;br /&gt;	 * HAPartition. If super is not called, HAPartition&lt;br /&gt;	 * will be &#039;null&#039;&lt;br /&gt;	 *&lt;br /&gt;	 * Alternatively you can use InitialContext to get &lt;br /&gt;	 * default partition, then you dont have to make &lt;br /&gt;	 * a call for super.startService(). I havent&lt;br /&gt;	 * tested it, so I am not sure of the results. &lt;br /&gt;	 *&lt;br /&gt;	 *&lt;br /&gt;	 * InitialContext ic = new InitialContext();&lt;br /&gt;	 * String partitionName = ServerConfigUtil.getDefaultPartitionName();&lt;br /&gt;	 * String partitionJndi = &amp;quot;/HAPartition/&amp;quot; + partitionName;&lt;br /&gt;	 * HAPartition partition = (HAPartition) ic.lookup(partitionJndi);&lt;br /&gt;	 */&lt;br /&gt;		super.startService();&lt;br /&gt;&lt;br /&gt;	/**&lt;br /&gt;	 * HAPartition gives access to the replicant manager,&lt;br /&gt;	 * which I am using to add node replicants to.&lt;br /&gt;	 */&lt;br /&gt;		HAPartition partition = super.getPartition();&lt;br /&gt;&lt;br /&gt;		if (partition != null) {&lt;br /&gt;			partition.getDistributedReplicantManager().add(&lt;br /&gt;					this.getServiceHAName(), this.getNodeIp());&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;		} catch (Exception e) {&lt;br /&gt;			this.stopService();&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	synchronized public void stopService() throws Exception {&lt;br /&gt;		super.stopService();&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	public boolean isMasterNode() {&lt;br /&gt;		return super.isMasterNode();&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	/**&lt;br /&gt;	 * Called when node is elected as a master node&lt;br /&gt;	 */&lt;br /&gt;	public void startSingleton() {&lt;br /&gt;	&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	/**&lt;br /&gt;	 * Called when node stops acting as a master node&lt;br /&gt;	 */&lt;br /&gt;	public void stopSingleton() {&lt;br /&gt;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	/**&lt;br /&gt;	 * Override this method only if you need to provide &lt;br /&gt;	 * a custom partition wide unique service name. &lt;br /&gt;	 * The default implementation will usually work,&lt;br /&gt;	 * provided that the getServiceName() method returns &lt;br /&gt;	 * a unique canonical MBean name.&lt;br /&gt;	 * &lt;br /&gt;	 */&lt;br /&gt;	public String getServiceHAName() {&lt;br /&gt;		// return super.getServiceHAName();&lt;br /&gt;		return CoordinatorHAService.COORDINATOR_HA_SERVICE_NAME;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	/**&lt;br /&gt;	 * Called when there are topology changes in the cluster.&lt;br /&gt;	 */&lt;br /&gt;	public void partitionTopologyChanged(List newReplicants, &lt;br /&gt;												int newViewID) {&lt;br /&gt;		super.partitionTopologyChanged(newReplicants, &lt;br /&gt;												newViewID);&lt;br /&gt;&lt;br /&gt;		/**&lt;br /&gt;		 * If current service is the master node - &lt;br /&gt;		 * print replicants in the cluster&lt;br /&gt;		 */&lt;br /&gt;		if (this.isMasterNode()) {&lt;br /&gt;			&lt;br /&gt;			List&lt;string&gt; clusterNodeIps = &lt;br /&gt;				new LinkedList&lt;string&gt;(newReplicants);&lt;br /&gt;&lt;br /&gt;			for (String clusterNodeIp : clusterNodeIps) {&lt;br /&gt;				logger.info(&amp;quot;Replicant IP: &amp;quot; + clusterNodeIp);	&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	/**&lt;br /&gt;	 * Gets current node&#039;s IP&lt;br /&gt;	 */&lt;br /&gt;	public String getNodeIp() {&lt;br /&gt;		return nodeIp;&lt;br /&gt;	}&lt;br /&gt;} &lt;/string&gt;&lt;/string&gt;&lt;/pre&gt;
..and this is my &lt;em&gt;jboss-service.xml&lt;/em&gt; below:
&lt;pre class=&#034;xml:firstline[1]&#034; name=&#034;code&#034;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;server&amp;gt;&lt;br /&gt;    &amp;lt;mbean&lt;br /&gt;	code=&amp;quot;com.example.CoordinatorHAService&amp;quot;&lt;br /&gt;	name=&amp;quot;com.example:service=CoordinatorHAService&amp;quot;&amp;gt;&lt;br /&gt;	&amp;lt;constructor&amp;gt;&lt;br /&gt;	&amp;lt;arg type=&amp;quot;java.lang.String&amp;quot;&lt;br /&gt;		value=&amp;quot;${jboss.bind.address:127.0.0.1}&amp;quot; /&amp;gt;&lt;br /&gt;	  &amp;lt;/constructor&amp;gt;&lt;br /&gt;     &amp;lt;/mbean&amp;gt;&lt;br /&gt;&amp;lt;/server&amp;gt;&lt;/pre&gt;
In JBoss clustering architecture, DRM sits on top of HAPartition which abstracts the communication framework.&lt;br /&gt;
&lt;br /&gt;
Maybe this is not the most right way to do it, but I do find DRM useful if I want to manage information about my cluster nodes, and I dont want to rely on HAPartition to provide me with such information. &lt;br /&gt;
&lt;br /&gt;
The moment a new node joins the cluster, I insert its IP to my set of replicants. So I always have accurate and recent information about nodes in my cluster. In case of a dead node, my list of replicants gets updated with IP of the dead node removed from the list. The source code is attached to this post or you can just do copy/paste if you feel like it.&lt;br /&gt;
&lt;br /&gt;
JBoss clustering is a very big topic. So if someone is interested, JBoss group provides a PDF book called &lt;a href=&#034;http://docs.jboss.org/jbossas/clustering/JBossClustering7.pdf&#034; target=&#034;_blank&#034;&gt;JBoss AS Clustering&lt;/a&gt; on their website, its really useful and easy to understand. It walks through and talks about fundamental concepts of clustering. The book is a bit long but worth while to have a look ;)&lt;br /&gt;
&lt;br /&gt;
Any comments or/and flames about this post are welcomed ...&lt;br /&gt;
&lt;br /&gt;
cheers&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;t=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;t=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Security - JMX Console&#034;&gt;JBoss Security - JMX Console&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - tutorial on writing DSL template&#034;&gt;Drools - tutorial on writing DSL template&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - Stop executing current agenda group and all rules&#034;&gt;Drools - Stop executing current agenda group and all rules&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; rel=&#034;bookmark&#034; title=&#034;Using template to deploy a JBoss queue&#034;&gt;Using template to deploy a JBoss queue&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&#034; rel=&#034;bookmark&#034; title=&#034;Deployment of mbean separately to its interface&#034;&gt;Deployment of mbean separately to its interface&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Clustering - HASingleton service&#034;&gt;JBoss Clustering - HASingleton service&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - working with Stateless session&#034;&gt;Drools - working with Stateless session&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/11/stateless_beans_and_annotations.html&#034; rel=&#034;bookmark&#034; title=&#034;Stateless beans and annotations&#034;&gt;Stateless beans and annotations&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          My understanding of Distributed Replicant Manager (DRM) is that it allows you to attach some serialized data (stub) to a cluster node and manage it.   Examples of this data include the list of stubs for a given RMI server. Each node has a stub to share with other nodes. The DRM enables the sharing of these stubs in ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;t=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;title=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&amp;amp;t=JBoss Clustering Architecture - Distributed Replicant Manager&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <enclosure url="http://javabeans.asia/files/src/jboss_clustering_replicant_manager.zip" length="1737" type="application/zip" />
    <category>clustering</category>
    <category>jboss</category>
    <category>management beans</category>
    <comments>http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html</guid>
    <pubDate>Sat, 31 May 2008 07:37:00 GMT</pubDate>
  </item>
  <item>
    <title>JBoss Clustering - Shared state across cluster partition</title>
    <link>http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html</link>
	 <description>
        Did you know that if you have a JBoss cluster, HA singletons service beans on each can share a common memory state? State is a memory space shared by all HA singletons service beans in a cluster. It is possible save an object to the state using HA singleton service bean on one node, and to retrieve that object on another node.&lt;br /&gt;
&lt;br /&gt;
The implementation is very easy. Lets assume you have two nodes in a cluster, on each node you have HA singleton service bean running. Lets call them &amp;quot;&lt;em&gt;service A&lt;/em&gt;&amp;quot; and &amp;quot;&lt;em&gt;service B&lt;/em&gt;&amp;quot;. Your service beans should extend from &lt;em&gt;HASingletonSupport &lt;/em&gt;class. &lt;em&gt;HASingletonSupport&lt;/em&gt; in its turn extends from &lt;em&gt;HAServiceMBeanSupport. &lt;/em&gt;The latter gives you access to two methods:
&lt;pre class=&#034;codeSample&#034;&gt;public void setDistributedState(String key,&lt;br /&gt;                                Serializable value)&lt;br /&gt;                         throws Exception&lt;br /&gt;&lt;/pre&gt;
and
&lt;pre class=&#034;codeSample&#034;&gt;public Serializable getDistributedState(String key)&lt;br /&gt;&lt;/pre&gt;
These are convenience which allow you to save and retrieve objects from shared state. It can be whatever you want - primitive data types or even POJOs.&lt;br /&gt;
&lt;br /&gt;
Lets say somewhere inside you &lt;em&gt;service A&lt;/em&gt;, you have the following method:
&lt;pre name=&#034;code&#034; class=&#034;java:nocontrols:firstline[1]&#034;&gt;public void setObjectToSharedState()  {&lt;br /&gt;      String key = &amp;quot;test-1&amp;quot;;&lt;br /&gt;      String value = &amp;quot;Testing memory state&amp;quot;;&lt;br /&gt;&lt;br /&gt; 	try {&lt;br /&gt;	    this.setDistributedState(key, value);&lt;br /&gt;	}&lt;br /&gt;	catch (Exception e)  {&lt;br /&gt;		e.printStackTrace();&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;
Now, what has happened is that you, by using your &lt;em&gt;service A&lt;/em&gt; saved into the shared memory a String value, under a key name &amp;quot;&lt;em&gt;test-1&lt;/em&gt;&amp;quot;. This key name you can use in your &lt;em&gt;service B&lt;/em&gt; to retrieve its corresponding value from the shared memory, in this case a String. Lets say the following method is sitting somewhere in your &lt;em&gt;service B&lt;/em&gt; bean, on another node in the cluster:&lt;br /&gt;
&lt;pre name=&#034;code&#034; class=&#034;java:nocontrols:firstline[1]&#034;&gt;public void getObjectFromSharedState()  {&lt;br /&gt;      String key = &amp;quot;test-1&amp;quot;;&lt;br /&gt;      String value = (String) this.getDistributedState(key);&lt;br /&gt;      System.out.println(&amp;quot;The value is: &amp;quot; + value);&lt;br /&gt;}&lt;/pre&gt;
By specifying a key name, you can retrieve back from the shared memory what ever is saved under that key. You just have to know the type to cast it back to. &lt;br /&gt;
Also keep in mind: if you specify wrong key name, the retrieved object will be &lt;em&gt;null&lt;/em&gt;.&lt;br /&gt;
&lt;br /&gt;
Shared memory state is another option, if you want to share something between your nodes, and for some reason you don&#039;t want to use JBoss cache.&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;t=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;t=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Security - JMX Console&#034;&gt;JBoss Security - JMX Console&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - tutorial on writing DSL template&#034;&gt;Drools - tutorial on writing DSL template&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - Stop executing current agenda group and all rules&#034;&gt;Drools - Stop executing current agenda group and all rules&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; rel=&#034;bookmark&#034; title=&#034;Using template to deploy a JBoss queue&#034;&gt;Using template to deploy a JBoss queue&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&#034; rel=&#034;bookmark&#034; title=&#034;Deployment of mbean separately to its interface&#034;&gt;Deployment of mbean separately to its interface&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Clustering - HASingleton service&#034;&gt;JBoss Clustering - HASingleton service&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - working with Stateless session&#034;&gt;Drools - working with Stateless session&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/11/stateless_beans_and_annotations.html&#034; rel=&#034;bookmark&#034; title=&#034;Stateless beans and annotations&#034;&gt;Stateless beans and annotations&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          Did you know that if you have a JBoss cluster, HA singletons service beans on each can share a common memory state? State is a memory space shared by all HA singletons service beans in a cluster. It is possible save an object to the state using HA singleton service bean on one node, and to retrieve that object on ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;t=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;title=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&amp;amp;t=JBoss Clustering - Shared state across cluster partition&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>clustering</category>
    <category>jboss</category>
    <category>management beans</category>
    <comments>http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html</guid>
    <pubDate>Fri, 16 May 2008 13:15:00 GMT</pubDate>
  </item>
  <item>
    <title>JBoss Clustering - How many nodes in the cluster?</title>
    <link>http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html</link>
	 <description>
        If you want to know how many nodes there are in the current cluster partition, all you have to do is to ask &lt;em&gt;HAPartition&lt;/em&gt; for the node list. &lt;em&gt;HAPartition&lt;/em&gt; represents your cluster partition, and it contains all the information you need to know about your cluster and the nodes: their host names, IPs, position in the cluster view.&lt;br /&gt;
&lt;br /&gt;
Lets assume you have a service bean that extends from &lt;em&gt;HASingletonSupport&lt;/em&gt;. &lt;em&gt;HASingletonSupport &lt;/em&gt;in its turn extends from &lt;em&gt;HAServiceMBeanSupport. &lt;br /&gt;
&lt;br /&gt;
&lt;/em&gt;&lt;em&gt;HAServiceMBeanSupport &lt;/em&gt;is the one who gives you access&lt;em&gt; to HAPartition &lt;/em&gt;object. &lt;br /&gt;
&lt;br /&gt;
The code to request for HAPartition object and node list that you see below , you can put somewhere in your service bean:
&lt;pre class=&#034;codeSample&#034;&gt;HAPartition partition = getPartition();&lt;br /&gt;ClusterNode[] nodes = partition.getClusterNodes();&lt;br /&gt;System.out.println(nodes.length);&lt;br /&gt;&lt;/pre&gt;
&lt;em&gt;ClusterNode&lt;/em&gt; object represents your node in the cluster. It contains information about node&#039;s host name, its internet address and a few more things. &lt;em&gt;getClusterNodes()&lt;/em&gt;, returns to you an array contains as many &lt;em&gt;ClusterNode&lt;/em&gt; objects as you have currently in your cluster. So by getting the value of array length, you will know how many nodes your cluster has.&lt;br /&gt;
&lt;br /&gt;
Another way, is to do practically the same, but to request from a HAPartition a current view of your cluster:
&lt;pre class=&#034;codeSample&#034;&gt;HAPartition partition = getPartition();&lt;br /&gt;Vector v = partition.getCurrentView();&lt;br /&gt;&lt;br /&gt;System.out.println(partition.getCurrentView().size());&lt;br /&gt;&lt;br /&gt;for (Object o : v) {&lt;br /&gt;   System.out.println(o.toString());&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
The view, which is a Vector contains information about node sockets. When printed, it will return to you a String representation of node ip + port:&amp;nbsp; xxx.xxx.xxx.xxx:port. Also by printing size of the Vector, you will get number of nodes in the cluster. &lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Important note&lt;/strong&gt;: &lt;br /&gt;
I noticed there is some delay happening from the time when node leaves the cluster to the time when HAPartition returns an updated view. In another words - after node has left the cluster and topology change has occurred, the HAPartition may return to you an old view still containing the dead node. So be careful. &lt;br /&gt;
&lt;br /&gt;
Also, &lt;em&gt;getPartition()&lt;/em&gt; may return null, if &lt;em&gt;super.startService()&lt;/em&gt; hasnt been called. Have a look at implementation of &lt;a href=&#034;http://docs.jboss.org/jbossas/javadoc/4.0.2/org/jboss/ha/jmx/HAServiceMBeanSupport.java.html&#034; target=&#034;_blank&#034;&gt;HAServiceMBeanSupport&lt;/a&gt; and my other post &lt;a href=&#034;http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034;&gt;JBoss Clustering - HASingleton service&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
Thats it.&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;t=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;t=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Security - JMX Console&#034;&gt;JBoss Security - JMX Console&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - tutorial on writing DSL template&#034;&gt;Drools - tutorial on writing DSL template&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - Stop executing current agenda group and all rules&#034;&gt;Drools - Stop executing current agenda group and all rules&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; rel=&#034;bookmark&#034; title=&#034;Using template to deploy a JBoss queue&#034;&gt;Using template to deploy a JBoss queue&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&#034; rel=&#034;bookmark&#034; title=&#034;Deployment of mbean separately to its interface&#034;&gt;Deployment of mbean separately to its interface&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Clustering - HASingleton service&#034;&gt;JBoss Clustering - HASingleton service&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - working with Stateless session&#034;&gt;Drools - working with Stateless session&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/11/stateless_beans_and_annotations.html&#034; rel=&#034;bookmark&#034; title=&#034;Stateless beans and annotations&#034;&gt;Stateless beans and annotations&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          If you want to know how many nodes there are in the current cluster partition, all you have to do is to ask HAPartition for the node list. HAPartition represents your cluster partition, and it contains all the information you need to know about your cluster and the nodes: their host names, IPs, position in the ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;t=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;title=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&amp;amp;t=JBoss Clustering - How many nodes in the cluster?&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>clustering</category>
    <category>jboss</category>
    <category>management beans</category>
    <comments>http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html</guid>
    <pubDate>Wed, 14 May 2008 08:36:00 GMT</pubDate>
  </item>
  <item>
    <title>Drools - working with Stateless session</title>
    <link>http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html</link>
	 <description>
        Drools (now it is also called JBoss Rules) is an amazing open source framework which allows you to create business rules management system for your application. I got introduced to Drools while working on a project at my current company. &lt;br /&gt;
&lt;br /&gt;
It is very easy to use and implement it and it is very efficient. For example instead of having dozens of if-else statements for some application business rules, you can use Drools to create a rule engine with your defined rules and pass your objects through the rule engine.&lt;br /&gt;
&lt;br /&gt;
For example, in your application that deals with student objects, you can create a rule that checks whether the student has paid his fees for the next semester, if not - send him/her reminder email... etc..&lt;br /&gt;
&lt;br /&gt;
In this example i want to show how to work with Stateless drools session to retrieve&amp;nbsp; results from the global variable. I know that at this point its a bit not clear,&amp;nbsp; so i will try to explain as I go... or you can simply visit their website, the link is under &amp;quot;Useful Links&amp;quot; section on the right hand side... &lt;br /&gt;
&lt;br /&gt;
In addition to that you can always join their IRC channel #drools, the drools team is very helpful and i owe my special thanks to a fellas name &lt;strong&gt;mic_hat &lt;/strong&gt;and &lt;strong&gt;conan&lt;/strong&gt; there, that had a lot of patience for me ;)&lt;br /&gt;
&lt;br /&gt;
For my example i prepared a simple POJO, DRL and DSL files and a test client.&lt;br /&gt;
DRL is the file that contains my rules. DSL is the expandable template for DRL.&lt;br /&gt;
&lt;br /&gt;
Drools allow you to write your rules using plain human language in DRL, and then in DSL template you can specify to what programming code the human sentence corresponds to. The following explains what I mean:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt; My DRL file with 2 rules in it:&lt;/strong&gt;&lt;br /&gt;
&lt;pre class=&#034;java:nocontrols:firstline[1]&#034; name=&#034;code&#034;&gt;package com.test.drools.rules;&lt;br /&gt;&lt;br /&gt;expander mydsl.dsl; &lt;br /&gt;&lt;br /&gt;import com.test.drools.entities.Pojo;&lt;br /&gt;&lt;br /&gt;global java.util.List list;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;rule &amp;quot;1&amp;quot;&lt;br /&gt;salience 1000&lt;br /&gt;auto-focus true&lt;br /&gt;&lt;br /&gt;when&lt;br /&gt;      The blog name is &amp;quot;Java Beans dot Asia&amp;quot;	    &lt;br /&gt;then&lt;br /&gt;      Log &amp;quot;The blog name was matched&amp;quot;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;rule &amp;quot;2&amp;quot;&lt;br /&gt;salience 900&lt;br /&gt;&lt;br /&gt;when&lt;br /&gt;      This post was created in &amp;quot;May&amp;quot;	    &lt;br /&gt;then&lt;br /&gt;      Log &amp;quot;The blog post month was matched&amp;quot;&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;
&amp;quot;&lt;em&gt;expander mydsl.dsl&lt;/em&gt;&amp;quot; - file name of my DSL template.&lt;br /&gt;
&amp;quot;&lt;em&gt;global java.util.List list&lt;/em&gt;&amp;quot; - a global variable, which is the type of List. Global variable you can use for storing some results, log messages and even objects.&lt;br /&gt;
&amp;quot;&lt;em&gt;salience&lt;/em&gt;&amp;quot; - the priority which rules should be executed first.&lt;br /&gt;
&amp;quot;&lt;em&gt;auto-focus&lt;/em&gt;&amp;quot; - the rule that has auto-focus will get executed first, basically the starting point of execution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt; My DSL template file for my DRL:&lt;/strong&gt;
&lt;pre class=&#034;java:nocontrols:firstline[1]&#034; name=&#034;code&#034;&gt;[condition][]The blog name is &amp;quot;{name}&amp;quot;=&lt;br /&gt;	poj : Pojo( blogName == &amp;quot;{name}&amp;quot;)&lt;br /&gt;&lt;br /&gt;[condition][]This post was created in &amp;quot;{month}&amp;quot;=&lt;br /&gt;	poj : Pojo( postMonth == &amp;quot;{month}&amp;quot;)&lt;br /&gt;&lt;br /&gt;[consequence][]Log &amp;quot;{message}&amp;quot;=&lt;br /&gt;	list.add(new String(&amp;quot;{message}&amp;quot;));&lt;/pre&gt;
As you can see &amp;quot;&lt;em&gt;This post was created in &amp;quot;arg&lt;/em&gt;&amp;quot;&amp;quot; will expands into &amp;quot;&lt;em&gt;poj : Pojo( postMonth == &amp;quot;{month}&amp;quot;)&lt;/em&gt;&amp;quot;, where the value of &amp;quot;&lt;em&gt;arg&lt;/em&gt;&amp;quot; will be compared to the value of &lt;em&gt;postMonth &lt;/em&gt;variable in my POJO.&lt;br /&gt;
&lt;br /&gt;
Keep in mind that you do not have to use DSL template, you can use only DRL file if you want to and have your source code there. Using the template makes your rules very readable. &lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;My POJO:&lt;/strong&gt;&lt;br /&gt;
&lt;pre name=&#034;code&#034; class=&#034;java:nocontrols:firstline[1]&#034;&gt;package com.test.drools.entities;&lt;br /&gt;&lt;br /&gt;import java.io.Serializable;&lt;br /&gt;&lt;br /&gt;public class Pojo implements Serializable {&lt;br /&gt;&lt;br /&gt;	private String blogName;&lt;br /&gt;	private String postMonth;&lt;br /&gt;&lt;br /&gt;	public Pojo() {&lt;br /&gt;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	public String getBlogName() {&lt;br /&gt;		return blogName;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	public void setBlogName(String blogName) {&lt;br /&gt;		this.blogName = blogName;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	public String getPostMonth() {&lt;br /&gt;		return postMonth;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	public void setPostMonth(String postMonth) {&lt;br /&gt;		this.postMonth = postMonth;&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;
&lt;strong&gt; My client:&lt;/strong&gt;&lt;br /&gt;
&lt;pre class=&#034;java:nocontrols:firstline[1]&#034; name=&#034;code&#034;&gt;package com.test.drools.client;&lt;br /&gt;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;import java.io.InputStreamReader;&lt;br /&gt;import java.io.Reader;&lt;br /&gt;import java.util.ArrayList;&lt;br /&gt;import java.util.Iterator;&lt;br /&gt;import java.util.List;&lt;br /&gt;&lt;br /&gt;import org.drools.RuleBase;&lt;br /&gt;import org.drools.RuleBaseFactory;&lt;br /&gt;import org.drools.StatelessSession;&lt;br /&gt;import org.drools.StatelessSessionResult;&lt;br /&gt;import org.drools.base.CopyIdentifiersGlobalExporter;&lt;br /&gt;import org.drools.compiler.DroolsError;&lt;br /&gt;import org.drools.compiler.DroolsParserException;&lt;br /&gt;import org.drools.compiler.PackageBuilder;&lt;br /&gt;import org.drools.compiler.PackageBuilderErrors;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import com.test.drools.entities.Pojo;&lt;br /&gt;&lt;br /&gt;public class Client {&lt;br /&gt;&lt;br /&gt;//path to the DRL file inside my JAR&lt;br /&gt;final static String DRL_URL = &lt;br /&gt;		&amp;quot;/com/test/drools/rules/mydrl.drl&amp;quot;;&lt;br /&gt;//path to the DSL file inside my JAR&lt;br /&gt;final static String DSL_URL = &lt;br /&gt;		&amp;quot;/com/test/drools/rules/mydsl.dsl&amp;quot;;&lt;br /&gt;&lt;br /&gt;public static void main(String[] args) {&lt;br /&gt;&lt;br /&gt;   //Instantiate and initialize the POJO.&lt;br /&gt;   Pojo p1 = new Pojo();&lt;br /&gt;   p1.setBlogName(&amp;quot;Java Beans dot Asia&amp;quot;);&lt;br /&gt;   p1.setPostMonth(&amp;quot;May&amp;quot;);&lt;br /&gt;&lt;br /&gt;   //Calling for private method to compile a RuleBase&lt;br /&gt;   RuleBase ruleBase = getRuleBase();&lt;br /&gt;&lt;br /&gt;   //Instantiating StatelessSession&lt;br /&gt;   StatelessSession session = &lt;br /&gt;			ruleBase.newStatelessSession();&lt;br /&gt;&lt;br /&gt;   //Setting global variable:&lt;br /&gt;   //the name &#039;list&#039; is the same name mentioned in DRL:&lt;br /&gt;   //global java.util.List list;&lt;br /&gt;   session.setGlobal(&amp;quot;list&amp;quot;, list);&lt;br /&gt;&lt;br /&gt;   //specifying the global name that should be exported&lt;br /&gt;   session.setGlobalExporter( &lt;br /&gt;   new CopyIdentifiersGlobalExporter( &lt;br /&gt;				new String[]{&amp;quot;list&amp;quot;} ) );&lt;br /&gt;&lt;br /&gt;   //executeWithResults() - stores execution results in &lt;br /&gt;   //StatelessSessionResult object. That objects will &lt;br /&gt;   //contain our global variable with results, that we &lt;br /&gt;   //can use after the execution of stateless &lt;br /&gt;   //session is finished.&lt;br /&gt;   StatelessSessionResult result = &lt;br /&gt;			session.executeWithResults(p1);&lt;br /&gt;&lt;br /&gt;   //get global variable and cast back to &lt;br /&gt;   //the type of List&lt;br /&gt;   List retrievedList = (List) result.getGlobal(&amp;quot;list&amp;quot;);&lt;br /&gt;&lt;br /&gt;   if (retrievedList != null &amp;amp;&amp;amp; &lt;br /&gt;			retrievedList.size() &amp;gt; 0) {&lt;br /&gt;&lt;br /&gt;   for (Iterator i = retrievedList.iterator(); &lt;br /&gt;					i.hasNext();) {&lt;br /&gt;	System.out.println((String) i.next());&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;private static RuleBase getRuleBase() {&lt;br /&gt;&lt;br /&gt;//Create a new package builder&lt;br /&gt;PackageBuilder builder = new PackageBuilder();&lt;br /&gt;&lt;br /&gt;try {&lt;br /&gt;&lt;br /&gt;//call for private method to get the DRL&lt;br /&gt;Reader drl = getSourceDrl();&lt;br /&gt;&lt;br /&gt;//call for private method to get the DSL&lt;br /&gt;Reader dsl = getDsl();&lt;br /&gt;&lt;br /&gt;//Add rule package to the builder using drl and &lt;br /&gt;//dsl Reader objects&lt;br /&gt;builder.addPackageFromDrl(drl, dsl);&lt;br /&gt;&lt;br /&gt;//Check whether our DRL and DSL files had any &lt;br /&gt;//errors when trying to create a rule package. &lt;br /&gt;//If DRL and/or DSL had any errors we wont be able &lt;br /&gt;//to create a rule package and a new RuleBase.&lt;br /&gt;PackageBuilderErrors errors = builder.getErrors();&lt;br /&gt;&lt;br /&gt;DroolsError[] error = errors.getErrors();&lt;br /&gt;&lt;br /&gt;if (error.length &amp;gt; 0) {&lt;br /&gt;for (DroolsError err : error) {&lt;br /&gt;System.out.println(&amp;quot;Errors are: &amp;quot; + err.getMessage());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;} catch (DroolsParserException e1) {&lt;br /&gt;e1.printStackTrace();&lt;br /&gt;} catch (IOException e1) {&lt;br /&gt;e1.printStackTrace();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//Get new RuleBase object. RuleBase is where &lt;br /&gt;//we will get Stateless session object from.&lt;br /&gt;RuleBase ruleBase = RuleBaseFactory.newRuleBase();&lt;br /&gt;&lt;br /&gt;try {&lt;br /&gt;//Add package with our rules to the RuleBase.&lt;br /&gt;//This is when the RuleBase is actually compiled&lt;br /&gt;ruleBase.addPackage(builder.getPackage());&lt;br /&gt;} catch (Exception e1) {&lt;br /&gt;e1.printStackTrace();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return ruleBase;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private static Reader getDsl() &lt;br /&gt;			throws IOException {&lt;br /&gt;return new InputStreamReader(Client.class&lt;br /&gt;.getResourceAsStream(DSL_URL));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private static Reader getSourceDrl() &lt;br /&gt;			throws IOException {&lt;br /&gt;return new InputStreamReader(Client.class&lt;br /&gt;.getResourceAsStream(DRL_URL));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
I will try to give now a brief explanation&amp;nbsp; what is actually happening:&lt;br /&gt;
When &lt;em&gt;session.executeWithResults(p1); &lt;/em&gt;is executes, rule engine will apply the rules on a p1 POJO object. If rules will be matched, then the result will be stored in the global variable. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
If value&lt;em&gt; &lt;/em&gt;of &lt;em&gt;&amp;quot;blogName&amp;quot; &lt;/em&gt;variable inside my p1 POJO object will be equal to &amp;quot;&lt;em&gt;Java Beans dot Asia&lt;/em&gt;&amp;quot;, then the rule#1 in my DRL will be matched, and the result &amp;quot;&lt;em&gt;The blog name was matched&lt;/em&gt;&amp;quot; will be stored in my global List.&lt;br /&gt;
&lt;br /&gt;
The final output of the program will be as follows:
&lt;pre class=&#034;java:nocontrols:firstline[1]&#034; name=&#034;code&#034;&gt;&amp;quot;The blog name was matched&amp;quot;&lt;br /&gt;&amp;quot;The blog post month was matched&amp;quot;&lt;/pre&gt;
This example was very simple, I had only two rules where i did comparison of String literals. But Drools definitely has the capability to create a friendly business rule system with thousands of rules if needed, while staying user friendly for both developers and business clients. I think its worth while checking it out :)&lt;br /&gt;
&lt;br /&gt;
I&#039;ve included a source code and jUnit test case for this tutorial if you want to have a look at it and try it your self.&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;t=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;t=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/09/01/drools_5_case_study_2_complex_event_processing.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools 5 Case Study 2 - Complex Event Processing&#034;&gt;Drools 5 Case Study 2 - Complex Event Processing&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/09/05/rule_engine_stress_testing.html&#034; rel=&#034;bookmark&#034; title=&#034;Rule Engine Stress Testing&#034;&gt;Rule Engine Stress Testing&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/22/brainteaser_drools_testing_objects.html&#034; rel=&#034;bookmark&#034; title=&#034;Brainteaser Drools: Testing Objects&#034;&gt;Brainteaser Drools: Testing Objects&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/23/feedback_by_the_drools_team.html&#034; rel=&#034;bookmark&#034; title=&#034;Feedback by the Drools Team&#034;&gt;Feedback by the Drools Team&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Security - JMX Console&#034;&gt;JBoss Security - JMX Console&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/29/drools_5_case_study_1_writing_dsl_for_drl_rule.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools 5 Case Study 1- Writing DSL for DRL rule&#034;&gt;Drools 5 Case Study 1- Writing DSL for DRL rule&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/31/drools_5_complex_event_processing.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools 5 - Complex Event Processing&#034;&gt;Drools 5 - Complex Event Processing&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - tutorial on writing DSL template&#034;&gt;Drools - tutorial on writing DSL template&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          Drools (now it is also called JBoss Rules) is an amazing open source framework which allows you to create business rules management system for your application. I got introduced to Drools while working on a project at my current company.   It is very easy to use and implement it and it is very efficient. For example ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;t=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;title=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&amp;amp;t=Drools - working with Stateless session&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <enclosure url="http://javabeans.asia/files/src/drools_working_with_stateless_session.zip" length="4888" type="application/zip" />
    <category>jboss</category>
    <category>java</category>
    <category>drools</category>
    <comments>http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html</guid>
    <pubDate>Sun, 11 May 2008 00:01:00 GMT</pubDate>
  </item>
  <item>
    <title>JBoss Clustering - HASingleton service</title>
    <link>http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html</link>
	 <description>
        Have you ever dealt with clustered singleton service? How to determine which cluster node is the master? Well, if I am the current node, I can simply ask whether I am the master or not. But what if I already know that the current node is not the master, and I want to determine which node among other nodes in the cluster is the master? &lt;br /&gt;
&lt;br /&gt;
First I would like to give brief summary about &lt;em&gt;HASingleton&lt;/em&gt; service (HA stands for High Availability).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Summary:&lt;/strong&gt;&lt;br /&gt;
HASingleton service, is a service that is deployed on every node in a cluster, but runs only on one node, while the other nodes remain passive. The node that the service runs on, is the master node. &lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;How does JBoss selects the master node? &lt;/strong&gt;&lt;br /&gt;
Well the first node in a cluster will become master node. If existing master node will leave the cluster as a result of a shutdown for example, another node is selected as master from the remaining nodes.&lt;br /&gt;
&lt;br /&gt;
Master node can control which tasks will get executed, and how many times. HASingletons also have the ability to share a memory state across clustered partition. Something like caching ...&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br /&gt;
Lets assume that I have a service bean that extends from &lt;em&gt;HASingletonSupport&lt;/em&gt; class. &lt;em&gt;HASingletonSupport &lt;/em&gt;in its turn extends from &lt;em&gt;HAServiceMBeanSupport&lt;/em&gt;&lt;br /&gt;
and implements two interfaces: &lt;em&gt;HASingletonMBean&lt;/em&gt; and &lt;em&gt;HASingleton. &lt;/em&gt;All of them give me those wonderful APIs that can tell me whether the current node is the master or not, what the status of my cluster, how many nodes etc. etc.&lt;br /&gt;
&lt;pre class=&#034;java:nocontrols:firstline[1]&#034; name=&#034;code&#034;&gt;public class MyHAService extends HASingletonSupport implements&lt;br /&gt;        MyHAServiceMBean {&lt;br /&gt;&lt;br /&gt;private static Logger logger = &lt;br /&gt;		Logger.getLogger(MyHAService.class);&lt;br /&gt;&lt;br /&gt; public void startService() throws Exception {&lt;br /&gt;        logger.info(&amp;quot; *** STARTED MY SINGLETON SERVICE *** &amp;quot;);&lt;br /&gt;        super.startService();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public void stopService() throws Exception {&lt;br /&gt;        logger.info(&amp;quot; *** STOPPED MY SINGLETON SERVICE *** &amp;quot;);&lt;br /&gt;        super.stopService();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;public boolean isMasterNode() {&lt;br /&gt;        return super.isMasterNode();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;public void startSingleton() {&lt;br /&gt;        logger.info(&amp;quot; *** CURRENT NODE IP:&amp;quot;&lt;br /&gt;                + this.getPartition().getClusterNode()&lt;br /&gt;			.getIpAddress().getHostAddress() + &lt;br /&gt;			&amp;quot; ELECTED AS A MASTER NODE *** &amp;quot;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;public void stopSingleton() {&lt;br /&gt;        logger.info(&amp;quot; *** CURRENT NODE IP:&amp;quot;&lt;br /&gt;                + this.getPartition().getClusterNode()&lt;br /&gt;			.getIpAddress().getHostAddress()&lt;br /&gt;                + &amp;quot; STOPPED ACTING AS A MASTER NODE *** &amp;quot;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public void partitionTopologyChanged(List newReplicants, int newViewID) {&lt;br /&gt;        logger.info(&amp;quot; *** TOPOLOGY CHANGE STARTING *** &amp;quot;);&lt;br /&gt;        super.partitionTopologyChanged(newReplicants, newViewID);&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
&lt;em&gt;startSingleton()&lt;/em&gt; - invoked when the current node elected as a master.&lt;br /&gt;
&lt;em&gt;stopSingleton()&lt;/em&gt; - invoked when the current node stops acting as a master.&lt;br /&gt;
&lt;em&gt;partitionTopologyChanged()&lt;/em&gt; - invoked when new node joins or leaves the cluster.&lt;br /&gt;
&lt;br /&gt;
As i mentioned before, I have the ability to know whether the current node is the master node, by calling &lt;em&gt;isMasterNode(). &lt;/em&gt;The method will return true if the node is master and false if its not. &lt;br /&gt;
&lt;br /&gt;
In case I already know that the current node is not the master, I can ask the clustered partition (the cluster) which node is the master. For example I can request the current view of my cluster.&lt;br /&gt;
&lt;br /&gt;
The implementation can be similar to the method below which you can have inside your service bean:
&lt;pre class=&#034;java:nocontrols:firstline[1]&#034; name=&#034;code&#034;&gt;private String getMasterSocket() {&lt;br /&gt;&lt;br /&gt;        HAPartition partition = this.getPartition();&lt;br /&gt;&lt;br /&gt;        if (partition != null) {&lt;br /&gt;&lt;br /&gt;            if (partition.getCurrentView() != null) {&lt;br /&gt;                return partition.getCurrentView().get(0).toString();&lt;br /&gt;&lt;br /&gt;            } else {&lt;br /&gt;                return null;&lt;br /&gt;            }&lt;br /&gt;        } else {&lt;br /&gt;            return null;&lt;br /&gt;        }&lt;br /&gt;    }&lt;/pre&gt;
The method above will return me a string contains port and ip of the master node, for example:&lt;br /&gt;
&lt;pre class=&#034;codeSample&#034;&gt;192.168.62.12:1099&lt;br /&gt;&lt;/pre&gt;
The &lt;em&gt;HAPartition&lt;/em&gt; service maintains across cluster a registry of nodes in a view order. Now, keep in mind that an order of the nodes in the view, does not necessary reflect the order nodes have joined the cluster.&lt;br /&gt;
&lt;br /&gt;
So the first node in the view as you can see beloew, will be the master node. &lt;br /&gt;
Simple as that.
&lt;pre class=&#034;codeSample&#034;&gt;return partition.getCurrentView().get(0).toString();&lt;/pre&gt;
&lt;strong&gt;Please note&lt;/strong&gt;:&lt;br /&gt;
Method &lt;em&gt;getPartition()&lt;/em&gt; may return null, if &lt;em&gt;super.startService()&lt;/em&gt; hasnt been called. Have a look at implementation of &lt;a href=&#034;http://docs.jboss.org/jbossas/javadoc/4.0.2/org/jboss/ha/jmx/HAServiceMBeanSupport.java.html&#034; target=&#034;_blank&#034;&gt;HAServiceMBeanSupport&lt;/a&gt; and my other post &lt;a href=&#034;http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&#034;&gt;JBoss Clustering - How many nodes in the cluster?&lt;/a&gt;.&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;t=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;t=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Security - JMX Console&#034;&gt;JBoss Security - JMX Console&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - tutorial on writing DSL template&#034;&gt;Drools - tutorial on writing DSL template&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/06/04/marshalling_vs_serialization.html&#034; rel=&#034;bookmark&#034; title=&#034;Marshalling VS Serialization&#034;&gt;Marshalling VS Serialization&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/06/07/ouch.html&#034; rel=&#034;bookmark&#034; title=&#034;Ouch!&#034;&gt;Ouch!&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - Stop executing current agenda group and all rules&#034;&gt;Drools - Stop executing current agenda group and all rules&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; rel=&#034;bookmark&#034; title=&#034;Using template to deploy a JBoss queue&#034;&gt;Using template to deploy a JBoss queue&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&#034; rel=&#034;bookmark&#034; title=&#034;Deployment of mbean separately to its interface&#034;&gt;Deployment of mbean separately to its interface&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/05/multiple_return_statements.html&#034; rel=&#034;bookmark&#034; title=&#034;Multiple return statements&#034;&gt;Multiple return statements&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          Have you ever dealt with clustered singleton service? How to determine which cluster node is the master? Well, if I am the current node, I can simply ask whether I am the master or not. But what if I already know that the current node is not the master, and I want to determine which node among other nodes in the ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;t=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;title=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&amp;amp;t=JBoss Clustering - HASingleton service&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>clustering</category>
    <category>jboss</category>
    <comments>http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html</guid>
    <pubDate>Thu, 08 May 2008 09:22:00 GMT</pubDate>
  </item>
  <item>
    <title>Deployment of mbean separately to its interface</title>
    <link>http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html</link>
	 <description>
        Few days ago i came across a little nasty thing during mbean deployment. What i did was separation of my mbean class and its interface in to two archives. So first i would deploy an archive contained my interfaces and then i would deploy an archive contained my bean classes. &lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt; Why did i do it this way?&lt;/strong&gt;&lt;br /&gt;
Well to minimize chances having &lt;em&gt;ClassCastException. &lt;/em&gt;Since JBoss creates a proxy to the bean from its interface. Having the interfaces deployed seperately from the bean itself, allows me easily to modify business logic in the bean (if needed). Therefore, I will have to redeploy only the bean itself, without the need to redeploy also the interface, which will not affect my proxies to the bean in the system.&lt;br /&gt;
&lt;br /&gt;
To my big surprise i got an exception:
&lt;pre name=&#034;code&#034; class=&#034;java:nocontrols:firstline[1]&#034;&gt;org.jboss.deployment.DeploymentException: &lt;br /&gt;Class does not expose a management interface: &lt;br /&gt;java.lang.Object; - nested throwable: &lt;br /&gt;(javax.management.NotCompliantMBeanException:&lt;br /&gt;Class does not expose a management interface: &lt;br /&gt;java.lang.Object)&lt;/pre&gt;
I could not understand where did I go wrong. I had my mbean class:
&lt;pre name=&#034;code&#034; class=&#034;java:nocontrols:firstline[1]&#034;&gt;public class MyService &lt;br /&gt;	extends ServiceMBeanSupport &lt;br /&gt;		implements MyServiceMBean {&lt;br /&gt;&lt;br /&gt;public void startService() throws Exception {&lt;br /&gt;		...&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;public void stopService() {&lt;br /&gt;		...&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;
I had my interface with extension &#039;MBean&#039;. The interface must have this extension, otherwise, you will receive a &lt;em&gt;Class does not expose a management interface&lt;/em&gt; exception :
&lt;pre name=&#034;code&#034; class=&#034;java:nocontrols:firstline[1]&#034;&gt;public interface MyServiceMBean extends ServiceMBean {&lt;br /&gt;	...&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
I had my jboss-service.xml:
&lt;pre name=&#034;code&#034; class=&#034;xml:nocontrols:firstline[1]&#034;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;&amp;lt;server&amp;gt;&lt;br /&gt;  &amp;lt;mbean code=&amp;quot;com.example.MyService&amp;quot; &lt;br /&gt;         name=&amp;quot;com.example:service=MyService&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;/mbean&amp;gt;&lt;br /&gt;&amp;lt;/server&amp;gt;&lt;/pre&gt;
Finally, i discovered that it was because of the way i did the packaging. If you ever going to package mbean and its interface in two separate archives, they (mbean and its interface) must sit under &lt;em&gt;&lt;strong&gt;the same package name&lt;/strong&gt;&lt;/em&gt;! &lt;br /&gt;
&lt;br /&gt;
For example: if I in archive A, put my mbean class under the package name &amp;quot;&lt;em&gt;com.example.test&lt;/em&gt;&amp;quot;, then in archive B I have to put its interface also under&amp;nbsp; &amp;quot;&lt;em&gt;com.example.test&lt;/em&gt;&amp;quot;.&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;t=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;t=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; rel=&#034;bookmark&#034; title=&#034;Using template to deploy a JBoss queue&#034;&gt;Using template to deploy a JBoss queue&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Clustering - HASingleton service&#034;&gt;JBoss Clustering - HASingleton service&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/11/stateless_beans_and_annotations.html&#034; rel=&#034;bookmark&#034; title=&#034;Stateless beans and annotations&#034;&gt;Stateless beans and annotations&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/14/jboss_clustering_how_many_nodes_in_the_cluster.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Clustering - How many nodes in the cluster?&#034;&gt;JBoss Clustering - How many nodes in the cluster?&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/16/jboss_clustering_shared_state_across_cluster_partition.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Clustering - Shared state across cluster partition&#034;&gt;JBoss Clustering - Shared state across cluster partition&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/31/jboss_clustering_architecture_distributed_replicant_manager.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Clustering Architecture - Distributed Replicant Manager&#034;&gt;JBoss Clustering Architecture - Distributed Replicant Manager&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          Few days ago i came across a little nasty thing during mbean deployment. What i did was separation of my mbean class and its interface in to two archives. So first i would deploy an archive contained my interfaces and then i would deploy an archive contained my bean classes.    Why did i do it this way? Well to ...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;t=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;title=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&amp;amp;t=Deployment of mbean separately to its interface&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>beans</category>
    <category>jboss</category>
    <category>management beans</category>
    <comments>http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html</guid>
    <pubDate>Sat, 03 May 2008 09:51:00 GMT</pubDate>
  </item>
  <item>
    <title>Using template to deploy a JBoss queue</title>
    <link>http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html</link>
	 <description>
        Currently I am involved in a project, where I have to use &lt;a target=&#034;_blank&#034; href=&#034;http://velocity.apache.org/engine/devel/&#034;&gt;Velocity&lt;/a&gt; template engine to deploy queues and message-driven beans to JBoss. &lt;a target=&#034;_blank&#034; href=&#034;http://velocity.apache.org/engine/devel/&#034;&gt;Velocity&lt;/a&gt; is a template engine that can be used for many purposes, and in my case I am using it to generate XML descriptor for a JBoss queue, hence: some-queue-name-service.xml. Its a simple scripting language and the XML descriptor template looks quite similar to the resulting XML descriptor.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt; Why do we use a template for deployment?&lt;/strong&gt; &lt;br /&gt;
Because some of our deployments occur at runtime, where properties for the queues and MDB&#039;s are generated on the fly and we need a templating engine to be able generate the deployments.&lt;br /&gt;
&lt;br /&gt;
So i decided to describe a process of deploying a JBoss queue. I am hoping that I will be clear enough, since i am quite new to this my self.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;The setup of my system:&lt;/strong&gt;&lt;br /&gt;
&lt;pre class=&#034;codeSample&#034;&gt;/opt/mitto/jboss/server/mitto/&lt;/pre&gt;
Root directory for my JBoss instance. (the [.])&lt;br /&gt;
&lt;br /&gt;
My Velocity templates sit under the root, inside &lt;em&gt;dynamic-templates&lt;/em&gt; directory:
&lt;pre class=&#034;codeSample&#034;&gt;./dynamic-templates/&lt;br /&gt;&lt;/pre&gt;
JBoss deployment service will look under the root of my JBoss instance for the &lt;em&gt;dynamic-templates&lt;/em&gt; directory. &lt;br /&gt;
&lt;br /&gt;
JBoss deployment service depends on Velocity library (&lt;em&gt;velocity.jar&lt;/em&gt;) that must be included under the root of:
&lt;pre class=&#034;codeSample&#034;&gt;./deploy/deployment-service.sar/&lt;br /&gt;&lt;/pre&gt;
XML descriptor of JBoss deployment service (&lt;em&gt;jboss-service.xml&lt;/em&gt;) sits under:
&lt;pre class=&#034;codeSample&#034;&gt;./deploy/deployment-service.sar/META-INF/&lt;/pre&gt;
You can see below the &lt;em&gt;jboss-service.xml&lt;/em&gt;:&lt;br /&gt;
&lt;pre class=&#034;xml:nocontrols:firstline[1]&#034; name=&#034;code&#034;&gt;&amp;lt;mbean&lt;br /&gt;   code=&amp;quot;org.jboss.services.deployment.DeploymentService&amp;quot;&lt;br /&gt;     name=&amp;quot;jboss:service=DeploymentService&amp;quot;&amp;gt;&lt;br /&gt;	&amp;lt;attribute name=&amp;quot;TemplateDir&amp;quot;&amp;gt;&lt;br /&gt;		dynamic-templates&lt;br /&gt;	&amp;lt;/attribute&amp;gt;&lt;br /&gt;	&amp;lt;attribute name=&amp;quot;DeployDir&amp;quot;&amp;gt;&lt;br /&gt;		dynamic-deploy&lt;br /&gt;	&amp;lt;/attribute&amp;gt;&lt;br /&gt;	&amp;lt;attribute name=&amp;quot;UndeployDir&amp;quot;&amp;gt;&lt;br /&gt;		dynamic-undeploy&lt;br /&gt;	&amp;lt;/attribute&amp;gt;&lt;br /&gt;&amp;lt;/mbean&amp;gt;&lt;/pre&gt;
The three directories mentioned above in &lt;em&gt;jboss-service.xml&lt;/em&gt;, sit under the root of my JBoss instance. &lt;br /&gt;
&lt;em&gt;TemplateDir&lt;/em&gt; - where my deployment generation templates can be found.&lt;br /&gt;
&lt;em&gt;UndeployDir&lt;/em&gt; - the generated modules go there.&lt;br /&gt;
&lt;em&gt;DeployDir - &lt;/em&gt;the directory to use when I ask to deploy a generated module.&lt;br /&gt;
&lt;br /&gt;
Now, inside the:
&lt;pre class=&#034;codeSample&#034;&gt;./dynamic-templates/&lt;/pre&gt;
I have following structure:&lt;br /&gt;
&lt;pre class=&#034;codeSample&#034;&gt;jbossmessaging-queue/&lt;br /&gt;		    /vm/&lt;br /&gt;		       jbossmessaging-queue.xml.vm&lt;br /&gt;		    template-config.xml&lt;/pre&gt;
&lt;em&gt;jbossmessaging-queue&lt;/em&gt; - directory that contains Velocity XML descriptor template for my queue. Also it represents the name of the deployment template that should be used, when createModule() method of deployment service will be called.&lt;br /&gt;
&lt;br /&gt;
t&lt;em&gt;emplate-config.xml &lt;/em&gt;specifies the properties for Velocity template XML descriptor for our queue. Deployment service will be able to access those properties when rendering the Velocity template and to retrieve the values of &lt;em&gt;&lt;strong&gt;JNDIName&lt;/strong&gt;&lt;/em&gt; and &lt;em&gt;&lt;strong&gt;QueueName &lt;/strong&gt;&lt;/em&gt;properties.&lt;br /&gt;
&lt;br /&gt;
Below you can see the descriptor for the &lt;em&gt;template-config.xml:&lt;/em&gt;
&lt;pre class=&#034;xml:nocontrols:firstline[1]&#034; name=&#034;code&#034;&gt;&amp;lt;template-config&lt;br /&gt;     template=&amp;quot;vm/jbossmessaging-queue.xml.vm&amp;quot;&lt;br /&gt;		       extension=&amp;quot;-service.xml&amp;quot;&amp;gt;&lt;br /&gt;   &amp;lt;property-list&amp;gt;&lt;br /&gt;  	&amp;lt;property name=&amp;quot;QueueName&amp;quot;&lt;br /&gt;	    type=&amp;quot;java.lang.String&amp;quot; optional=&amp;quot;false&amp;quot;/&amp;gt;&lt;br /&gt;   &amp;lt;/property-list&amp;gt;&lt;br /&gt;&amp;lt;/template-config&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;em&gt;jbossmessaging-queue.xml.vm&lt;/em&gt; mentioned above, is the name of the actual Velocity template XML descriptor for the queue, which you can see below:&lt;br /&gt;
&lt;pre class=&#034;xml:nocontrols:firstline[1]&#034; name=&#034;code&#034;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;&amp;lt;!--&lt;br /&gt;  ==============================================&lt;br /&gt;  QueueName          - $QueueName&lt;br /&gt;  ==============================================&lt;br /&gt;--&amp;gt;&lt;br /&gt;&amp;lt;server&amp;gt;&lt;br /&gt;&amp;lt;mbean&lt;br /&gt;   code=&amp;quot;org.jboss.jms.server.destination.QueueService&amp;quot;&lt;br /&gt;   name=&amp;quot;jboss.messaging.destination:service=Queue,&lt;br /&gt;   name=$QueueName&amp;quot; xmbean-dd=&amp;quot;xmdesc/Queue-xmbean.xml&amp;quot;&amp;gt;&lt;br /&gt;    &lt;br /&gt;   &amp;lt;depends optional-attribute-name=&amp;quot;ServerPeer&amp;quot;&amp;gt;&lt;br /&gt;	jboss.messaging:service=ServerPeer&amp;lt;/depends&amp;gt;&lt;br /&gt;   &amp;lt;attribute name=&amp;quot;Clustered&amp;quot;&amp;gt;true&amp;lt;/attribute&amp;gt;&lt;br /&gt;   &amp;lt;depends&amp;gt;jboss.messaging:service=PostOffice&amp;lt;/depends&amp;gt;     &lt;br /&gt; &lt;br /&gt;&amp;lt;/mbean&amp;gt;&lt;br /&gt;&amp;lt;/server&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;strong&gt; Implementation:&lt;/strong&gt;&lt;br /&gt;
I created a service bean that will acquire proxies for the JBoss &lt;em&gt;MainDeployerMBean&lt;/em&gt; and JBoss &lt;em&gt;DeploymentServiceMBean&lt;/em&gt;. I will use JBoss deployment service to construct a queue module in the file system, and I will use JBoss main deployer to deploy the queue, by pointing it to the module in the file system. My implementation of my service bean as follows:
&lt;pre class=&#034;java:nocontrols:firstline[1]&#034; name=&#034;code&#034;&gt;public class DeploymentService &lt;br /&gt;	extends ServiceMBeanSupport &lt;br /&gt;		implements DeploymentServiceMBean {&lt;br /&gt;&lt;br /&gt;private static final String &lt;br /&gt;	JBOSS_MAIN_DEPLOYER_SERVICE = &amp;quot;jboss.system:service=MainDeployer&amp;quot;;&lt;br /&gt;private static final String &lt;br /&gt;	JBOSS_DEPLOYMENT_SERVICE = &amp;quot;jboss:service=DeploymentService&amp;quot;;&lt;br /&gt;&lt;br /&gt;private MainDeployerMBean mainDeployerService = null;&lt;br /&gt;private DeploymentServiceMBean jbossDeploymentService = null;&lt;br /&gt;&lt;br /&gt;public void startService() throws Exception {&lt;br /&gt;&lt;br /&gt;	try {&lt;br /&gt;                //get proxy for main deployer service bean&lt;br /&gt;		mainDeployerService = getJBossMainDeployer();&lt;br /&gt;	}&lt;br /&gt;	catch (MBeanProxyCreationException e)  {&lt;br /&gt;		e.printStackTrace();&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	try {&lt;br /&gt;		&lt;br /&gt;		//get proxy for deployemnt service bean		&lt;br /&gt;		jbossDeploymentService = getJBossDeploymentService();&lt;br /&gt;	}&lt;br /&gt;	catch (MBeanProxyCreationException e)  {&lt;br /&gt;		e.printStackTrace();&lt;br /&gt;	}&lt;br /&gt;		&lt;br /&gt;	deploy();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void stopService() {&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;private void deploy()  {&lt;br /&gt;&lt;br /&gt;//hashmap contains properties for the queue template&lt;br /&gt;HashMap&amp;lt;String, Object&amp;gt; properties = new HashMap&amp;lt;String, Object&amp;gt;();&lt;br /&gt;&lt;br /&gt;//short file name of my queue&lt;br /&gt;String destination = &amp;quot;myqueue-service.xml&amp;quot;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//directory name where the queue Velocity template is kept, &lt;br /&gt;//inside &#039;dynamic-templates&#039; dir &lt;br /&gt;String template = &amp;quot;jbossmessaging-queue&amp;quot;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//property that holds a queue name for the Velocity template&lt;br /&gt;properties.put(&amp;quot;QueueName&amp;quot;, &amp;quot;myqueue&amp;quot;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;String resultingFileName = &amp;quot;&amp;quot;;&lt;br /&gt;&lt;br /&gt;//create a queue module in a filesystem, at this stage queue &lt;br /&gt;//is not deployed yet.&lt;br /&gt;try {&lt;br /&gt;	resultingFileName = jbossDeploymentService&lt;br /&gt;			.createModule(destination, template, properties);&lt;br /&gt;} catch (Exception e) {&lt;br /&gt;		e.printStackTrace();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;String path = constructPath(destination);&lt;br /&gt;&lt;br /&gt;try {&lt;br /&gt;	//check whether deployment exists for the given &lt;br /&gt;	//module queue in the file system&lt;br /&gt;	if (!mainDeployerService.isDeployed(path)) {&lt;br /&gt;&lt;br /&gt;		mainDeployerService.deploy(path);&lt;br /&gt;	}&lt;br /&gt;} catch (MalformedURLException e) {&lt;br /&gt;	e.printStackTrace();&lt;br /&gt;}&lt;br /&gt;	&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//construct an absolute path to the queue module in a filesystem &lt;br /&gt;//for a given name.&lt;br /&gt;private String constructPath(String shortName) {&lt;br /&gt;String path = ServerConfigLocator.locate().getServerHomeDir()&lt;br /&gt;			.getAbsolutePath()&lt;br /&gt;			+ &amp;quot;/&amp;quot;&lt;br /&gt;			+ jbossDeploymentService.getUndeployDir()&lt;br /&gt;			+ &amp;quot;/&amp;quot;&lt;br /&gt;			+ shortName;&lt;br /&gt;	return path;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;//Constructs and returns a proxy for MainDeployerMBean&lt;br /&gt;private MainDeployerMBean getJBossMainDeployer() &lt;br /&gt;					throws MBeanProxyCreationException&lt;br /&gt;{&lt;br /&gt;	MBeanServer server = getServer();&lt;br /&gt;&lt;br /&gt;	ObjectName serviceName = new ObjectName(JBOSS_MAIN_DEPLOYER_SERVICE);&lt;br /&gt;&lt;br /&gt;//&#039;false&#039; -&amp;gt; dont make the returned proxy implement NotificationEmitter interface&lt;br /&gt;	MainDeployerMBean mainDeployer =&lt;br /&gt;	(MainDeployerMBean) MBeanServerInvocationHandler&lt;br /&gt;                                .newProxyInstance(server, serviceName,&lt;br /&gt;                                        MainDeployerMBean.class, false);&lt;br /&gt;&lt;br /&gt;  return mainDeployer;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//Constructs and returns a proxy for DeploymentServiceMBean&lt;br /&gt;private DeploymentServiceMBean getJBossDeploymentService() &lt;br /&gt;					throws MBeanProxyCreationException&lt;br /&gt;{&lt;br /&gt;	MBeanServer server = getServer();&lt;br /&gt;&lt;br /&gt;	ObjectName serviceName = new ObjectName(JBOSS_DEPLOYMENT_SERVICE);&lt;br /&gt;&lt;br /&gt;//&#039;false&#039; -&amp;gt; dont make the returned proxy implement NotificationEmitter interface&lt;br /&gt;	DeploymentServiceMBean deploymentService =&lt;br /&gt;	(DeploymentServiceMBean) MBeanServerInvocationHandler&lt;br /&gt;                                .newProxyInstance(server, serviceName,&lt;br /&gt;                                        DeploymentServiceMBean.class, false);&lt;br /&gt;&lt;br /&gt;  return deploymentService;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
Two main points that i want to explain here are: &lt;br /&gt;
&lt;em&gt;createModule() &lt;/em&gt;method of JBoss deployment service and &lt;br /&gt;
&lt;em&gt;deploy() &lt;/em&gt;of JBoss main deployer.  &lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;createModule() &lt;/em&gt;- accepts three arguments: resulting file name (in this case is &lt;em&gt;myqueue-service.xml&lt;/em&gt;), the directory name where the Velocity template is kept and a HashMap object which contains properties for the template. &lt;br /&gt;
&lt;br /&gt;
JBoss deployment service will use the Velocity template to generate &lt;em&gt;myqueue-service.xml&lt;/em&gt; module under &lt;em&gt;dynamic-undeploy&lt;/em&gt; directory. &lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;deploy()&lt;/em&gt; - accepts a path to the module in the system and deploys the module. In this case the path to the module is:
&lt;pre class=&#034;codeSample&#034;&gt;/opt/mitto/jboss/server/mitto/&lt;br /&gt;                dynamic-undeploy/myqueue-service.xml&lt;/pre&gt;
Thats about it :) You can use Velocity templates to deploy queues, message-driven and other types of beans. Basically anything that has XML descriptors.&lt;br /&gt;
I really hope I was clear enough in this example, since it is quite consized.&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;t=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;t=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;Related Posts&lt;/b&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/08/27/jboss_security_jmx_console.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Security - JMX Console&#034;&gt;JBoss Security - JMX Console&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2009/03/08/hibernate_event_interceptor.html&#034; rel=&#034;bookmark&#034; title=&#034;Hibernate Event Interceptor&#034;&gt;Hibernate Event Interceptor&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/10/24/drools_tutorial_on_writing_dsl_template.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - tutorial on writing DSL template&#034;&gt;Drools - tutorial on writing DSL template&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/06/09/drools_stop_executing_current_agenda_group_and_all_rules.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - Stop executing current agenda group and all rules&#034;&gt;Drools - Stop executing current agenda group and all rules&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/03/deployment_of_mbean_separately_to_its_interface.html&#034; rel=&#034;bookmark&#034; title=&#034;Deployment of mbean separately to its interface&#034;&gt;Deployment of mbean separately to its interface&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/06/bitwise_operation_in_hibernate_3.html&#034; rel=&#034;bookmark&#034; title=&#034;Bitwise operation in Hibernate 3&#034;&gt;Bitwise operation in Hibernate 3&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/08/jboss_clustering_hasingleton_service.html&#034; rel=&#034;bookmark&#034; title=&#034;JBoss Clustering - HASingleton service&#034;&gt;JBoss Clustering - HASingleton service&lt;/a&gt;&lt;br /&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/11/drools_working_with_stateless_session.html&#034; rel=&#034;bookmark&#034; title=&#034;Drools - working with Stateless session&#034;&gt;Drools - working with Stateless session&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;</description>
	<!--
    <description>
          Currently I am involved in a project, where I have to use Velocity template engine to deploy queues and message-driven beans to JBoss. Velocity is a template engine that can be used for many purposes, and in my case I am using it to generate XML descriptor for a JBoss queue, hence: some-queue-name-serv...&lt;p&gt;&lt;a href=&#034;http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034;&gt;Read more...&lt;/a&gt;&lt;/p&gt;&lt;div class=&#034;tags&#034;&gt;&lt;span&gt;Social Bookmarks : &lt;/span&gt;&amp;nbsp;&lt;a href=&#034;http://slashdot.org/bookmark.pl?url=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Add this post to Slash Dot&#034;&gt;&lt;img src=&#034;common/images/slashdot.png&#034; alt=&#034;Add this post to Slashdot&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://digg.com/submit?url=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Digg this post&#034;&gt;&lt;img src=&#034;common/images/digg.png&#034; alt=&#034;Add this post to Digg&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://reddit.com/submit?url=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Add this post to Reddit&#034;&gt;&lt;img src=&#034;common/images/reddit.png&#034; alt=&#034;Add this post to Reddit&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://del.icio.us/post?url=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Save this post to Del.icio.us&#034;&gt;&lt;img src=&#034;common/images/delicious.png&#034; alt=&#034;Add this post to Delicious&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.stumbleupon.com/submit?url=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Stumble this post&#034;&gt;&lt;img src=&#034;common/images/stumbleupon.png&#034; alt=&#034;Add this post to Stumble it&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.google.com/bookmarks/mark?op=edit&amp;amp;bkmk=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Add this post to Google&#034;&gt;&lt;img src=&#034;common/images/google.png&#034; alt=&#034;Add this post to Google&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://technorati.com/faves?add=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Technorati&#034;&gt;&lt;img src=&#034;common/images/technorati.png&#034; alt=&#034;Add this post to Technorati&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.bloglines.com/sub/http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Bloglines&#034;&gt;&lt;img src=&#034;common/images/bloglines.png&#034; alt=&#034;Add this post to Bloglines&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.facebook.com/share.php?u=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&#034; target=&#034;_blank&#034; title=&#034;Add this post to Facebook&#034;&gt;&lt;img src=&#034;common/images/facebook.png&#034; alt=&#034;Add this post to Facebook&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://www.furl.net/storeIt.jsp?u=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;t=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Add this post to Furl&#034;&gt;&lt;img src=&#034;common/images/furl.png&#034; alt=&#034;Add this post to Furl&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;amp;url=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;title=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Add this post to Windows Live&#034;&gt;&lt;img src=&#034;common/images/windowslive.png&#034; alt=&#034;Add this post to Windows Live&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&#034;http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;amp;u=http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html&amp;amp;t=Using template to deploy a JBoss queue&#034; target=&#034;_blank&#034; title=&#034;Add this post to Yahoo!&#034;&gt;&lt;img src=&#034;common/images/yahoo.png&#034; alt=&#034;Add this post to Yahoo!&#034; border=&#034;0&#034; /&gt;&lt;/a&gt;&lt;/div&gt;</description>
      
	-->
    <category>jboss</category>
    <category>velocity</category>
    <category>queues</category>
    <category>xml</category>
    <category>jms</category>
    <comments>http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html#comments</comments>
    <guid isPermaLink="true">http://javabeans.asia/2008/05/01/using_template_to_deploy_a_jboss_queue.html</guid>
    <pubDate>Thu, 01 May 2008 00:48:00 GMT</pubDate>
  </item>
  </channel>
</rss>
