SlideShare una empresa de Scribd logo
1 de 16
Descargar para leer sin conexión
Copyright © 2016 M/Gateway Developments Ltd
EWD 3 Training Course
Part 28
Integrating Legacy Mumps Code
with QEWD
Rob Tweed
Director, M/Gateway Developments Ltd
Twitter: @rtweed
Copyright © 2016 M/Gateway Developments Ltd
Integrating Mumps Code
• Use the cache.node function() API
– function() is also available in the NodeM
module for GT.M
• Invokes a Mumps extrinsic function
• May need to create an extrinsic function
wrapper around existing Mumps logic in
order to invoke it from Node.js / JavaScript
Copyright © 2016 M/Gateway Developments Ltd
Equivalent to:
set result=$$myFunc^theRoutine(arg1,arg2)
var result = this.db.function({
function: 'myFunc^theRoutine',
arguments: [ arg1, arg2]
});
Invoking a function
Copyright © 2016 M/Gateway Developments Ltd
The function() result
• The value returned by a function() call can
be a very large string
– So it's possible to use it to return stringified
JSON
• However this would require a Mumps JSON
parser/generator to create the JSON string
– These tend to be slow
– Some are un-reliable
Copyright © 2016 M/Gateway Developments Ltd
Limitations of the function() API
• Arguments are limited to simple variables
– Numeric or strings
• Cannot pass arguments by reference
– So you can't get complex data structures in
and out of a function via arguments
Copyright © 2016 M/Gateway Developments Ltd
Is Legacy Mumps integration possible?
• Yes!
• The trick is to use a temporary Global as a
means of passing complex data in and out
of a Mumps wrapper function
• We can make use of the fact that the
cache.node (and NodeM) interface runs
in-process with Caché (or GT.M)
Copyright © 2016 M/Gateway Developments Ltd
Node.js
Caché
GT.M
CCallinInterface
cache.node
NodeM
In-process Connection
Copyright © 2016 M/Gateway Developments Ltd
Node.js
Caché
GlobalsDB
GT.M
CCallinInterface
cache.node
NodeM
process.pid $job
In-process Connection
One-to-one correspondence
Copyright © 2016 M/Gateway Developments Ltd
Node.js
Caché
GlobalsDB
GT.M
CCallinInterface
cache.node
NodeM
process.pid $job
new this.documentStore.documentNode('temp', [process.pid]) ^temp($job)
In-process Connection
These refer to the same thing!
Copyright © 2016 M/Gateway Developments Ltd
Integrating Legacy Code
• On Node.js side, before calling the legacy
Mumps function:
– Use setDocument() to create complex input
data in a temporary global, subscripted by
process.pid, eg:
var myComplexInputData = { // create your complex input data here};
var temp = new this.documentStore.documentNode('temp', [process.pid]);
temp.setDocument(myComplexInputData);
// now invoke the Mumps function
var result = this.db.function({function: 'myFunc^theRoutine',arguments: []});
Copyright © 2016 M/Gateway Developments Ltd
Integrating Legacy Code
• In the Mumps function:
– The complex input data is accessible in
^temp($j) and its sub-tree of nodes, so:
– Merge out the inputs from ^temp($j)
new inputs
merge inputs=^temp($j)
• You've now picked up the complex input
data for the function!
Copyright © 2016 M/Gateway Developments Ltd
Integrating Legacy Code
• In the Mumps function:
– Invoke your Mumps code to process the inputs
– Put the complex output data into a local array
– Merge the array back into the temporary global, eg
new ouputs
; put your output data into this array, then:
kill ^temp($j) ; clear down the temporary global
merge ^temp($j)=outputs
QUIT 1 ; function has finished
Copyright © 2016 M/Gateway Developments Ltd
Integrating Legacy Code
• Back on the Node.js side
– Pick up the results from the temporary global
using getDocument()
– Delete the temporary global's document node,
eg:
var outputs = temp.getDocument();
temp.delete();
Copyright © 2016 M/Gateway Developments Ltd
Integrating Legacy Code
• Remember that because QEWD uses ewd-
qoper8, it allows us to safely use the
synchronous cache.node APIs
• So invoking a Mumps function is synchronous in
QEWD
• Your JavaScript logic will therefore wait until the
Mumps function has completed before
continuing
– It doesn't matter if the Mumps code Hangs or waits on
a Lock
Copyright © 2016 M/Gateway Developments Ltd
Invoking Legacy Mumps Code
with complex I/O
var myComplexInputData = { // create your complex input data here};
var temp = new this.documentStore.documentNode('temp', [process.pid]);
temp.delete(); // clear it down just in case
temp.setDocument(myComplexInputData);
// now invoke the Mumps function
var result = this.db.function({function: 'myFunc^theRoutine',arguments: []});
// Mumps function has finished – process its outputs
var outputs = temp.getDocument();
temp.delete(); // clear down the temporary global
// the complex output data from the Mumps function is now in the
// outputs object
Copyright © 2016 M/Gateway Developments Ltd
Invoking Legacy Mumps Code
with complex I/O
myFunc()
new inputs,outputs
merge inputs=^temp($j)
; process inputs and put output data into outputs array
; invoke any legacy procedures, functions etc
kill ^temp($j)
merge ^temp($j)=outputs
quit 1
The corresponding Mumps wrapper function

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

EWD 3 Training Course Part 12: QEWD Session Timeout Control
EWD 3 Training Course Part 12: QEWD Session Timeout ControlEWD 3 Training Course Part 12: QEWD Session Timeout Control
EWD 3 Training Course Part 12: QEWD Session Timeout Control
 
EWD 3 Training Course Part 35: QEWD Session Locking
EWD 3 Training Course Part 35: QEWD Session LockingEWD 3 Training Course Part 35: QEWD Session Locking
EWD 3 Training Course Part 35: QEWD Session Locking
 
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
EWD 3 Training Course Part 5b: First Steps in Building a QEWD ApplicationEWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
EWD 3 Training Course Part 5b: First Steps in Building a QEWD Application
 
EWD 3 Training Course Part 11: Handling Errors in QEWD
EWD 3 Training Course Part 11: Handling Errors in QEWDEWD 3 Training Course Part 11: Handling Errors in QEWD
EWD 3 Training Course Part 11: Handling Errors in QEWD
 
EWD 3 Training Course Part 30: Modularising QEWD Applications
EWD 3 Training Course Part 30: Modularising QEWD ApplicationsEWD 3 Training Course Part 30: Modularising QEWD Applications
EWD 3 Training Course Part 30: Modularising QEWD Applications
 
EWD 3 Training Course Part 4: Installing & Configuring QEWD
EWD 3 Training Course Part 4: Installing & Configuring QEWDEWD 3 Training Course Part 4: Installing & Configuring QEWD
EWD 3 Training Course Part 4: Installing & Configuring QEWD
 
EWD 3 Training Course Part 9: Complex QEWD Messages and Responses
EWD 3 Training Course Part 9: Complex QEWD Messages and ResponsesEWD 3 Training Course Part 9: Complex QEWD Messages and Responses
EWD 3 Training Course Part 9: Complex QEWD Messages and Responses
 
EWD 3 Training Course Part 3: Summary of EWD 3 Modules
EWD 3 Training Course Part 3: Summary of EWD 3 ModulesEWD 3 Training Course Part 3: Summary of EWD 3 Modules
EWD 3 Training Course Part 3: Summary of EWD 3 Modules
 
EWD 3 Training Course Part 42: The QEWD Docker Appliance
EWD 3 Training Course Part 42: The QEWD Docker ApplianceEWD 3 Training Course Part 42: The QEWD Docker Appliance
EWD 3 Training Course Part 42: The QEWD Docker Appliance
 
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
EWD 3 Training Course Part 37: Building a React.js application with ewd-xpres...
 
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.jsEWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
EWD 3 Training Course Part 44: Creating MicroServices with QEWD.js
 
EWD 3 Training Course Part 34: QEWD Resilient Mode
EWD 3 Training Course Part 34: QEWD Resilient ModeEWD 3 Training Course Part 34: QEWD Resilient Mode
EWD 3 Training Course Part 34: QEWD Resilient Mode
 
EWD 3 Training Course Part 10: QEWD Sessions and User Authentication
EWD 3 Training Course Part 10: QEWD Sessions and User AuthenticationEWD 3 Training Course Part 10: QEWD Sessions and User Authentication
EWD 3 Training Course Part 10: QEWD Sessions and User Authentication
 
qewd-ripple: The Ripple OSI Middle Tier
qewd-ripple: The Ripple OSI Middle Tierqewd-ripple: The Ripple OSI Middle Tier
qewd-ripple: The Ripple OSI Middle Tier
 
QEWD.js, JSON Web Tokens & MicroServices
QEWD.js, JSON Web Tokens & MicroServicesQEWD.js, JSON Web Tokens & MicroServices
QEWD.js, JSON Web Tokens & MicroServices
 
EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Data...
EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Data...EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Data...
EWD 3 Training Course Part 1: How Node.js Integrates With Global Storage Data...
 
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
EWD 3 Training Course Part 31: Using QEWD for Web and REST ServicesEWD 3 Training Course Part 31: Using QEWD for Web and REST Services
EWD 3 Training Course Part 31: Using QEWD for Web and REST Services
 
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
EWD 3 Training Course Part 14: Using Ajax for QEWD MessagesEWD 3 Training Course Part 14: Using Ajax for QEWD Messages
EWD 3 Training Course Part 14: Using Ajax for QEWD Messages
 
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService FunctionalityEWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
EWD 3 Training Course Part 45: Using QEWD's Advanced MicroService Functionality
 
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Servicesewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
ewd-qoper8-vistarpc: Exposing VistA's RPCs as REST Services
 

Destacado

Destacado (15)

EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
EWD 3 Training Course Part 36: Accessing REST and Web Services from a QEWD ap...
 
EWD 3 Training Course Part 17: Introduction to Global Storage Databases
EWD 3 Training Course Part 17: Introduction to Global Storage DatabasesEWD 3 Training Course Part 17: Introduction to Global Storage Databases
EWD 3 Training Course Part 17: Introduction to Global Storage Databases
 
EWD 3 Training Course Part 26: Event-driven Indexing
EWD 3 Training Course Part 26: Event-driven IndexingEWD 3 Training Course Part 26: Event-driven Indexing
EWD 3 Training Course Part 26: Event-driven Indexing
 
EWD 3 Training Course Part 18: Modelling NoSQL Databases using Global Storage
EWD 3 Training Course Part 18: Modelling NoSQL Databases using Global StorageEWD 3 Training Course Part 18: Modelling NoSQL Databases using Global Storage
EWD 3 Training Course Part 18: Modelling NoSQL Databases using Global Storage
 
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
EWD 3 Training Course Part 24: Traversing a Document's Leaf NodesEWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
EWD 3 Training Course Part 24: Traversing a Document's Leaf Nodes
 
EWD 3 Training Course Part 25: Document Database Capabilities
EWD 3 Training Course Part 25: Document Database CapabilitiesEWD 3 Training Course Part 25: Document Database Capabilities
EWD 3 Training Course Part 25: Document Database Capabilities
 
EWD 3 Training Course Part 21: Persistent JavaScript Objects
EWD 3 Training Course Part 21: Persistent JavaScript ObjectsEWD 3 Training Course Part 21: Persistent JavaScript Objects
EWD 3 Training Course Part 21: Persistent JavaScript Objects
 
EWD 3 Training Course Part 20: The DocumentNode Object
EWD 3 Training Course Part 20: The DocumentNode ObjectEWD 3 Training Course Part 20: The DocumentNode Object
EWD 3 Training Course Part 20: The DocumentNode Object
 
EWD 3 Training Course Part 27: The QEWD Session
EWD 3 Training Course Part 27: The QEWD SessionEWD 3 Training Course Part 27: The QEWD Session
EWD 3 Training Course Part 27: The QEWD Session
 
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
EWD 3 Training Course Part 41: Building a React.js application with QEWD, Part 5
 
EWD 3 Training Course Part 7: Applying the QEWD Messaging Pattern
EWD 3 Training Course Part 7: Applying the QEWD Messaging PatternEWD 3 Training Course Part 7: Applying the QEWD Messaging Pattern
EWD 3 Training Course Part 7: Applying the QEWD Messaging Pattern
 
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
 
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
EWD 3 Training Course Part 33: Configuring QEWD to use CORSEWD 3 Training Course Part 33: Configuring QEWD to use CORS
EWD 3 Training Course Part 33: Configuring QEWD to use CORS
 
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
 
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
 

Similar a EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD

Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010
Chris Ramsdale
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
AOE
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
維佋 唐
 
Google io bootcamp_2010
Google io bootcamp_2010Google io bootcamp_2010
Google io bootcamp_2010
Chris Ramsdale
 

Similar a EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD (20)

JBoss World 2010
JBoss World 2010JBoss World 2010
JBoss World 2010
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMS
 
Introduction to Micronaut at Oracle CodeOne 2018
Introduction to Micronaut at Oracle CodeOne 2018Introduction to Micronaut at Oracle CodeOne 2018
Introduction to Micronaut at Oracle CodeOne 2018
 
Spring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundrySpring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud Foundry
 
OSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshopOSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshop
 
Monitoring using Prometheus and Grafana
Monitoring using Prometheus and GrafanaMonitoring using Prometheus and Grafana
Monitoring using Prometheus and Grafana
 
Clug 2012 March web server optimisation
Clug 2012 March   web server optimisationClug 2012 March   web server optimisation
Clug 2012 March web server optimisation
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
 
NodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayNodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin Way
 
Advanced Node.JS Meetup
Advanced Node.JS MeetupAdvanced Node.JS Meetup
Advanced Node.JS Meetup
 
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
 
Tuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsTuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on Mobicents
 
Devoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoTDevoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoT
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
CloudStack and cloud-init
CloudStack and cloud-initCloudStack and cloud-init
CloudStack and cloud-init
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоны
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Google io bootcamp_2010
Google io bootcamp_2010Google io bootcamp_2010
Google io bootcamp_2010
 

Más de Rob Tweed

Más de Rob Tweed (7)

QEWD Update
QEWD UpdateQEWD Update
QEWD Update
 
Data Persistence as a Language Feature
Data Persistence as a Language FeatureData Persistence as a Language Feature
Data Persistence as a Language Feature
 
LNUG: Having Your Node.js Cake and Eating It Too
LNUG: Having Your Node.js Cake and Eating It TooLNUG: Having Your Node.js Cake and Eating It Too
LNUG: Having Your Node.js Cake and Eating It Too
 
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST ServicesEWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
EWD 3 Training Course Part 43: Using JSON Web Tokens with QEWD REST Services
 
QEWD.js: Have your Node.js Cake and Eat It Too
QEWD.js: Have your Node.js Cake and Eat It TooQEWD.js: Have your Node.js Cake and Eat It Too
QEWD.js: Have your Node.js Cake and Eat It Too
 
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPSEWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
EWD 3 Training Course Part 32: Configuring QEWD to use SSL/HTTPS
 
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode ObjectsEWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects
EWD 3 Training Course Part 23: Traversing a Range using DocumentNode Objects
 

Último

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Último (20)

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 

EWD 3 Training Course Part 28: Integrating Legacy Mumps Code with QEWD

  • 1. Copyright © 2016 M/Gateway Developments Ltd EWD 3 Training Course Part 28 Integrating Legacy Mumps Code with QEWD Rob Tweed Director, M/Gateway Developments Ltd Twitter: @rtweed
  • 2. Copyright © 2016 M/Gateway Developments Ltd Integrating Mumps Code • Use the cache.node function() API – function() is also available in the NodeM module for GT.M • Invokes a Mumps extrinsic function • May need to create an extrinsic function wrapper around existing Mumps logic in order to invoke it from Node.js / JavaScript
  • 3. Copyright © 2016 M/Gateway Developments Ltd Equivalent to: set result=$$myFunc^theRoutine(arg1,arg2) var result = this.db.function({ function: 'myFunc^theRoutine', arguments: [ arg1, arg2] }); Invoking a function
  • 4. Copyright © 2016 M/Gateway Developments Ltd The function() result • The value returned by a function() call can be a very large string – So it's possible to use it to return stringified JSON • However this would require a Mumps JSON parser/generator to create the JSON string – These tend to be slow – Some are un-reliable
  • 5. Copyright © 2016 M/Gateway Developments Ltd Limitations of the function() API • Arguments are limited to simple variables – Numeric or strings • Cannot pass arguments by reference – So you can't get complex data structures in and out of a function via arguments
  • 6. Copyright © 2016 M/Gateway Developments Ltd Is Legacy Mumps integration possible? • Yes! • The trick is to use a temporary Global as a means of passing complex data in and out of a Mumps wrapper function • We can make use of the fact that the cache.node (and NodeM) interface runs in-process with Caché (or GT.M)
  • 7. Copyright © 2016 M/Gateway Developments Ltd Node.js Caché GT.M CCallinInterface cache.node NodeM In-process Connection
  • 8. Copyright © 2016 M/Gateway Developments Ltd Node.js Caché GlobalsDB GT.M CCallinInterface cache.node NodeM process.pid $job In-process Connection One-to-one correspondence
  • 9. Copyright © 2016 M/Gateway Developments Ltd Node.js Caché GlobalsDB GT.M CCallinInterface cache.node NodeM process.pid $job new this.documentStore.documentNode('temp', [process.pid]) ^temp($job) In-process Connection These refer to the same thing!
  • 10. Copyright © 2016 M/Gateway Developments Ltd Integrating Legacy Code • On Node.js side, before calling the legacy Mumps function: – Use setDocument() to create complex input data in a temporary global, subscripted by process.pid, eg: var myComplexInputData = { // create your complex input data here}; var temp = new this.documentStore.documentNode('temp', [process.pid]); temp.setDocument(myComplexInputData); // now invoke the Mumps function var result = this.db.function({function: 'myFunc^theRoutine',arguments: []});
  • 11. Copyright © 2016 M/Gateway Developments Ltd Integrating Legacy Code • In the Mumps function: – The complex input data is accessible in ^temp($j) and its sub-tree of nodes, so: – Merge out the inputs from ^temp($j) new inputs merge inputs=^temp($j) • You've now picked up the complex input data for the function!
  • 12. Copyright © 2016 M/Gateway Developments Ltd Integrating Legacy Code • In the Mumps function: – Invoke your Mumps code to process the inputs – Put the complex output data into a local array – Merge the array back into the temporary global, eg new ouputs ; put your output data into this array, then: kill ^temp($j) ; clear down the temporary global merge ^temp($j)=outputs QUIT 1 ; function has finished
  • 13. Copyright © 2016 M/Gateway Developments Ltd Integrating Legacy Code • Back on the Node.js side – Pick up the results from the temporary global using getDocument() – Delete the temporary global's document node, eg: var outputs = temp.getDocument(); temp.delete();
  • 14. Copyright © 2016 M/Gateway Developments Ltd Integrating Legacy Code • Remember that because QEWD uses ewd- qoper8, it allows us to safely use the synchronous cache.node APIs • So invoking a Mumps function is synchronous in QEWD • Your JavaScript logic will therefore wait until the Mumps function has completed before continuing – It doesn't matter if the Mumps code Hangs or waits on a Lock
  • 15. Copyright © 2016 M/Gateway Developments Ltd Invoking Legacy Mumps Code with complex I/O var myComplexInputData = { // create your complex input data here}; var temp = new this.documentStore.documentNode('temp', [process.pid]); temp.delete(); // clear it down just in case temp.setDocument(myComplexInputData); // now invoke the Mumps function var result = this.db.function({function: 'myFunc^theRoutine',arguments: []}); // Mumps function has finished – process its outputs var outputs = temp.getDocument(); temp.delete(); // clear down the temporary global // the complex output data from the Mumps function is now in the // outputs object
  • 16. Copyright © 2016 M/Gateway Developments Ltd Invoking Legacy Mumps Code with complex I/O myFunc() new inputs,outputs merge inputs=^temp($j) ; process inputs and put output data into outputs array ; invoke any legacy procedures, functions etc kill ^temp($j) merge ^temp($j)=outputs quit 1 The corresponding Mumps wrapper function