[Index]

events:for


An Event Source For a variable set of child Event Sources. Required when the list of events to wait for changes dynamically - such as the set of files required to run a job.

Property Summary

configuration The configuration that will be parsed for each value.
eventOperator Event Operator to filter events.
file The name of the configuration file.
index The current index in the values.
last The last event to be passed to a consumer.
name A name, can be any text.
purgeAfter The number of completed jobs to keep.
to The destination events will be sent to.
values Any stream of values.

Example Summary

Example 1 Wait for prices to be available to price some fruit trades.

Property Detail

configuration

Configured ByELEMENT
AccessREAD_WRITE
RequiredYes.

The configuration that will be parsed for each value.

eventOperator

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, default to ALL.

Event Operator to filter events. ANY/ALL.

file

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

The name of the configuration file. to use for configuration.

index

AccessREAD_ONLY
RequiredR/O.

The current index in the values.

last

AccessREAD_ONLY
RequiredRead only.

The last event to be passed to a consumer.

name

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

A name, can be any text.

purgeAfter

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo. Defaults to no complete jobs being purged.

The number of completed jobs to keep. Oddjob configurations can be quite memory intensive, mainly due to logging, purging complete jobs will stop too much memory being taken.

Setting this property to 0 means that no complete jobs will be purged.

to

Configured ByELEMENT
AccessWRITE_ONLY
RequiredMaybe. Set automatically by some parent components.

The destination events will be sent to.

values

Configured ByELEMENT
AccessWRITE_ONLY
RequiredNo.

Any stream of values.


Examples

Example 1

Wait for prices to be available to price some fruit trades. This resulted as an experiment in turning Oddjob into a rules engine.

<oddjob id="this">
    <job>
        <sequential>
            <jobs>
                <properties name="Properties">
                    <values>
                        <file file="${some.dir}" key="data.dir"/>
                    </values>
                </properties>
                <bean class="org.oddjob.events.example.FileFactStore" id="factStore" rootDir="${data.dir}"/>
                <events:when id="whenBookList" name="When BookList Available" xmlns:events="oddjob:events">
                    <jobs>
                        <bean class="org.oddjob.events.example.FactSubscriber" factStore="${factStore}" name="Subscribe to BookList" query="BookList:GREENGROCERS"/>
                        <foreach id="forEachBook" name="For Each Book">
                            <values>
                                <value value="${whenBookList.trigger.of.books}"/>
                            </values>
                            <configuration>
                                <inline>
                                    <foreach id="bookName">
                                        <job>
                                            <events:when id="whenBook" name="When ${bookName.current}">
                                                <jobs>
                                                    <bean class="org.oddjob.events.example.FactSubscriber" factStore="${factStore}" name="Subscribe to Book ${bookName.current}" query="Book:${bookName.current}"/>
                                                    <events:when id="priceMatch" name="When Prices for ${bookName.current}">
                                                        <jobs>
                                                            <events:for name="For Each Trade">
                                                                <configuration>
                                                                    <inline>
                                                                        <events id="trade">
                                                                            <job>
                                                                                <bean class="org.oddjob.events.example.FactSubscriber" factStore="${factStore}" name="Subscribe to Price for ${trade.current.product}" query="Price:${trade.current.product}"/>
                                                                            </job>
                                                                        </events>
                                                                    </inline>
                                                                </configuration>
                                                                <values>
                                                                    <value value="${whenBook.trigger.of.trades}"/>
                                                                </values>
                                                            </events:for>
                                                            <sequential name="Run Calculation">
                                                                <jobs>
                                                                    <bean class="org.oddjob.events.example.ValueCalculator" id="calculate">
                                                                        <trades>
                                                                            <value value="${whenBook.trigger.of.trades}"/>
                                                                        </trades>
                                                                        <prices>
                                                                            <value value="${priceMatch.trigger.ofs}"/>
                                                                        </prices>
                                                                    </bean>
                                                                    <echo>Value of ${bookName.current} is ${calculate.value}</echo>
                                                                </jobs>
                                                            </sequential>
                                                        </jobs>
                                                    </events:when>
                                                </jobs>
                                            </events:when>
                                        </job>
                                    </foreach>
                                </inline>
                            </configuration>
                        </foreach>
                    </jobs>
                </events:when>
            </jobs>
        </sequential>
    </job>
</oddjob>


(c) R Gordon Ltd 2005 - Present