cancel
Showing results for 
Search instead for 
Did you mean: 

How to replace the DefaultHistoryManager

tlyle
Champ in-the-making
Champ in-the-making

Hello all,

I'm looking for some information on how to replace the DefaultHistoryManager with my own implementation.

I found this thread https://community.alfresco.com/message/797997-re-disable-history-for-specific-process?commentID=7979... so I know which interface I have to implement but how do I go about configuring Activiti to use my new implementation?

Any advice is appreciated.

Tom

1 ACCEPTED ANSWER

vasile_dirla
Star Contributor
Star Contributor

Hi Tom,

For registering a new HistoryManager then you have to create the HistoryManager,

class MyHistoryManager extends AbstractManager implements HistoryManager{
...
}

the SessionFactory ,

public class MyHistoryManagerSessionFactory implements SessionFactory {
  
   public java.lang.Class<?> getSessionType() {
      return HistoryManager.class;
   }
  
   @Override
   public Session openSession() {
      return new MyHistoryManager();
   }

}

and then just inject the sessionFactory into the engine using configurations like that:

<bean id="processEngineConfiguration" class="...SomeProcessEngineConfigurationClass">
...
<property name="customSessionFactories">
<list>
<bean class="com.mycompany.MyHistoryManagerSessionFactory"/>
</list>
</property>
...
</bean>

 

View answer in original post

3 REPLIES 3

vasile_dirla
Star Contributor
Star Contributor

Hi Tom,

For registering a new HistoryManager then you have to create the HistoryManager,

class MyHistoryManager extends AbstractManager implements HistoryManager{
...
}

the SessionFactory ,

public class MyHistoryManagerSessionFactory implements SessionFactory {
  
   public java.lang.Class<?> getSessionType() {
      return HistoryManager.class;
   }
  
   @Override
   public Session openSession() {
      return new MyHistoryManager();
   }

}

and then just inject the sessionFactory into the engine using configurations like that:

<bean id="processEngineConfiguration" class="...SomeProcessEngineConfigurationClass">
...
<property name="customSessionFactories">
<list>
<bean class="com.mycompany.MyHistoryManagerSessionFactory"/>
</list>
</property>
...
</bean>

 

gdharley
Elite Collaborator
Elite Collaborator

Hi Tom,

Vasili's answer is absolutely correct, but implementing a complete history manager may be overkill for what you need.

Somewhere around 5.16, the "event" subsystem was introduced (documented here: Activiti User Guide ).

This allows you to register for any event and act accordingly. 

We use this mechanism to integrate into such things as NoSQL storage for reporting (e.g. Elasticsearch) as it acts in addition to the existing history tables and will not impact the operation of the history and management REST (and Java) API.

But, if you are looking for a full replacement, then Vasili's directions are correct.

Regards,

Greg

tlyle
Champ in-the-making
Champ in-the-making

Thanks for the replies. They've both been very useful