Skip to content

Toro Cloud Dev Center

Quick start tutorial: Creating a Martini endpoint

Estimated time to complete: 4-5 minutes

A Martini endpoint allows you to listen to certain types of events, and react to them by invoking a configured service as they occur.

There are multiple types of endpoints in Martini, and each type will have different compatibility requirements for services. Some endpoint types have overlapping requirements; hence, a service can be compatible with multiple types of endpoints.

This tutorial page will go over the process of creating an endpoint-compatible service, and an endpoint that will invoke it.

Prerequisites to creating an endpoint

This tutorial assumes you already know how to create a service from scratch. If you're unsure on how to do this, you can learn about it using the tutorial page on writing a service. That page will also teach you how to add input and output properties, add invoke steps, and run the service in the IDE.

Create the endpoint-compatible service

A service is deemed compatible with a certain type of endpoint if its parameters are of the same name and compatible type as the parameters supported by the endpoint. The service doesn't need to declare all of the parameters supported by the endpoint, but it must not have any deviating input property that must not be null1.

Consider the following service, which will be used for a new endpoint later:

Endpoint service

Endpoint service

The service above requires a string input property named content, which is printed to the console. This also means it is compatible with the following types of endpoints:

To force callers to provide an input property upon invocation, set the property's Allow Null field to false using the steps below.

Setting `Allow Null` to `false`

  1. Select the input property from the Input/Output view.
  2. If you're using Martini Desktop, open the Properties view by pressing if it isn't open yet.
  3. Change the value of Allow Null by clicking its Value column, and then selecting false from the dropdown. If the Allow Null value of a property is false, it's name will be displayed with bold text.
  4. Save the service by pressing (or by pressing the save button in the main toolbar).

Setting `Allow Null` to `false`

  1. Select the input property from the Input/Output view.
  2. Change the value of Allow Null by double clicking its Value column.

Create the endpoint

When your service is ready, you can proceed to creating your Martini endpoint. To do this:

Creating a new endpoint from a service

Creating a new endpoint from a service

  1. Right click on your endpoint-compatible service.
  2. From the appearing context menu, select New > Expose as Endpoint.
  3. A dialog will appear, prompting you for the type and name of the endpoint. For this tutorial choose JMS Listener as the Supported Type of the endpoint, and enter PrintContent as the name.
  4. Click Finish. The JMS endpoint configuration editor will appear shortly thereafter.
  5. Populate any required fields. For this tutorial, create a new topic called contentListener in the Destination field. This is done by pressing the Choose button beside it.

    I can't create topic://contentListener

    If topic://contentListener already exists, you won't be able to create it again. Instead, select it from the list of existing destinations to use it.

  6. Press to save. You may not save your endpoint unless all required fields are populated.

  7. Start the endpoint by clicking on the green arrow button on the top right-hand side of the JMS editor.

Editing an existing endpoint

If you're unsatisfied with your settings, you can still edit your endpoint anytime later. To edit your endpoint, open the endpoint configuration editor by double clicking your endpoint from the Navigator, and make sure it's stopped (by clicking on the red square icon on the top right-hand side of the endpoint editor).

Once in the editor with a stopped endpoint, you can edit field values as usual, and then press to save. You can also test if your configuration works as expected using the Test Configuration button on certain endpoints. Also, don't forget to start your endpoints when you're done!

Creating a new endpoint from a service

Creating a new endpoint from a service

Invoke the endpoint

Triggers differ from endpoint to endpoint, depending on the endpoint's type and configured properties. Only a started endpoint can be triggered.

This tutorial uses a JMS listener endpoint which is triggered when a JMS message is sent to the topic or queue that the JMS listener is subscribed to. So to see the endpoint in action, you can either:

  1. Use functions to send a JMS message.
  2. Use Martini's JMS Message Publisher dialog.

When an endpoint is triggered, it will invoke its configured service. In this case, the PrintContent endpoint will run when a message is received on the contentListener JMS topic. This will invoke the PrintContent.gloop service, which will in turn print the content of the JMS message to the console.

Open the console

Views can be opened and closed. To ensure your respective instance's Console view is visible, right click your instance from the navigator, and then select "Open Martini Console". This view will display logs received by your instance in real time.

To test the endpoint:

  1. Right click on the endpoint in the Navigator.
  2. Select Send JMS Message.
  3. Enter some sample text in the text area, and then click Send. You can send as many messages as you like.

You can close or move the dialog to get a better view of the messages logged in the Console view. If the service has been implemented properly, the content of the JMS message will be logged to the console.

Creating a new endpoint from a service

Creating a new endpoint from a service

  1. Your service can have deviating properties, as long as these properties are optional; or in other words, have Allow Null set to true

  2. The content property is used when Martini receives a TextMessage