Typical uses of listeners include:
- Microservices.Microservices are autonomous and independent. For example, Service-1 requires access to Service-2, even when it is down. Some brokers, such as MQTT and Kafka, provide message queuing for delayed delivery. You can use listeners to process these messages.A typical listener might accept the message, convert to a JSON/XML string, and invoke thelistenerUtil.restPOST/PUTmethod. This method activates interface logic, which then activates reactive logic.
- Internet of Things (IoT).IoT devices use MQTT. You can establish listeners to handle these messages. Typical IoT processing persists the message. You can modify or validate inbound data, with extra automation (persistence and object model), by declaring reactive logic events.
- DevOps.CA Live API Creatorcan also invoke listeners when the server starts. You can then register with a service discovery platform, such as Consul, or self-configure the server (for example, set data source connection parameters).
In this article:
The following diagram shows the workflow for creating a listener in API Creator:
Connections are a set of properties that defines how to connect to an external system. MQTT, Kafka, RabbitMQ, and Java Message Service (JMS) listeners require a connection.
For more information about connections, see Create Connections.
You can create the following types of listeners in API Creator.
For information about how to create MQTT listeners, see MQTT Listeners.
For information about how to create Kafka listeners, see Kafka Listeners.
For information about how to create RabbitMQ listeners, see RabbitMQ Listeners.
For information about how to create JMS listeners, see JMS Listeners.
Startup and Shutdown Listeners
CA Live API Creatorinvokes whenever you start the
CA Live API Creatorstarts. More specifically, API Server executes it every time the
CA Live API CreatorWAR file starts. If the infrastructure support engineer or the system administrator restarts
CA Live API CreatorWAR file, the listener is again executed.
If you are running
Shutdown listeners are the mirror image of startup listeners.
CA Live API Creatorinvokes shutdown listeners whenever you stop the
CA Live API Creatorserver.
If the container (for example, Apache Tomcat, Jetty, IBM WebSphere, and Oracle WebLogic) suffers a serious failure,
CA Live API Creatormight not invoke shutdown listeners upon shutdown.
For more information:
CA Live API Creatormaintains a log of its activity in the admin database.
CA Live API Creatoralso generates logs for listener code that uses the
You can display the details for a log entry by clicking the log entry. You can search for a log entry by timestamp and the listener or connection name or the log summary. You can also refresh the list by clicking
Refreshor by selecting the
Auto-refreshcheckbox. You can purge log entries from the database by clicking
Delete All Logs.
You can access the following details for your listener logs on the Logs tab:
The date and time
CA Live API Creatorgenerated this log entry.
The description for this log entry.
The logging level for this log entry.
The name of the listener or connection.
Defines the protocol that you want
CA Live API Creatorto follow to establish a link to an external system to exchange information.
Values:MQTT, Kafka, RabbitMQConsumer, or JMSConsumer
The identifier of the server that created the log entry.
The listener or connection parameters.
This log detail is not available for log entries that originate inside the listener code.
The log entry in JSON format.
Listeners are either active or inactive. Active listeners are enabled in the API and inactive listeners are disabled in the API. API Server executes the listener code when it receives messages only for active listeners. You can mark a listener as active or inactive by selecting or clearing the
Listeners in the "Running" status have initialized themselves successfully based on the configured connection. Listeners in the "Stopped" status have issues with the configured connection, with the listener parameters, or with the code.
You can view the listener status from the status icon that appears at the top of the page in API Creator. The following image shows a startup listener in the "Stopped" status:
The status is based on the following factors:
- The validity of the parameters.
- The status of the underlying connection.
- Exceptions in the listener code that are causing the connection to fail.
Troubleshoot listener issues using the log entries. Click
Refreshor select the
You can also view a listener's status using the icon that displays to the left of the listener name in the list of listeners:
The listener is in the "Running" status and is active.
The listener is in the "Stopped" status and is active.
The listener is in the "Stopped" status and is inactive.