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 declarative business 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 event rules.
- 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 CreatorWAR file starts. If the infrastructure support engineer or the system administrator restarts the
CA Live API CreatorWAR file,
If have configure
CA Live API Creatorto run as a cluster,
Shutdown listeners are the mirror image of startup listeners.
CA Live API Creatorinvokes shutdown listeners whenever you stop API Server.
If the Java container (for example, Apache Tomcat, Jetty, IBM WebSphere, or Oracle WebLogic) suffers a serious failure,
CA Live API Creatormight not invoke shutdown listeners upon shutdown.
For more information:
CA Live API Creatorgenerates logs for listener code that use the
CA Live API Creatorlog messages. You can persist log messages by creating a logger for externalizing your API logs.
For more information about how to persist log messages, see External Logging.
Listeners are either active or inactive. Active listeners are enabled in the API and inactive listeners are disabled in the API. If the listener is enabled in the API (it is active), API Server executes the listener code when it receives messages. 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 connection that you configured. 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.