< Previous | Next >

Lesson 1.3: Adding events, subscriptions, and metrics

Before you begin, you must complete Lesson 1.2: Creating monitor models.
In this lesson you will continue working on your monitor model. For the first task, make sure that you have imported the Sample Resources into your workspace.

Adding event definitions

  1. From the Project Explorer view, right-click on the Event Definitions folder and click Import.
  2. From the Import wizard, click General > File System, then click Next.
  3. Click Browse next to the From directory field, and then find and select the directory of your current workspace. Click OK.
  4. On the left side of the panel is a list of directories within your workspace. Select SampleResources. On the right side is a list of files. Select LimousinesEvents.xsd.
  5. Click Browse located next to the Into folder field.
  6. Select the Limousines_Part_1 folder and click OK, then click Finish.

Adding inbound event subscriptions

  1. Right-click on the Trip MC definition, then click New > Inbound Event. The Create New Inbound Event wizard opens.
  2. Enter carDispatched in the Name field. This is the name of this inbound event.
  3. Click OK. The right panel shows the Inbound Event Details.
  4. Enter a brief description for this inbound event. For example, enter event reporting that a limousine has been dispatched for a trip.
  5. Scroll down and look for the Event Type Details. In the Event parts table, click Add. The Create an event part type wizard opens.
  6. Enter content in Name field of the wizard. The ID field is populated with the same value automatically.
  7. In the Type field, click Select Type. The Select event part data type wizard opens.
  8. From the wizard, select Choose the data type from the XML schemas accessible from this monitor project and expand the LimousineEvents.xsd file. Select lmo:dispatchLimousine and click Finish.
  9. Click Finish in the Create an event part type wizard.
  10. Scroll down to the Filter Condition section.
  11. Inside the Filter Condition field, enter the expression fn:exists(carDispatched/content/lmo:limousineId). You can use the Content Assist feature of the product to build your XPath expression. To invoke Content Assist, press Ctrl+Space.
  12. Scroll down to the Correlation Expression. Inside the Correlation Expression field, enter the expression carDispatched/content/lmo:tripId = tripKey.
  13. For the If no instances are found field, select Create new instance.
  14. For the If one instance is found field, select Treat as error.
  15. For If multiple instances are found field, select Treat as error.
  16. Save your project.
Complete this task by repeating the steps above using the values given in the table below for the remaining inbound events.
Table 1. Limousine business inbound event subscriptions
  carDispatched passengerPickedUp passengerDroppedOff
Description event reporting that a limousine has been dispatched for a trip event reporting passenger pickup event reporting trip completion (arrival at destination)
Event part name and identifier content Content content
Event part type lmo:dispatchLimousine lmo:pickUpPassenger lmo:dropOffPassenger
Event part path cbe:CommonBaseEvent/lmo:dispatchLimousine cbe:CommonBaseEvent/lmo:pickUpPassenger cbe:CommonBaseEvent/lmo:dropOffPassenger
Filter conditions fn:exists( carDispatched/content/lmo:limousineId ) fn:exists( passengerPickedUp/content/lmo:limousineId ) fn:exists( dropOffPassenger/content/lmo:limousineId )
Correlation expression carDispatched/content/lmo:tripID=tripKey passengerPickedUp/content/lmo:limousineId=limousine and tripStatus='picking up passenger' passengerDroppedOff/content/lmo:limousineId=limousine and tripStatus='passenger on board'
No instances found Create new instance Treat as error Treat as error
One instance found Treat as error Deliver to the instance Deliver to the instance
Multiple instances found Treat as error Treat as error Treat as error

Adding metric definitions

  1. From the monitor model outline, right-click on the Trip monitoring context definition, then click New > Metric.
  2. Fill in the Create New Metric wizard with the following values: dropOffActualTime, dropOffActualTime, and DateTime, then click OK. The metric is added into your monitor model.
  3. On the right panel there is additional information you can fill out for this metric. For example, type the actual passenger drop-off time in the description field.
  4. Save your project.
