Skip to content
Nils Stenholm edited this page Feb 24, 2021 · 16 revisions

nFlow Frequently Asked Questions

Why Spring throws exception "No bean named 'nflowDatabaseInitializer' is defined" when starting?

org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'workflowInstanceDao' defined in URL 
[jar:file:/some/path/nflow-engine-0.2.1-SNAPSHOT.jar!/com/nitorcreations/nflow/engine/internal/dao/WorkflowInstanceDao.class]: 
Unsatisfied dependency expressed through constructor argument with index 1 of type [com.nitorcreations.nflow.engine.internal.dao.ExecutorDao]: : 
No bean named 'nflowDatabaseInitializer' is defined; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No bean named 'nflowDatabaseInitializer' is defined

This may be caused by missing Spring profile that selects database engine. You should use one of these spring profiles nflow.db.mysql, nflow.db.postgresql, nflow.db.oracle or nflow.db.h2. E.g use this system property: -Dspring.profiles.active=nflow.db.mysql.

How to include nflow-engine in my application without starting workflow processing?

Set nflow.autostart=false, e.g use system property -Dnflow.autostart=false when starting your application. With this property nFlow instance won't start a dispatcher thread and thus the instance will not process any workflows.

Why WorkflowState symbol is not found?

error: cannot find symbol
    public enum State implements WorkflowState {
                                 ^
  symbol:   class WorkflowState
  location: class MyWorkflow

Use fully qualified class name for io.nflow.engine.workflow.definition.WorkflowState. This seems to be a JDK bug.

How to fix exception java.lang.NoClassDefFoundError: javax/activation/DataSource with JDK 10?

Include javax.activation library. It seems that they are no longer part of the JDK 10.

<dependency>
    <groupId>javax.activation</groupId>
    <artifactId>activation</artifactId>
    <version>1.1.1</version>
</dependency>

When the parent workflow goes to end state, what happens to child workflows?

Nothing special happens to child workflows, they continue execute normally.

What is the difference between businessId and externalId?

businessId can be used in for grouping workflow instances that are related to the same business logic entity. It has no effect to nFlow processing and the same value can be used in any number of workflow instances.

externalId must be unique within workflow instances of the same workflow type. It can be defined to avoid creating more than 1 instance of workflow instances of given type. If externalId is undefined when creating the workflow instance, nFlow will generate a random value (UUID.randomUUID().toString()) for it.

Is the code in end states executed?

Yes.

How to log workflow type/id/state variables?

You can use MDC via WorkflowLogContextListener.

Inject this to Spring context at startup:

@Bean
public WorkflowExecutorListener[] listeners() {
    return new WorkflowExecutorListener[] {new WorkflowLogContextListener("workflow")};
}

Add %X{CONTEXT_NAME} to logging pattern:

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>[%thread] %-5level %logger %X{workflow} - %msg%n</pattern>
        </encoder>
    </appender>

Can the amount of items archived per batch be controlled or throttled?

Not currently. Archiving is meant to help performance and generally it's desirable that it's quick.

However, for example, Galera Cluster has a limit for the number of rows per writeset, which might be exceeded and thus preventing archiving from running successfully. You can use work-arounds for this, for example, tuning wsrep_max_ws_rows and/or implementing a custom workflow that deletes old workflow data (actions, states) to keep the row counts manageable. Another option is to forgo the built-in archiving and implement a custom one (if archiving is needed).