Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

MDM uses the Apache ActiveMQ messaging system which leverages the STOMP text-based messaging protocol.  STOMP allows clients to be written easily.  A STOMP protocol implementation in node.js can be found here.

Adding STOMP

npm install --save stomp-clientAdd the following libraries in your local workspace:

  • amq_jquery_adapter.js
  • amq.js
  • stomp.js

Configuring STOMP

...

Note: Hari had is working on inserted the STOMP libraries into the project but is now using the npm command above . There may be some changes to the following

...

using npm to install the libraries.

...

Injecting STOMP Libraries

You can directly Directly add to the library section of your source code e.g. (use the appropriate path to your libraries):


Code Block
{src: `${this.ASSETS_SRC}/vendor-libs/js/amq_jquery_adapter.js`, inject: true, vendor: true},
{src: `${this.ASSETS_SRC}/vendor-libs/js/amq.js`, inject: true, vendor: true},
{src: `${this.ASSETS_SRC}/vendor-libs/js/stomp.js`, inject: true, vendor: true},


Subscribing to a Topic

Setup your credentials in your configuration (e.g. config.ts)

Code Block
languagejs
//
// Define these in a config file e.g. config.ts
//
ACTIVEMQ_CLIENT: process.env.ACTIVEMQ_CLIENT ? process.env.ACTIVEMQ_CLIENT : 'ws://docker.local:61614',
ACTIVEMQ_USER_NAME: process.env.ACTIVEMQ_USER_NAME ? process.env.ACTIVEMQ_USER_NAME : 'admin',
ACTIVEMQ_PASSWORD: process.env.ACTIVEMQ_PASSWORD ? process.env.ACTIVEMQ_PASSWORD : 'admin',


Setup your handler:

Code Block
languagejs




subscribeNotification() {
	this.loggedInZoneUuid = localStorage.getItem('zoneUuid');
	this.client = Stomp.client(Config.ACTIVEMQ_CLIENT);
	let topicUrl = '/topic/' + this.loggedInZoneUuid;
	let connectHeaders = {
		login: Config.ACTIVEMQ_USER_NAME,
		passcode: Config.ACTIVEMQ_PASSWORD,
		'client-id': this.loggedInZoneUuid
	};
	let componentRef = this;
	
	let callback = function (message) {
		// called when the client receives a STOMP message from the server
		componentRef.toastr.info(message.body);
		componentRef.incrementUnreadNotificationCount();
	};
	let subscribeHeaders = {'activemq.subscriptionName': this.loggedInZoneUuid};
	this.client.connect(connectHeaders, function () {
		componentRef.client.subscribe(topicUrl, callback, subscribeHeaders);
	}
);


Disconnect from the handler on logout, this should be in the same file as the above handler:


Code Block
this.client.disconnect();

Notification Types

The following is list of event types that a subscriber can be notified of on a per zone (topic) basis.  Each time an event is triggered it publishes a new notification of a given event type  .  

EventEvent TypeDefault ScopeAdditional Payload
A zone is createdZONE_POSTALL
A zone is updatedZONE_PUTALL
A zone is deletedZONE_DELETEALL
A zone's thumbnail image is updatedZONE_THUMBNAIL_PUTALL

A data domain is created or a new version of

of the data domain has been created

DOMAIN_POSTALL

A data domain has been created

DOMAIN_PUTALL
A data domain has been deletedDOMAIN_DELETEALL
An MDR has been created for a given data domain (TBD)DOMAIN_NAME_DATA_POSTALL
An MDR has been updated in a given data domain (TBD)DOMAIN_NAME_DATA_PUTALL
An MDR has been deleted in a give data domain (TBD)DOMAIN_NAME_DATA_DELETEALL

...