Fulmine "Hello World 2" Tutorial

This tutorial will take you through the basics of adding and manipulating fields in a record. As with the previous tutorial, two contexts will be created in the same VM but the code can be broken out into separate VMs. The tutorial code is located here. Run the code, the following will show in the console (allow 30 seconds to complete)

Constructed LogTaskHandler
Starting logging executor
Started logging executor
received Record(helloWorld:Type(10,Record):Domain(1,Tutorial))=[nativeContext=HelloWorldPublisher, state=STALE]
received Record(helloWorld:Type(10,Record):Domain(1,Tutorial))=[nativeContext=HelloWorldPublisher, state=LIVE]
received Record(helloWorld:Type(10,Record):Domain(1,Tutorial))=[nativeContext=HelloWorldPublisher, state=LIVE, field1=an initial value]
received Record(helloWorld:Type(10,Record):Domain(1,Tutorial))=[nativeContext=HelloWorldPublisher, state=LIVE, field1=changed value, field2=some other value]
received Record(helloWorld:Type(10,Record):Domain(1,Tutorial))=[nativeContext=HelloWorldPublisher, state=LIVE, field1=changed value again, field2=some other value]

The subscriber context has received 5 updates to the 'helloWorld' record. Records are updated in 'execution frames'. These are loosely analogous to transactions in that all changes that occur in a frame are grouped into a single atomic change. The code excerpt from the tutorial code below shows how a change to a record is executed in a frame.

        record.beginFrame(new EventFrameExecution());
        try
        {
            field1 = new StringField("field1", "an initial value");
            record.add(field1);
        }
        finally
        {
            record.endFrame();
        }

Only when the frame is completed is the change to the record released to any local or remote subscribers. It does not matter how many times a field changes or how many fields in a record change in a frame. The net change in the record will only be seen when the frame ends. This is demonstrated in the second frame in the code

        record.beginFrame(new EventFrameExecution());
        try
        {
            // this overwrites the value of field1 from the previous frame
            field1.set("changed value");
            record.add(new StringField("field2", "some other value"));
        }
        finally
        {
            record.endFrame();
        }

In this frame, there are 2 changes made to the record. The console output shows that we receive both these changes as a single event

received Record(helloWorld:Type(10,Record):Domain(1,Tutorial))=[nativeContext=HelloWorldPublisher, state=LIVE, field1=changed value, field2=some other value]

The changes occurred in a single frame and hence are broadcast as an atomic change to listeners.