Opening and Closing JSM

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
jyoung
Posts: 642
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Opening and Closing JSM

Post by jyoung » Wed Mar 29, 2017 6:59 am

I am using Integrator and the PDFDocumentService and SMTPMailService to create a PDF, email it and finally delete it off the server.
I created 3 separate functions to do each of the above actions. Each of these actions open and close the JSM server.
There is one main "run" function that invokes the other functions. I want to be able to submit this function instead of waiting on it (call).
Each function exchanges the wk_Status with the *ALWAYS option.

Is it ok to be opening and closing the JSM Server repeatedly or should I open it once, do everything and then close it?
I really don't like having really big code files, so if I need open it once, can I pass (exchange) the handle around?

As an example, I have these functions
functions.png
functions.png (12.79 KiB) Viewed 1392 times
The "run" one is the main function and looks like

Code: Select all

function options(*DIRECT) rcv_list(#JSMXMessages)

define_com class(#VLFServerTraceHandler) scope(*APPLICATION)

* fields we receive from the calling progam
group_by name(#ReceiveFields) fields(#CLOFID #CLOCN #CLOD)

* list we receive from the calling program, will populate with messages from JSM operations
def_list name(#JSMXMessages) fields(#JSMXSTS #JSMXMSG) type(*WORKING) entrys(*MAX)

#SYS_APPLN.TraceMessageText( "Running Sales Analysis Report" )

* default to an error state
#wk_Status := ER

exchange fields(#wk_Status) option(*ALWAYS)

* the exchange board is cleared after every function call, so we have to exchange it every time
exchange fields(#CLOFID #CLOCN #CLOD)
call process(*DIRECT) function(CreateSalesAnalysisReport) pass_lst(#JSMXMessages)
if (#wk_Status <> OK)
return
endif

* the file path is exchanged back to us
exchange fields(#wk_FilePath)
call process(*DIRECT) function(EmailSalesAnalysisReport) pass_lst(#JSMXMessages)
if (#wk_Status <> OK)
return
endif

exchange fields(#wk_FilePath)
call process(*DIRECT) function(DeleteSalesAnalysReport) pass_lst(#JSMXMessages)
if (#wk_Status <> OK)
return
endif

#wk_Status := OK
The Create, Email and Delete all have their own JSMX_OPEN and JSMX_CLOSE commands.

User avatar
HMJust
Posts: 51
Joined: Wed May 11, 2016 7:23 pm
Contact:

Re: Opening and Closing JSM

Post by HMJust » Wed Mar 29, 2017 7:56 pm

I have successfully passed the handle around in case of SOAP agents. That worked.

In the case of doing an HTTP request I was however unable to reuse the handle and had to close and re-open the JSM each time :-(

So I guess you have to try and see.
I don't know what I am doing, nor how I did it. If it works, luck was involved :geek:

jyoung
Posts: 642
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Opening and Closing JSM

Post by jyoung » Thu Mar 30, 2017 12:46 am

Thanks HMJust,

I may try to pass the handle around and see what happens. Right now its working fine and performing well. I was concerned that opening and closing the connection to the JSM server could be a resource intensive or limiting operation (kinda like database connections). Will monitor and see how it holds up.

I really just want to make sure I am not doing something completely stupid. :D

Post Reply