This might provide some useful information: <a href="https://community.jboss.org/wiki/PublishDroolsArtifactsFromAProductionEnvironment">https://community.jboss.org/wiki/PublishDroolsArtifactsFromAProductionEnvironment</a><br>
<br><div class="gmail_quote">On 28 June 2012 10:15, Stephen Masters <span dir="ltr">&lt;<a href="mailto:stephen.masters@me.com" target="_blank">stephen.masters@me.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div>One option:</div><div><br></div><div><ul><li>Point your production environment at a LIVE snapshot (or whatever you want to call it) instead of LATEST.</li><li>Point your CI build at LATEST.</li><li>On successful completion of the test suite, create a new LIVE snapshot.</li>
</ul></div><div>That way, you can always see the current live version of your rules in Guvnor, and diff them if you need to.</div><div><br></div><div>Steve</div><div><div class="h5"><div><br></div><div><br><br>On Jun 27, 2012, at 03:20 PM, Gustaf Cele &lt;<a href="mailto:gustaf.cele@databyran.se" target="_blank">gustaf.cele@databyran.se</a>&gt; wrote:<br>
<br></div><div><blockquote type="cite"><div><div>Hi Wolfgang!<br> <br> A staging area sounds like a good idea. Would something as simple as this work?<br> <br> KnowledgeAgent stagingAgent = connectToGuvnorAndStartPolling();<br>
 KnowledgeBase productionKnowledgeBase = ...;<br> stagingAgent.addEventListener(new DefaultKnowledgeAgentEventListener() {<br> @Override<br> public void beforeChangeSetApplied(BeforeChangeSetAppliedEvent event) {<br> if (allTestsPass()) {<br>
 // copy rules from stagingAgent to productionKnowledgeBase, somehow<br> }<br> });<br> <br> ... and in that case, how would I go about the copying part? Is it safe to just save the reference from stagingAgent.getKnowledgeBase() if the agent is configured with drools.agent.newInstance=true?<br>
 <br> /g<br> <br> -----Original Message-----<br> From: Wolfgang Laun [mailto:<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>] <br> Sent: den 27 juni 2012 15:45<br> To: Rules Users List<br>
 Subject: Re: [rules-users] Continuous deployment of rules/vetoing changesets<br> <br> Have you considered using a &quot;staged&quot; approach?<br> <br> Rather than forwarding LATEST right into production, have one listener move it into the staging area or not - depending on the tests. The production side listener(s) are directed onto the staging area.<br>
 <br> -W<br> <br> <br> <br> On 27/06/2012, Gustaf Cele &lt;<a href="mailto:gustaf.cele@databyran.se" target="_blank">gustaf.cele@databyran.se</a>&gt; wrote:<br> &gt; Hi,<br> &gt;<br> &gt; I have a Guvnor server (5.4.0.Final) which provides rules to a client <br>
 &gt; (which itself is an EJB server app) using KnowledgeAgents to get hold <br> &gt; of rule updates. The knowledge agents are started with changeset XMLs <br> &gt; on the classpath which point at my Guvnor instance.<br>
 &gt;<br> &gt; The KnowledgeAgents are set up thus:<br> &gt;<br> &gt; ResourceFactory.getResourceChangeNotifierService().start();<br> &gt; ResourceFactory.getResourceChangeScannerService().start();<br> &gt; KnowledgeAgent knowledgeAgent =<br>
 &gt; KnowledgeAgentFactory.newKnowledgeAgent(agentName);<br> &gt; knowledgeAgent.monitorResourceChangeEvents(true);<br> &gt; Resource resource =<br> &gt; ResourceFactory.newClassPathResource(changeSetResourcePath, getClass());<br>
 &gt; knowledgeAgent.applyChangeSet(resource);<br> &gt; ResourceFactory.getResourceChangeNotifierService().start();<br> &gt; ResourceFactory.getResourceChangeScannerService().start();<br> &gt;<br> &gt; And the changesets look like this (xsd stuff removed for brevity):<br>
 &gt;<br> &gt; &lt;change-set&gt;<br> &gt; &lt;add&gt;<br> &gt; &lt;resource username=&quot;ruleclient&quot; password=&quot;hunter2&quot;<br> &gt; basicAuthentication=&quot;enabled&quot;<br> &gt;<br> &gt; source=&quot;<a href="http://guvnorhost/drools-guvnor/org.drools.guvnor.Guvnor/package/my.package/LATEST" target="_blank">http://guvnorhost/drools-guvnor/org.drools.guvnor.Guvnor/package/my.package/LATEST</a>&quot;<br>
 &gt; type=&quot;PKG&quot; /&gt;<br> &gt; &lt;/add&gt;<br> &gt; &lt;/change-set&gt;<br> &gt;<br> &gt; As you can see, we use LATEST because we want continuous deployment of <br> &gt; our rules. Change a rule, build the package, and have the connected <br>
 &gt; KnowledgeAgents updated with the new rule. This works very well - a <br> &gt; bit too well, unfortunately. We have a comprehensive test suite, and <br> &gt; every now and then, you&#39;ll check in a rule that breaks a test. We want <br>
 &gt; to prevent any changes to our rules from being propagated to the <br> &gt; clients until all the tests succeed, and this is where we&#39;re stuck.<br> &gt;<br> &gt; We&#39;ve tried using a KnowledgeAgentEventListener which throws an <br>
 &gt; exception when it detects test failures:<br> &gt;<br> &gt; public class VetoListener extends DefaultKnowledgeAgentEventListener {<br> &gt; @Override<br> &gt; public void beforeChangeSetApplied(BeforeChangeSetAppliedEvent<br>
 &gt; event) {<br> &gt; if (!allTestsPass()) {<br> &gt; throw new RuntimeException(&quot;tests failed, not applying <br> &gt; change set&quot;);<br> &gt; }<br> &gt; }<br> &gt;<br> &gt; boolean allTestsPass(){<br> &gt; // Get test results from<br>
 &gt; ${guvnor_url}/org.drools.guvnor.Guvnor/package/my.package/LATEST/SCENARIOS<br> &gt; // and check if there were any failures<br> &gt; }<br> &gt; }<br> &gt; // Usage:<br> &gt; knowledgeAgent.addEventListener(new VetoListener());<br>
 &gt;<br> &gt; This does prevent the new changeset from being applied, but it also <br> &gt; seems to kill the thread polling for new changes entirely. Restarting <br> &gt; the ResourceChange{Scanner,Notifier}Services doesn&#39;t help.<br>
 &gt;<br> &gt; I&#39;ve also tried modifying the event&#39;s changeset (I know you <br> &gt; shouldn&#39;t), but it doesn&#39;t stop the changes from being applied:<br> &gt;<br> &gt; public void beforeChangeSetApplied(BeforeChangeSetAppliedEvent event) {<br>
 &gt; if (!allTestsPass()) {<br> &gt; event.getChangeSet().getResourcesModified().clear();<br> &gt; // ... and clear all the other collections you can get <br> &gt; from<br> &gt; event.getChangeSet()<br> &gt; }<br> &gt; }<br>
 &gt;<br> &gt; So, what I wonder is if there is any way of preventing a changeset <br> &gt; from being applied to a KnowledgeAgent&#39;s knowledge base when there are <br> &gt; failing test scenarios, but which applies updates as soon as all tests <br>
 &gt; succeed? More generally, I&#39;m looking for something with fewer manual <br> &gt; steps than run tests-make snapshot-publish, and in particular I want <br> &gt; to ensure you never publish a package when there are tests failing, <br>
 &gt; and it should preferably not require any changes outside of Guvnor to <br> &gt; get out new rules to the client app. Any ideas?<br> &gt;<br> &gt; Thanks in advance,<br> &gt;<br> &gt; /g<br> &gt;<br> &gt;<br> _______________________________________________<br>
 rules-users mailing list<br> <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
 <br> _______________________________________________<br> rules-users mailing list<br> <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div></div></div></div><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>