Martini Invoking Services via a Jabber Trigger
Jabber triggers enable services within Martini to be invoked automatically upon receiving instant messages, facilitating interactive applications and automated responses.
Properties
In addition to general configurations, Jabber-specific settings allow for detailed customization of the trigger's behavior.
Jabber-Specific Configuration
Name | Default | Description |
---|---|---|
Username | (required) | The Jabber client username. |
Password | (required) | The Jabber client password. |
Host | (required) | The host address of the Jabber server. |
Port | 5222 |
The port number for the Jabber server. |
Service Name | (required) | The XMPP service name, typically the domain part of Jabber IDs. |
Reply with Service Response | false |
When enabled, automatically replies with the service's returned value, limited to string responses. |
Use Object Converter on Service Response | false |
Allows the trigger to respond with an object converted through Martini's object converter if enabled. |
Advanced Configuration
Advanced settings provide further options for customization, enhancing security and connection stability.
Name | Default | Description |
---|---|---|
Security Mode | Default |
Configures the TLS security mode for connections. |
Ping Interval (s) | 20 |
Frequency of server pings to maintain connection, defaulting to 20 seconds. |
Connection Timeout (ms) | 50000 |
Time to wait for a TCP connection to establish, set at 50000 milliseconds by default. |
Packet Reply Timeout (ms) | 10000 |
Timeout for waiting on a packet reply, with a default of 10000 milliseconds. |
Resource Name | jabber/{endpoint_name} |
Sets the resource for the connection. If null, the server automatically creates a resource. |
Keystore Path | Path to the KeyStore file for client authentication, if required. | |
Keystore Type | Type of the KeyStore, if used. | |
PKCS11 Library | Location of the PKCS11 library file, necessary for PKCS11 KeyStore types. | |
Enable Compression | false |
Enables stream compression to reduce network traffic, effective after TLS establishment and server support. |
Allow Empty Username | false |
Permits a null or empty string as username, useful for certain SASL mechanisms. |
Allow Reconnection | true |
Enables automatic reconnection to the server upon disconnection. |
Send Presence | false |
Determines whether an initial available presence is sent to the server, indicating the client is online and available to receive messages. Set to false to log in without being 'noticed'. |
Service Parameters
Jabber-specific parameters enable detailed control over how messages are processed and responses are formulated.
Name | Type | Description |
---|---|---|
message |
Message |
The received message object. |
content |
String |
The body of the message, or null if not set. |
error |
XMPPError |
Any error associated with the message, or null if none. |
chat |
Chat |
Jabber chat instance for sending messages and performing other operations. |
to |
String |
The recipient of the message, or null if not set. |
from |
String |
The sender of the message, or null if not set. |
subject |
String |
The subject of the message, or null if not set. |
language |
String |
The language of the message, or null if not set. |
threadId |
String |
Unique identifier for a sequence of chat messages, or null if not set. |
Jabber Triggers
Jabber triggers in Martini allow services to be invoked in response to incoming instant messages, facilitating real-time interactions and automation based on chat messages.
Properties
General configurations apply, with Jabber-specific settings available for tailoring the trigger's behavior to your needs.
Jabber-Specific Configuration
- Username (required): The Jabber client username.
- Password (required): The Jabber client password.
- Host (required): The host address of the Jabber server.
- Port: The port number for the Jabber server, with a default of
5222
. - Service Name (required): The XMPP service name, typically the domain part of Jabber IDs.
- Reply with Service Response: When enabled, the trigger will automatically reply with the service's return value, limited to string responses.
- Use Object Converter on Service Response: If enabled, allows the trigger to respond with an object converted through Martini's object converter.
Advanced Configuration
Advanced settings provide additional customization options, including security, connection management, and compression.
- Security Mode: Configures the TLS security mode for connections.
- Ping Interval (s): The frequency of server pings to maintain the connection, defaulting to 20 seconds.
- Connection Timeout (ms): The wait time for a TCP connection to establish, set to 50000 milliseconds by default.
- Packet Reply Timeout (ms): The timeout for waiting on a packet reply, with a default of 10000 milliseconds.
- Additional advanced properties include Resource Name, Keystore Path, Keystore Type, PKCS11 Library, Enable Compression, Allow Empty Username, Allow Reconnection, and Send Presence, each offering specific enhancements and adjustments for the trigger.
Service Parameters
The Jabber trigger provides various parameters to handle incoming messages and to facilitate specific responses.
Jabber-Specific Parameters
Parameters such as message, content, error, chat, to, from, subject, language, and threadId are available, providing extensive control over how messages are processed and responses are generated.
Examples
Groovy as Service
The following example demonstrates a Groovy service designed for a Jabber trigger, engaging users in a number guessing game by analyzing and responding to their messages.
1 2 3 4 5 6 7 8 |
|
This example highlights how to use the Jabber trigger to create interactive, chat-based services. By leveraging the properties of the injected Message
object, the service can guide user interactions, providing a dynamic and engaging experience.
For further exploration, the Martini package examples
contains additional services demonstrating more use cases, offering a comprehensive guide to harnessing the power of Jabber triggers in your Martini applications.