Skip to content

Home

Development

IDEs

API Explorer

Releases

Release notes

Martini Runtime

Martini Desktop

Martini Online

Feature requests

Bug reports

examples package: Martini endpoints

The examples package contains Martini endpoints of different types to demonstrate their capabilities and possible configurations.

The examples package's endpoints are configured to use the following services, which are collectively under the endpointServices package:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
examples
├── ...
└── code
    └── endpointServices
        ├── gloop
        │   ├── emailExamples
        │   │   └── ReadEmailAttachments.gloop
        │   ├── fileExamples
        │   │   ├── LogToFile.gloop
        │   │   └── SendToRemoteLocation.gloop
        │   └── ...
        └── groovy
            ├── EmailExamples.groovy
            └── ...

You will notice that each service has a Gloop and Groovy version. It is possible to configure any of the endpoints so that they call the Gloop service instead of the Groovy service or vice versa.

Try it!

The examples package's endpoints are easily accessible under the Endpoints node, under the examples package in the Navigator view. See the available endpoints in action simply by enabling and starting them.

`examples` package's endpoints

Some of the endpoints in the examples package need to be set up before services can be invoked. In the following sub-sections, we'll run you through the setup process of each endpoint.

Directory watcher endpoint

A directory watcher endpoint is not pre-configured in the examples package, so you must create one1. For example purposes, TORO recommends you use any of the following services as the endpoint's service:

Type Service
Gloop endpointServices.gloop.fileExamples.SendToRemoteLocation.gloop
Groovy endpointServices.groovy.FileExamples.sendToRemoteLocation(byte[], String)

Either service requires that you configure the FTP credentials to be used. You can do this by setting the following properties in the package.properties file:

Key Description
ftp.host FTP server host
ftp.username FTP server username
ftp.password FTP server password
ftp.protocol FTP server
Not enough time to setup your own FTP server?

There are public FTP servers like DLP Test if you want a quick way to set up an FTP server.

To trigger the endpoint, you must either add, modify, or delete a file in the directory configured for the endpoint. This all depends on which actions you have configured the endpoint to respond to.

The result of the endpoint invocation depends on the configured service. For the services above, you should expect the file that triggered the service to be uploaded to the configured FTP server.

Email endpoint

An example email endpoint is not provided out-of-the-box, which is why a new endpoint must be created. The following properties must also be configured:

Key Description
protocol Protocol of the SMTP server
server Host of the SMTP server
port Port of the SMTP server
login Username used for the SMTP server
password Password used for the SMTP server

TORO recommends you use any of the following services as the endpoint's service:

Type Service
Gloop endpointServices.gloop.emailExamples.ReadEmailAttachments.gloop
Groovy endpointServices.groovy.EmailExamples.readEmailAttachment()

Send service response as reply

You can easily reply to received messages via the "Send service response as reply" option. With this, the message returned by the service is sent as the response when the endpoint gets triggered by a received email.

To trigger the endpoint, send an email to the email address configured for the endpoint.

The result of the endpoint invocation depends on the configured service. For the services above, you should expect the email received to be logged to the console.

FTP client endpoint

Since there is no example created by default, you must create the FTP client endpoint. You can use any of the following services as the service of the endpoint:

Type Service
Gloop endpointServices.gloop.FileExamples.LogToFile.gloop
Groovy endpointServices.groovy.FileExamples.logFileChange()

To trigger this endpoint, add, update, or delete a tracked file from the configured FTP/FTPS/SFTP server. Which action to perform depends on the type of events tracked by this endpoint.

The result of the endpoint invocation depends on the configured service. For the services above, you should expect the name of the file that triggered the service to be logged to the console.

JMS listener endpoint

The example JMS listener endpoint is already configured; all you need to do is to start the JMSListenerExample endpoint of the examples package.

You may use any of the following services as the endpoint's service:

Type Service
Gloop endpointServices.gloop.JMSExamples.ReceiveJMS.gloop
Groovy endpointServices.groovy.JMSExamples.receiveJMS(Message)

Once the JMSListenerExample endpoint is enabled and started, the JMS queue queue://exampleJMSListener will be available, and will wait for JMS messages to be sent. The endpoint gets triggered when a message is sent to the queue.

