consumer Assembly Project

Overview

In this tutorial, you will learn how to build Assemblies as reusable and configurable projects. You will gain experience composing Assemblies and integrating them into existing Projects to quickly create fully customized Applications.

In this tutorial you will:

  • Import an existing Project which detects “dangerous” weather conditions and either warns residents or orders an evacuation
  • Convert the imported Project into an Assembly and generalize it such that any data source and conditions may be used to trigger warning and evacuation alerts
  • Publish the Assembly to the Catalog
  • Install the Assembly from the Catalog as a consumer and configure it to meet the consumer’s requirements

A brief note on terminology:

  • An Assembly author is the creator of the Assembly and usually the person who published the Assembly to the Vantiq Catalog.
  • An Assembly consumer is a user who has installed the Assembly from the Catalog and is configuring the Assembly to integrate it into their Application.

Part 1: Setting up the Catalog

This tutorial assumes you are already familiar with the Vantiq Catalog. To learn about the Catalog, follow the full Catalog Tutorial.

If you’re already familiar with the Catalog, follow Part 1 of the Catalog Tutorial to set up a Catalog host namespace, a publisher namespace, and a subscribing (consuming) Namespace for the Assembly.

Part 2: Creating the Assembly

Import the Project

To begin creating an Assembly, start by importing a fully functioning Project. The goal is to generalize this Project such that it can be customized to report warnings and evacuation alerts for any type of data using the conditions specified by the Assembly consumer.

In the publisher Namespace created in Part 1, using the Projects button, select Import.

Select Contributions as the Import Type and com.vantiq.weatherEmergencies.WeatherEmergencyProject as the Contribution. Click Import.

Project import

Click Reload once the import is completed. You have just imported a project that you will convert into an Assembly.

As an overview, the key resources in this Project are all in the com.vantiq.weatherEmergencies package:

  • The weather Source which sends data to the DetectWeatherEmergency App.
  • The DetectWeatherEmergency Service uses the isDangerousWeather App Component to detect whether there are dangerous weather conditions and triggers corresponding Collaboration Types
  • The Collaborations send warning or evacuation notifications to be displayed by the ResidentNotificationSystem Client.

Project overview

Convert the Project into an Assembly

Using the Projects button, select Convert To Assembly and then click Convert to Assembly in the confirmation dialog. This converts the Project from a static definition to a configurable, reusable, and shareable Assembly.

Set the description for the Assembly to:

Detects whether unhealthy weather conditions are present and notifies residents with a warning or evacuation alert

Click Save to save the Assembly.

Assembly Pane

Creating the Assembly Interface

When Assemblies are installed by consumers, they act as black boxes to provide high level, reusable tools. Consumers can only interact with the Assembly through the Assembly Interface.

The Assembly Interface is defined by the Event Driven Services the author chooses to expose. Event Driven Services contain inbound and outbound Event Types which provide a layer of abstraction between the implementation of the Assembly’s asynchronous behavior and its consumers. Event Driven Services also define
Procedures that may be invoked by consumers.

In this Project, the com.vantiq.weatherEmergencies.DetectWeatherEmergency Service exposes Event Types from the com.vantiq.weatherEmergencies.DetectWeatherEmergency App which is the core event processing logic in the Assembly. This allows consumers to send events
to the Assembly and react to events produced by the Assembly. The com.vantiq.weatherEmergencies.WeatherService provides some common Procedures for transforming weather events such as convertToFahrenheit.

Navigate to the Interface tab of the Assembly Pane and click Manage Services to expose existing Services to the Assembly Interface.

Manage Services

Select com.vantiq.weatherEmergencies.WeatherService and com.vantiq.weatherEmergencies.DetectWeatherEmergency and click OK.