JMS Messaging Support for Ignition Projects
Configure Messaging Broker
-
Install ActiveMQ on a server and configure it. (INSTALLATION and CONFIGURATION 1. Install latest Java x64 JRE 2. Down - Pastebin.com)
-
Get an MQTT client. (http://mqttfx.jensd.de/)
-
Establish a connection with your broker.
Ignition Project
-
(PRE-REQ) Install Nick's Database Module. (Database Module)
-
Import attached project.
Gateway Startup
Turn up logging for 'activemq' logger.
A couple things happen on the first strartup of the project:
-
The latest activemq-all.jar is downloaded from Maven to %IGNITION_INSTALL%/lib/core/gateway/activemq-all-latest.jar.
The JAR is manually added to JAVA paths upon download. Once Ignition services are restarted,
the JAR is automatically loaded along with everything else in /lib/core/gateway.
(https://mvnrepository.com/artifact/org.apache.activemq/activemq-all) -
Tables are created in 'DefaultH2' data source. You will get an error in the gateway logs if this datasource is not found.
TABLES
activemq_connections: Your ActiveMQ connection strings and connection wide configuration.
activemq_subscriptiontopics: ActiveMQ topics that you will be subscribing to. Each topic can have a custom MessageListener
. Leaving the column NULL will default to the generic listener (eg. project.activemq.AMQMessageListenerScript.AMQMessageListener
). Custom message listeners can be added to shared.activemq.message_listeners package (eg. shared.activemq.message_listeners.CustomMessageListenerScript.CustomMessageListener
).
activemq_connectionsubscriptionlinks: Here is where you tell each connection what topics it should subscribe to. Joins connection Id to topic Id.
activemq_projectsubscriptionlinks: Here is where you allow a message received on a specific topic to be passed through to a project client message handler. Joins topic id to an Ignition project name. The project must have an OnActiveMqMessage
client message handler. Your custom MessageListener
overrides this functionality.
During Gateway startup script execution, each connection is established and all enabled topics are subscribed to. Reconnections and resubscriptions are handled automatically.
Publishing Messages from Ignition
shared.activemq.publisher.publishToConnectionId(connectionId,topicPath,message={})
shared.activemq.publisher.publishToConnectionName(connectionName,topicPath,message={})
TODO: automatic update facility for activemq-all.jar.
TODO: allow custom javax.jms.ExceptionListener
TODO: allow custom org.apache.activemq.transport.TransportListener
TODO: USE_CASE_SPECIFIC create memory tags from KV pairs and update value on message received
TODO: USE_CASE_SPECIFIC create com.inductiveautomation.ignition.common.sqltags.model.event.TagChangeListener and publish to ActiveMQ on memory tag value change
TODO: build client interface for managing connections
TODO: advisory/control layer between client and gateway
ActiveMQIntegration-global-latest.proj (4.0 KB)
ActiveMQIntegration-project-latest.proj (30.3 KB)