Tuesday, September 29, 2009

III Drools Boot Camp at October Rules Fest 2009 - FAQ

It is official: the III Drools Boot Camp will happen on October 25th and 26th, just before the October Rules Fest 2009 in Dallas, Texas. And it is completely free for anyone attending to the October Rules Fest event!

Those that never joined us in a boot camp before might be wondering what is a boot camp, or what we do during those hours there together. For them, we've put together the quick FAQ bellow. For those that joined us before, I am sure no explanations are required.

Is the Drools Boot Camp some kind of intensive training?

Although some might thing so, it is definitively not.

If the purpose of training is to make users better for the product,
the Drools Boot Camp goal is to make the product better for the users.
Yes, we mean you.



What activities do we promote during a boot camp?

  • Use case discussion and mentoring: bring your use case (not a hello world example) and we will discuss it and try to give you new ideas on how to approach the problem.
  • Roadmap discussion: bring your requirements (and also your use cases). We will use that to understand how Drools is used and to prioritize the Drools roadmap.
  • Feature implementations: bring your feature request and we will coach you on how to develop that feature in the Drools codebase. It is an open source project, after all.
  • Bug fixing: bring your bug report and we will coach you on how to fix the problem or fix it ourselves "on-the-fly".
  • Special sessions: we will have some special, more formal, presentations on Drools topics of interest. Check the agenda.

I am a [noob/average/expert] user. Can I join you?

Yes, everyone is welcome as long as you understand the constructive spirit of the event. We are there to share experience and grow together in the best open source spirit. Get your hands dirty or not, share your own experience or help with others cases, pick a subject that interests you or discuss a topic brought by a fellow user, but do it with a constructive attitude.

What will be the formal presentations that will happen during the Boot Camp?

So far, we have 2 sessions scheduled. As we approach the date, feel free to suggest other presentations you would like to see or even better, propose your own presentation. We will consider the suggestions and will add them to the agenda as we approach the event date. Current sessions are:

Drools 5.0 State of the Union: Sunday, October 25th, 11:00 to 12:00
  • The new features in Drools 5.0 will be covered at an end user level. This includes all the drools projects, Guvnor, Flow, Fusion and Expert. This is suitable for anyone with minimal previous Drools experience who just want to know "what's new".
Drools 5.0 Advanced Engine : Sunday, October 25th, 15:00 to 16:00
  • This will be a deep dive for the technical on Rete enhancements. We will cover the asymmetrical Rete implementation, as compared to the traditional symmetrical approach, and how we enhanced it for event processing and workflow. This is targetted at experienced people, who already have an understanding of Rete and wish to understand the latest research and innovations - not for the faint-hearted.

Happy Drooling!

Friday, September 25, 2009

Drools Flow: Variable Persistence Strategies

As community contributors, we would like to introduce one of the new features that will be part of the upcoming Drools Flow 5.1 release: pluggable variable persistance. This new feature allows you to define how to persist your process data (aka the process variables), in a relational manner. The main idea of this feature is to allow you to customize data persistence, especially if the data your process is using is for example already stored in an external system, for example, when using JPA entities, external documents or other relational information. This way we can avoid duplicating this information inside the binary snapshot that Drools Flow automatically generates when one of our processes reaches a wait state (storing the runtime state of your processes to allow safe recovery if necessary). The approach is shown in the following figure:



Variable instance data is not stored as part of the runtime state of a process instance, but stored separately as VariableInstanceInfo objects. Different strategies can be used to generate a VariableInstanceInfo that will maintain different information to be able to store and retrieve the external variable information.

How can we get this working in our project? First of all, we need to configure our custom variable persisters. These persisters will be in charge of knowing all the environmental details to persist and restore each external variable type. Drools Flow provides a few out-of-the-box like for example, one for JPA entities and one for serializable variables. We can do that with the following lines:

VariablePersistenceStrategyFactory.getVariablePersistenceStrategy()
.setPersister("javax.persistence.Entity",
"org.drools.persistence.processinstance.persisters.JPAVariablePersister");
VariablePersistenceStrategyFactory.getVariablePersistenceStrategy()
.setPersister("java.io.Serializable",
"org.drools.persistence.processinstance.persisters.SerializableVariablePersister");

With these two lines we are configuring two different variable persisters, one for JPA entities and another for any object that implements the java.io.Serializable interface. This new feature will introspect each variable and decide which persister to use to store and retrieve each variable. Now we can start our processes with different variables and they will be handled using the configured persisters.

Map parameters = new HashMap();
// just a String
parameters.put("x", "SomeString");
// MyEntity is a JPA mapped entity
parameters.put("y", new MyEntity("This is a test Entity"));
// MyVariableSerializable is just a class that implement the java.io.Serializable
parameters.put("z", new MyVariableSerializable("This is a test SerializableObject"));
ProcessInstance processInstance =
ksession.startProcess("org.plugtree.labs.droolsflow", parameters);

As you can see, three variables are used to start the process, each of these variables is of a different type, so, based on the configured persisters, each of them will be treated differently. Take a look at the following snapshot that shows us the status of the database table called VariableInstanceInfo that contains our wrapped variables:



