In a
previous blog post we gave a functional description of the pizza preparation process. For this we used the image below. Till now we only have implemented the bottom part ‘the preparation of a single pizza’.
In this post we will do the next step. The preparation of a complete order, containing potentially multiple pizzas. We will do this in a separate process. So let's start by creating a new process in the preparation application. We gave it the self explaining name OrderPreparationProcess.
Next we created the process flow. We used the baby-step approach to implement to flow, for this reason we start with all components in draft mode.
Make sure to define the subprocess as Multi instance. For now is does not matter yet if it’s sequential or parallel.
First thing to do is feed the flow with some data. We know the data format for a single pizza. An order consist of one or multiple pizzas, so we need a list for that. Besides that we need information about the customer, like name and address. For demo purposes we have limited the amount of data, but in a real life scenario, more data is needed. But we assume you get the point. So let's go.
Start with creating a new Business Object for an order. We called it OrderPreparationBO
Click next to get to the attributes page.
Then, click the Plus sign to add an attribute
After giving a name, select ‘Change Type’ to specify a list of PizzaPreparationsBO’s.
After clicking OK, the attribute is defined as shown below
Click add, to add it to the new Business Object.
We also added the general customer data attributes as shown here.
Now we have defined the input payload format of an order. Next we need to define the output format of the order. Because we don’t want to make it to complicated we have used a String simple type for that, which means that no Business Object is needed.
Now that we have defined the input and output format we can start using them in the process. First we will do the input. Open the properties of Start Order and click the pencil next to Define Interface.
Add the payloadIn argument with type OrderPreparationBO.
That’s all, the input payload is specified.
Do the same for the output.
Now we have defined both the input and output, but of course the data also needs to flow through the process. First lets create a Data Object for that. After selecting the Start Order Message Event open the Data Associations via the button in the top right corner.
In here we see on the left side our order Payload. On the right side we see the Data Objects. In there, add a new Data Object to store the order.
After creating the Data Object, the order can be associated.
Do something similar for the output. We just return the constant value ‘Done’.
Perhaps it is somewhat boring or disappointing but let see the result so far to go. Deploy the application and create some instances with for example SoapUI.
After submitting a soap call with an order containing three pizza the process has the following flow.
And in Tree view mode, we do see that three subprocesses have been executed. So we are on the right track.
What’s next?
In coming posts we will continue to complete the picture. Next part will be the call out to the pizza preparation process from the multi instance subprocess. After that we will extend it with a Decision Model and custom Correlation. And of course besides these topics we will also continue to blog about other PCS features.
No comments:
Post a Comment