2023.1.1294.2 Active MQ
Overview
This feature is used to make an ActiveMQ connection between Prespective(acts as a client) and an external ActiveMQ server to transport messages.
Architectural view of MQTT.
Ref: - A Survey of Distributed Message Broker Queues - Scientific Figure on ResearchGate. Available from: https://www.researchgate.net/figure/ActiveMQ-Architecture_fig5_315764651 [accessed 28 Jul, 2021]
Where to find
The feature can be found under Prespective Menu > Logic > Add Logic Simulator > Adapter Settings > Adapter Target > ActiveMQ
Feature Layout
Gateway settings |
|
---|---|
Adapter Target | Select a different adapter, please see respective documentation for more information |
Adapter Setting (ActiveMQServerSettings) |
|
IP Address | The address of the ActiveMQ server. This can be a be in IPv4 address or a hostname like localhost |
Port | The port on which the ActiveMQ broker is running, the default port is 61616. |
CorrelationID | The identifier on which a message responds. Different Correlation IDs can communicate over the same queue, but is not recommended. Make sure other clients use the same Correlation ID |
DeliveryMode | Int that defines whether the message is persistent(0) or non_persistent(1). Persistent is default and makes sure the message survives a broker reset. It can be a slower than non_persistent |
Lifecycle settings | Not implemented for Active MQ |
How to use
Prerequisites for ActiveMQ
ActiveMQ can work with an online broker on the internet, but is more commonly used with a local broker. A local broker can be downloaded from the Apache Website: ActiveMQ
Java Runtime Environment is required. Download the Latest Java LTS Free
The README.txt in the zip file will help you setup the broker.
Once the broker is running you will find the broker admin page on http://localhost:8161/admin/
In the admin panel you will find an overview of the current queues and its connected consumers and producers when you click on ‘Queues’.
Used Protocol
To communicate with the ActiveMQ adapter in prespective you need to have to apply the following protocol:
Message is not supported, only MapMessage.
The structure for the MapMessage is:
<MAPMESSAGEINSTANCE>.Properties.Set<TYPE>("<TYPE>",<VALUE>);
<MAPMESSAGEINSTANCE>.Properties.Get<TYPE>("<TYPE>");
Each type has a specific Set and Get command. This differs a little bit per language. Please visit the ActiveMQ supported language page to check yours ActiveMQ
c#:
_mapMsg.Properties.SetBool("BOOL", true);
_mapMsg.Properties.GetBool(”BOOL”);
Destination = queue as defined in plc address
CorrelationID = same as defined in ActiveMQ adapter settings
Supported Types
BOOL
BYTE
SBYTE
WORD
DWORD
SHORT
USHORT
INT16
UINT16
INT32
UINT32
INT64
UINT64
REAL32
REAL64
BYTEARRAY
STRING
STRUCT
Naming Rules
Setting up the component works as like any other prelogic component. The thing you have to take into account is how the PLC Address Path Format (or implicit naming rule) is configured. The output of this Address is the path to the queue.
ie. Simulator1.DrivenStepper.iPosition
Simulator1 is the instance name of the simulator
DrivenStepper the instance of a motor object
iPosition is the variable name as defined in the signal definition
This structure is based on MQTT and can be adapted to any personal preference, because this adapter implementation uses queues instead of topics.
Prespective Documentation