Page 1 of 1

Opening and Closing JSM

Posted: Wed Mar 29, 2017 6:59 am
by jyoung
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 (12.79 KiB) Viewed 1589 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)

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

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

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

Re: Opening and Closing JSM

Posted: Wed Mar 29, 2017 7:56 pm
by HMJust
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.

Re: Opening and Closing JSM

Posted: Thu Mar 30, 2017 12:46 am
by jyoung
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