Magic Software
Lesson 4Hands-on · ~25 min

Resources

Before you can wire up an integration flow, you need to define the resources the project will talk to. This lesson explains how Magic xpi centralizes those definitions and walks you through creating your first mail-server resource.

What is a resource?

Every external system Magic xpi connects to — an SMTP server, a database, a REST API, a file share — is a resource. The Resources section of the Settings dialog is the central place to define them. From the Project menu, choose Settings to open it.

Each resource carries the configuration details needed for a successful connection — for example, the host, port, and credentials for a database. You configure those details once and reference them everywhere.

Advantages of a central resource catalog

  • Reuse. The same resource can be referenced from many flows; you maintain its credentials in one place.
  • Portability. Resource configuration lives separately from the integration logic, so deploying to a new environment is just an XML swap.
  • Sharing. Resources can be shared across multiple integration projects — common for email and database connections.
Pause and think. Look ahead to the course project. Which resources are you going to need? At a minimum, an email server and a database.

Resource types

Resource types are predefined categories that share the same set of properties. Database is a resource type, for example: you may have multiple databases defined in your project (Oracle, MySQL, MSSQL), but they all share the same shape of configuration.

The shipping resource types live in <Magic xpi 4.14.1 install>\Runtime\resource_types.xml.

Hands off the type definitions. Although it's possible to modify the shipped resource type definitions, you shouldn't — only advanced developers with a strong reason should touch that file.

Adding a new resource

The Resources section is split into two panes: the left pane lists the defined resources grouped by type; the right pane shows the configuration properties of the resource you've selected.

  1. Open Project » Settings and select the Resources node on the left.
  2. Click Add. The New Resource dialog opens.
  3. Choose Email from the Resource Type dropdown — you'll use this resource later to notify the salesperson.
  4. Set the resource name to Company mail server. (You can rename a resource at any time from its context menu.)
  5. Click OK.
The small New Resource dialog asking for resource type and name
Adding a new resource — pick a type, give it a meaningful name.

Configuring the mail-server resource

Once added, the resource appears in the left pane and its properties show on the right. The set of properties depends on the resource type — for Email, you configure both incoming and outgoing servers.

Server TypePOP3 or IMAP for incoming mail; leave blank for outgoing-only configurations. Use IMAP for the course.
Incoming Mail Server / Porte.g. mail.example.com on port 110 (POP3) or 143 (IMAP).
Incoming Secure ConnectionUse SSL for the incoming connection.
Outgoing Mail Server / PortThe SMTP server (e.g. smtp.example.com); typically port 25 or 587.
Outgoing Secure ConnectionUse SSL/TLS for SMTP.
From AddressThe address messages will be sent from.
Authentication Type / User / PasswordHow Magic xpi authenticates with the mail server. Bold properties are mandatory.
Email Mail Server resource settings showing POP3, port 110, server localhost, etc.
The Mail Server resource fully configured. Bold properties are mandatory.
Always validate. After entering the values, click Validate. Magic xpi opens a connection using your settings and tells you immediately whether they are correct.

Exercise

Practice what you've learned by adding a database resource for the course data.

Database resource. Create an MSSQL database resource named Course Database that points at the course schema. You'll reference this from later lessons. Use the credentials of your local MSSQL instance and target the Magic_xpi_course database.

Loading the course database

To complete the rest of the course, load the supplied tables into your local MSSQL Server:

  1. In <Documents>\Magic\projects\Magic_xpi_course\course_data\DB\MSSQL, open runsql.bat in a text editor.
  2. Replace %1 with your database user name, %2 with your server name, and %3 with the password.
  3. Save and run runsql.bat.
  4. Open logsql.txt in the same folder to confirm that all tables loaded successfully.

Summary

You learned about the Resources section of the Settings dialog — the single location where you configure the external systems Magic xpi connects to. You created an Email resource and a Database resource, both of which you'll reuse during the rest of the course.