WSO2 Developer’s Guide
上QQ阅读APP看书,第一时间看更新

Creating a sequence

In this section, we will create the sequences that implement the logic for our service. Sequences are the building blocks of our service. We can create them from the Developer Studio dashboard by following these steps:

  1. Click on Sequence.
  2. Select Create New Sequence and click on Next.
  1. In this window, we enter this data:
    • Sequence Name: The name of the sequence
    • Save Sequence in: Project where we create the sequence

There are some advanced configurations that are not mandatory:

  • On Error Sequence: Here, we can specify which sequence will be triggered when an error occurs during the sequence flow. This behavior is similar to that described for fault sequences in proxies. If no sequence is specified, the fault sequence of the proxy that executes this sequence is thrown.
  • Available Endpoints: Here, we can select a default endpoint to send the message.
  • Make the sequence as Dynamic Sequence: This option means that the sequence will be stored in the WSO2EI registry, which allows you to share the sequence and can be stored in the two kinds of locations: Configuration and Governance. We are not using this feature due to the scope of this book, but to give a brief idea of its application, we can say that the configuration registry artifacts are shared by all the WSO2EI nodes in a cluster, while the governance registry artifacts are shared by all the WSO2 products of our environment.
  1. Click on Finish and the sequence will finally be created:
  1. We can begin implementing our sequence logic by double-clicking on the file My1stSEQ.xml in the project explorer, which will open the sequence editor:

As you may note, this editor is quite similar to the proxy editor. On the left-hand side, we have the Palette, where we can find the artifact we use to compose our logic. We just need to drag and drop components from the palette to the design section.

In most of the common scenarios, logic is implemented using mediators that allow us to modify the content of the message. We will discuss more on mediators in the subsequent chapters.

As is the case with proxies, we also have a source tab where we can see the XML code behind the design display. Consider this design:

We have the following source code for the preceding design: