RSS endpoint
The RSS endpoint enables developers to write applications that invoke a configured service when changes occur in an RSS feed.
Properties
General configuration
Property | Default | Description |
---|---|---|
Name | (required) | The name of the endpoint. |
Service | (required) | The service to execute when the endpoint is triggered. |
Run As | Anonymous |
The user to run the service in behalf of. This is logged to Tracker. |
Document Type | <Name of endpoint type> | The document type to be used when adding documents to Tracker as this endpoint is triggered. |
Auto Start | true |
Whether or not to automatically start the endpoint upon package startup. |
Log To Tracker | false |
Flag determining whether executions should be logged to Tracker. |
Replicated | true |
If this endpoint is configured on a Martini instance that's running in a cluster, replicated will determine whether to run the endpoint on all instances, or only the elected leader node in the cluster. When this is checked, all instances will run the endpoint. When it's unchecked, only the leader node will run the endpoint. |
RSS-specific configuration
Property | Default | Description |
---|---|---|
URL | (required) | The URL hosting the RSS feed. |
Polling Interval | (required) | The interval in seconds, at which Martini checks for changes in the RSS feed. |
Only New Entries | false |
When checked, only 'unread' entries in the RSS feed will be sent to the service. |
Service
When the endpoint is triggered, the following variables are exposed to the configured service:
General parameters
Name | Type | Description |
---|---|---|
$trackerId |
java.lang.String |
The Tracker document internal ID. If the endpoint was configured to not track, this value will be null . |
$tracker |
io.toro.martini.tracker.Tracker |
The Tracker object. If the endpoint was configured to not track, this value will be null . |
martiniPackage |
MartiniPackage |
The Martini package that contains the endpoint. |
parameters |
java.util.Map |
A map containing all the endpoint specific parameters. |
properties |
java.util.Map |
A map containing containing all the properties associated with the endpoint. |
RSS-specific parameters
Name | Gloop Object | Description |
---|---|---|
context |
GloopObjectObject (org.quartz.JobExecutionContext) |
The Quartz context. |
jobDataMap |
GloopObjectObject (org.quartz.JobDataMap) |
The Quartz job data map. |
job |
GloopObjectObject (org.quartz.Job) |
The Quartz job. |
feed |
io.toro.martini.rss.Feed |
The Model containing the RSS feed. |
entries |
io.toro.martini.rss.Entry[] |
The list of entries in the RSS feed. |
entry |
io.toro.martini.rss.Entry |
The newest entry in the feed. |
Name | Type | Description |
---|---|---|
context |
org.quartz.JobExecutionContext |
The Quartz context. |
jobDataMap |
org.quartz.JobDataMap |
The Quartz job data map. |
job |
org.quartz.Job |
The Quartz job. |
feed |
SyndFeed |
The object containing the RSS feed. |
entries |
List<SyndEntry> |
The list of entries in the RSS feed. |
entry |
SyndEntry |
The newest entry in the feed. |
Example
Gloop as service
Consider the following input of a service:
We can write an application that prints the contents of the RSS feed that triggered the endpoint:
- (1) This line will iterate over the
entries
. - (2) Every item is printed using the logger.
Groovy script as service
Consider this Groovy script that simply prints the available variables in the context:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
When the endpoint is triggered - in this case, the polling interval has elapsed - the console will show logs similar to the following:
1 2 3 4 5 6 7 8 9 |
|
Groovy function as service
We can also use a function from a Groovy class, and use the available properties as function parameters:
1 2 3 4 5 6 7 8 |
|
This iterates the list of SyndEntry
provided by the entries
variable and prints the title with the logger.
Want more examples?
The distribution ships with a Martini package called examples
, which contains services demonstrating more use
cases.