Invoke SendJMSMessage.gloop or JMSExamples.sendJMSMessage(String, String) to publish a message to the aforementioned JMS destination. Upon endpoint invocation, you should expect a log message like below:

1
INFO  [Martini] Received a reply for message "Martini Desktop.". The reply text is: Received message with id: ID:TORO-MBP20-49485-1559606518516-2:1:6:3:1. Message acknowledged
Durable JMS listener

Another JMS listener endpoint, called JMSListenerDurableExample, is included in the examples package. This endpoint demonstrates how a JMS listener endpoint with a durable subscription behaves.

RSS endpoint

The example RSS endpoint is already created and configured; all you need to do is enable and start the RSSExample endpoint.

You may use any of the following services as the endpoint's service. Either service logs RSS entries found to the Martini console.

Type Service
Gloop endpointServices.gloop.rssExamples.RssReader.gloop
Groovy endpointServices.groovy.RSSExamples.rssReader()

Upon starting the endpoint, the configured service will be called, and then re-invoked at every polling interval. Log messages like below are expected every time the endpoint is invoked:

1
2
3
4
5
6
INFO  [RomeRunnableTrigger] Found '5' entries from RSS feed 'http://localhost:8080/api/example/server/rss?dataFormat=xml'
INFO  [Martini] Found a new RSS item with title Title 1
INFO  [Martini] Found a new RSS item with title Title 2
INFO  [Martini] Found a new RSS item with title Title 3
INFO  [Martini] Found a new RSS item with title Title 4
INFO  [Martini] Found a new RSS item with title Title 5

Scheduler endpoint

The example scheduler endpoint is already created in the examples package. Before enabling the scheduler endpoint, you must first open the package.properties file and configure the email credentials. Properties required are enlisted and described in the table below:

Key Description
protocol Protocol of the SMTP server
server Host of the SMTP server
port Port of the SMTP server
login Username used for the SMTP server
password Password used for the SMTP server
email.bulk.to Comma-separated email addresses that will receive the email

After configuring these properties, you may proceed to enabling and starting the SendScheduledEmail endpoint.

Use any of the following as the endpoint's service.

Type Service
Gloop code.endpointServices.gloop.schedulerExamples.SendScheduledEmail.gloop
Groovy code.endpointServices.groovy.SchedulerExamples.sendScheduledEmail()

The endpoint will be invoked after every configured interval. Once invoked, either of the services above will send an email to the configured recipients.

Tracker resubmit endpoint

The example Tracker resubmit endpoint is already configured, all you need to do is enable and start it to see the endpoint in action. Take note that this endpoint is dependent on the RSS endpoint (RSSExample), so the RSS endpoint needs to be enabled and started as well before you can use Tracker resubmit endpoint.

You may use any of the following services as the endpoint's service:

Type Service
Gloop endpointServices.gloop.trackerResubmitExamples.Resubmit.gloop
Groovy endpointServices.groovy.TrackerResubmitExamples.resubmit()

Enabling this endpoint allows RSS documents of Started states2 to be resubmitted in the Tracker interface. Upon resubmitting an RSS document, you will notice a Resubmit Count property added to it.3

`Resubmit Count` property

`Resubmit Count` property

REST alias endpoint

As the REST alias endpoint is already configured, all you need to do is enable and start the RestAliasExample endpoint of the examples package.

TORO recommends you use any of the following services as this endpoint's service:

Type Service
Gloop code.endpointServices.gloop.JMSExamples.SendJMSMessage.gloop
Groovy code.endpointServices.groovy.JMSExamples.sendJMSMessage()

To trigger this endpoint, enable the JMSListener endpoint, and send a GET request to <host>/api/sendJMSMessage?jmsQueue=queue://news&messageContent=Hello. You should receive a response similar to:

1
2
3
{
    "reply": "Received message with id: ID:TORO-MBP20-49419-1559692612334-2:1:9:3:3. Message acknowledged"
}

  1. Directory watcher endpoints are not supported in Martini Online. 

  2. Conditions are specified in the endpoint's configuration. 

  3. Courtesy of the configured endpoint service.