Yandex Yatomata Camel

Camel integration for Yatomata FSM

License

License

Categories

Categories

Dex General Purpose Libraries Utility
GroupId

GroupId

ru.yandex.qatools
ArtifactId

ArtifactId

yatomata-camel
Last Version

Last Version

1.2
Release Date

Release Date

Type

Type

jar
Description

Description

Yandex Yatomata Camel
Camel integration for Yatomata FSM
Project URL

Project URL

https://github.com/camelot-framework/yatomata-camel
Project Organization

Project Organization

Yandex
Source Code Management

Source Code Management

https://github.com/camelot-framework/yatomata-camel

Download yatomata-camel

How to add to project

<!-- https://jarcasting.com/artifacts/ru.yandex.qatools/yatomata-camel/ -->
<dependency>
    <groupId>ru.yandex.qatools</groupId>
    <artifactId>yatomata-camel</artifactId>
    <version>1.2</version>
</dependency>
// https://jarcasting.com/artifacts/ru.yandex.qatools/yatomata-camel/
implementation 'ru.yandex.qatools:yatomata-camel:1.2'
// https://jarcasting.com/artifacts/ru.yandex.qatools/yatomata-camel/
implementation ("ru.yandex.qatools:yatomata-camel:1.2")
'ru.yandex.qatools:yatomata-camel:jar:1.2'
<dependency org="ru.yandex.qatools" name="yatomata-camel" rev="1.2">
  <artifact name="yatomata-camel" type="jar" />
</dependency>
@Grapes(
@Grab(group='ru.yandex.qatools', module='yatomata-camel', version='1.2')
)
libraryDependencies += "ru.yandex.qatools" % "yatomata-camel" % "1.2"
[ru.yandex.qatools/yatomata-camel "1.2"]

Dependencies

compile (3)

Group / Artifact Type Version
ru.yandex.qatools : yatomata jar 1.6
org.slf4j : slf4j-api jar 1.7.7
org.apache.camel : camel-core jar 2.13.2

provided (4)

Group / Artifact Type Version
org.apache.camel : camel-spring jar 2.13.2
org.springframework : spring-core jar 3.2.11.RELEASE
org.springframework : spring-context jar 3.2.11.RELEASE
org.springframework : spring-beans jar 3.2.11.RELEASE

test (9)

Group / Artifact Type Version
junit : junit jar 4.11
org.hamcrest : hamcrest-all jar 1.3
org.mockito : mockito-all jar 1.9.5
ru.yandex.qatools.allure : allure-junit-adaptor jar 1.4.8
org.apache.camel : camel-test jar 2.13.2
org.apache.camel : camel-test-spring jar 2.13.2
org.apache.camel : camel-jms jar 2.13.2
org.apache.activemq : activemq-camel jar 5.10.0
org.springframework : spring-jms jar 3.2.11.RELEASE

Project Modules

There are no modules declared in this project.

Yatomata Camel integration

This project aims to provide the ability to use Yatomata along with Camel.

User Guide

Setup

Add the following dependency to pom.xml of your Camel project:

    <dependency>
        <groupId>ru.yandex.qatools</groupId>
        <artifactId>yatomata-camel</artifactId>
        <version>1.0</version>
    </dependency>

Basics

Create the FSM class (for more information see Yatomata docs):

    @FSM(start = Stopped.class)
    @Transitions({
            @Transit(from = Stopped.class, on = Run.class, to = Running.class),
            @Transit(from = Running.class, on = Stop.class, to = Stopped.class, stop = true),
    })
    public class MyFSM {

    }

Add the aggregator bean to your Spring context:

    <bean id="myFSM" class="ru.yandex.qatools.fsm.camel.YatomataAggregationStrategy">
        <constructor-arg value="com.me.MyFSM"/>
    </bean>

Now you can use myFSM as an ordinary aggregation strategy:

    <aggregate strategyRef="myFSM">
        <correlationExpression>
            <simple>${in.body.uuid}</simple>
        </correlationExpression>
        <completionPredicate>
            <method bean="myFSM" method="isCompleted"/>
        </completionPredicate>
        <to uri="seda:queue:done"/>
    </aggregate>

You can also use the more declarative processors with the @Processor annotation. Create the processor class, declaring the separate methods for every body type of your message:

public class MyProcessor {
    @Processor(bodyType = String.class)
    public String process(@Body String body) {
        return body + "processed";
    }
}

Add the processor bean to your Spring context:

    <bean id="myProcessor" class="ru.yandex.qatools.fsm.camel.PluggableProcessor">
        <constructor-arg>
            <bean class="com.me.MyProcessor"/>
        </constructor-arg>
    </bean>

Now you can use myProcessor as an ordinary processor in your camel routes:

    <process ref="myProcessor"/>

Camel context injection

You can use @InjectHeader and @InjectHeaders annotations to inject the current exchange context into your FSM:

    @InjectHeader("headerName")
    String headerValue;

    @InjectHeaders
    Map<String, Object> headers;

You can also inject the Camel producer templates using @Producer annotation like in the ordinary Camel beans:

    @Produce(uri = "seda:queue:done")
    private ProducerTemplate doneQueue;

It is also possible to inject the CamelContext using the CamelContextAware interface:

   @FSM(start = InitialState.class)
   @Transitions
   public class TestStateMachine implements CamelContextAware {
       private CamelContext camelContext;

       @Override
       public void setCamelContext(CamelContext camelContext) {
           this.camelContext = camelContext;
       }

       @Override
       public CamelContext getCamelContext() {
           return camelContext;
       }
   }
ru.yandex.qatools

Camelot Framework

Simplified scalable aggregation and processing framework built upon Apache Camel.

Versions

Version
1.2
1.1
1.0