0
votes

I am absolutly new in WSO2 ESB and I have the following doubt about how can I correctly "refactor" my project.

I have a project that works pretty well. This project is growing in dimension and I have some doubts about how keep it neat.

It try to explain the situation in details.

At the beginning I only had a single API. The API flow is pretty complex so I split it in multiple sequences.

So I have the main API file that , something like this:

<?xml version="1.0" encoding="UTF-8"?>
<api context="/MY_API_1" name="MY_API_1" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET" uri-template="/{sampleId}">
        <inSequence>
            <property expression="get-property('uri.var.sampleId')" name="samplePK" scope="default" type="STRING"/>
            <log level="custom">
                <property expression="$ctx:samplePK" name="SAMPLE ID (PK)"/>
            </log>

            <!-- DO SOME OPERATIONS -->

            <!-- GO TO THE CODE DEFINED INTO THE sampleDataSequence -->
            <sequence key="sampleDataSequence"/>

            <!-- DO SOME OTHER OPERATION THAT QUIT THE "MY_API_1" API FLOW -->

        </inSequence>
        <outSequence>
            <send/>
        </outSequence>
        <faultSequence/>
    </resource>
</api>

As you can see in the previous code I'm specifying that at a certain point the flow definition is defined into the sampleDataSequence sequence, that is this file \glis-toolkit\glis-toolkit\src\main\synapse-config\sequences\sampleDataSequence.xml (so it is defined into the sequences folder in my project).

In turn also into the sampleDataSequence.xml there are some sequences definition (because my flow is pretty big and I splitted it into different logical sections).

It works pretty fine. The problem is that now I am creating a second API that have to be splitted in different sequences. So I know that I can put it all these new sequences into the same \synapse-config\sequences folder of my project. But I think that it is pretty horrible because I will have a lot of sequences file into the same folder related different APIs generating confusion.

There is a way to put the sequence file of the new API into a different folder? Or a sub folder of the \synapse-config\sequences folder (something like: **\synapse-config\sequences\myApi2**)

My problem is that (from what I know) to insert a sequence into the flow I do something like:

<sequence key="mySequence"/>

that will insert the mySequence.xml file content taking it automatically from the \synapse-config\sequences folder.

Can I specify that the mySequence.xml file is into another folder or in a subfolder of my \synapse-config\sequences folder?

1

1 Answers

0
votes

It might be easier to organize your sequences as you desire to if you move them to a registry resources project. Then you can reference your sequences in the appropriate file structure:

<sequence key="gov:/sequences/myApi2/mySequence"/>

Don't forget to add your registry resources project to your CAR project, so that those sequences are deployed with the rest of your esb config project.