We can see the JPAPersistedVariable "y" that contains the reference to the MyEntity instance, which stores the fully qualified name of the MyEntity class and the ID that can be used to retrieve it from the external database.



The important thing to know here is that we can create custom persisters that will know how to store a particular type of variable. All the persisters need to implement the interface called VariablePersister. This interface will force us to implement the following two methods:

public interface VariablePersister {

VariableInstanceInfo persistExternalVariable(
String name,
Object o,
VariableInstanceInfo oldValue,
Environment env);

Object getExternalPersistedVariable(
VariableInstanceInfo variableInstanceInfo,
Environment env);

}

Once we create our custom persister that implements this interface, we are ready to register it, binding it with the variable type that it is ready to handle it:

VariablePersistenceStrategyFactory.getVariablePersistenceStrategy()
.setPersister("org.plugtree.labs.CustomType",
"org.drools.persistence.processinstance.persisters.MyCustomTypeVariablePersister");

Now all our variables inserted inside our processes that are instances of the class CustomType will be persisted using the MyCustomTypeVariablePersister.

There is only one thing left, we need to create the structure that will contain the specific data for our CustomType variable. This is a very easy step, we just need to create a new VariableInstanceInfo subclass to store only the specific information of our CustomType variable. This will be a new Entity that needs to be mapped into our persistence.xml file.

Here I have included an example about how this works that includes configurations for H2 and MySQL to test the behavior and see how the process persists and handles your process information--I encourage you to debug the test--and take a look at the database to see how the variables are persisted. I've also included a simple variable persister to show you a very basic example about how you can wrap a String variable in a relational way to see its content in a VARCHAR field.

Remember to take a look at the persistence.xml file and confirm that your new variable instance info type is mapped as a JPA entity:

<class>org.drools.persistence.processinstance.variabletypes.JPAPersistedVariable</class>
<class>org.drools.persistence.processinstance.variabletypes.SerializablePersistedVariable</class>
<class>org.plugtree.labs.variablepersistence.StringPersistedVariable</class>

Please let us know if this has been useful to you and in what way. As always, we welcome you questions, criticism, and (hopefully) compliments.

Project File: DroolsFlowVariablePersistenceStrategies.zip


Monday, September 21, 2009

Drools and Seam integration

Our friend Tihomir continues to do an awesome job on Drools and Seam integration. Here you can see a couple more posts about what he is doing:

Seam Numberguess example with Drools5 API

Numberguess example using Drools5 Templates

Happy Drooling

Drools Boot Camp: Dallas October 25th and 26th

Yes, you read it correct! After the success of the previous boot camps, with over 50 participants in the last boot camp in June, we will do it again. Same as last year, we are having the boot camp in the days preceding the October Rules Fest, so that you can enjoy both the boot camp and the ORF in the same trip.

What is a Drools Boot Camp?

It is an informal meeting between Drools core developers and Drools users (both community and customers) where we spend a few days together doing presentations on specific topics, discussing use cases, analyzing requirements, deriving solutions, developing features and coding bug fixes.

It is a very open discussion on topics of interest of the participants. It is NOT a Drools training. It is a place to understand where we are, what are the user needs and how to move forward. So, don't bring "hello world" type of problems to be discussed. Bring real use cases and real challenges you would like to get insights on.

You can find all the details about the Boot Camp and register for it from the ORF page. The Boot Camp is completely free for ORF attendants, but if you plan to attend only to the Boot Camp, there is a small fee.

What is the October Rules Fest?

The October Rules Fest is the best technical (no-fluff) conference on Business Rules. It is a gathering of the most important researchers, vendors, consultants and users of Business Rules from around the globe. Check the speaker bios and you will get an idea... just for a start, Dr Charles Forgy and Gary Riley will be there...

Drools will also be presenting 4 sessions.

Hope to see you all there.
Drools Team

Thursday, September 17, 2009

Inbox feature to track recent changes (Guvnor)

A recent feature committed into Guvnor trunk is the ability to track what you have opened, or edited - this shows up under an "Inbox" item in the main navigator.

Recently Opened

Clicking on the recently opened item will open a listing of all items you have "recently" opened (it tracks a few hundred items that you were last to look at). Pretty simple

Recently Edited
Any items that you save changes to, or comment on will show up here, once again, pretty simple

Incoming changes
This tracks changes made by *other people* to items that are in *your* "Recently Edited" list. When you open these items they then are removed from this list (but remain in your Recently Edited list).

All pretty simple (one of those things that are simple to grasp and use, and painful to implement ! as are all the good things in life).


Wednesday, September 09, 2009

Update on the "Advisor" smart forms tool...


Some people have asked about a tool mentioned some time back for creating smart forms made (which was being done by Solnet). This is being prepared to be open sourced, and will have a section on jboss.org where you can find it/download it.

Status update from Derek:
Just a brief update: There is a proposed name: Tohu (which is a Maori word whose meanings include to advise, guide or instruct). We are basically happy with the state of the code. What we are working on is the documentation and various other supporting artifacts prior to releasing this to a wider audience, which should be within a matter of weeks (hopefully sooner rather than later).

Looking forward to it !