Complete this task by repeating the steps above using the values given in the following table for the remaining metric definitions.
Table 2. Limousine business metrics
Name Description Type Default value Other
tripKey unique identifier for this trip xs:string   MC key; length <= 64
dropOffActualTime the actual passenger drop-off time xs:dateTime    
dropOffScheduledTime the scheduled passenger drop-off time xs:dateTime    
dropOffAddress the trip destination address xs:string   length <= 256
driver the name of the driver xs:string   length <= 64
limousine the limousine number dispatched for this trip xs:integer    
passenger the name of the passenger xs:string   length <=64
pickUpAddress the passenger pick-up address xs:string   length <= 256
pickUpActualTime the actual passenger pick-up time xs:dateTime    
pickUpScheduledTime the scheduled passenger pick-up time xs:dateTime    
pickUpWasLate indicator that passenger pickup was more than 10 minutes late xs:boolean fn:false()  
timeDispatched time at which car was dispatched for this trip xs:dateTime    
tripDuration the duration of the trip xs:duration    
tripStatus 'picking up passenger'/'passenger on board'/'completed on time'/'completed not on time'/'unknown' xs:string 'unknown' length <= 24

Mapping inbound events to metrics

  1. From the monitor model outline, click on the dropOffActualTime metric. There is additional information about this metric on the right side.
  2. In the additional information, scroll down to the Metric Value Expressions section, and click the Add button.
  3. Click on the field under the Expression column. The default value in the field is <<No expressions specified>>.
  4. Enter passengerDroppedOff/content/lmo:timestamp in that field or you can click the button with three dots. The Expression Dialog window opens. You can enter the path expression in the Expression Dialog window. Alternatively, you can press Ctrl+Spacebar on your keyboard to open the content-assist window. Expand the tree and navigate through the path until you have selected the entire path.
  5. Press the Enter key, then click OK. The expression is now displayed in the field.
  6. Save your project.
Complete this task by repeating the steps above using the values given in the table below for the remaining map expressions.
Table 3. Limousine business maps
Metric Map
tripKey carDispatched/content/lmo:tripId
dropOffActualTime passengerDroppedOff/content/lmo:timestamp
dropOffScheduledTime carDispatched/content/lmo:dropOffTime
dropOffAddress fn:concat(carDispatched/content/lmo:dropOffAddress/lmo:street, ', ', carDispatched/content/lmo:dropOffAddress/lmo:city)
driver carDispatched/content/lmo:driver
limousine carDispatched/content/lmo:limousineId
passenger carDispatched/content/lmo:passenger
pickUpAddress fn:concat(carDispatched/content/lmo:pickUpAddress/lmo:street, ', ', carDispatched/content/lmo:pickUpAddress/lmo:city)
pickUpActualTime passengerPickedUp/content/lmo:timestamp
pickUpScheduledTime carDispatched/content/lmo:pickUpTime
pickUpWasLate if ( fn:exists( pickUpActualTime ) ) then pickUpActualTime > pickUpScheduledTime+ xs:dayTimeDuration('PT10M') else pickUpWasLate
timeDispatched carDispatched/content/lmo:timestamp
tripDuration if (fn:exists(dropOffActualTime) and fn:exists(timeDispatched)) then dropOffActualTimel - timeDispatched else tripDuration
tripStatus if ( fn:exists( dropOffActualTime ) ) then ( if ( dropOffActualTime <= dropOffScheduledTime ) then 'completed on time' else 'completed not on time' ) else if ( fn:exists( pickUpActualTime ) ) then 'passenger on board' else if ( fn:exists( timeDispatched ) ) then 'picking up passenger' else 'unknown'

Lesson checkpoint

Now you are ready to deploy your monitor model. Lesson 1.4: Deploying the monitor model.

< Previous | Next >