Author |
Message
|
yashgt |
Posted: Mon Nov 30, 2015 7:11 am Post subject: Under which process does API-exit run? |
|
|
Apprentice
Joined: 11 Nov 2014 Posts: 38
|
Hi,
If I configure a library as the API Exit for a Queue Manager, do the functions in the library run within the process space of the Application that makes the MQPUT and MQGET and other calls?
Or do the functions run in the process space of the Queue Manager?
Regards,
Yash |
|
Back to top |
|
 |
Vitor |
Posted: Mon Nov 30, 2015 7:36 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
They run as part of the queue manager thread. That's why a badly written exit can cause so much potential damage & instability. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
markt |
Posted: Mon Nov 30, 2015 8:39 am Post subject: |
|
|
 Knight
Joined: 14 May 2002 Posts: 508
|
They run on the application thread. Though of course, some "applications" are actually qmgr processes and therefore will also run the API exit. |
|
Back to top |
|
 |
yashgt |
Posted: Mon Nov 30, 2015 9:20 am Post subject: |
|
|
Apprentice
Joined: 11 Nov 2014 Posts: 38
|
The responses contradict each other. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Nov 30, 2015 9:25 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
yashgt wrote: |
The responses contradict each other. |
The klein bottle is correct. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Nov 30, 2015 9:25 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
yashgt wrote: |
The responses contradict each other. |
They do not. They complement each other. Both hold a kernel of truth.
All depends on timing, exit type, programming language used. The exits may be called multiple times.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
yashgt |
Posted: Mon Nov 30, 2015 10:20 am Post subject: |
|
|
Apprentice
Joined: 11 Nov 2014 Posts: 38
|
So if an application A1 connects to Q Manager QM1 and makes an MQPUT, the API exit will get called. If the API exit tries to print its own process ID, will it be the process ID of A1 or will it be of QM1?
If it is the ID of the A1 process, an exit() done by the API-exit function, should not cause any other applications to be affected. right? |
|
Back to top |
|
 |
tczielke |
Posted: Mon Nov 30, 2015 1:01 pm Post subject: |
|
|
Guardian
Joined: 08 Jul 2010 Posts: 941 Location: Illinois, USA
|
MQ comes with an amqsaxe sample API exit executable (i.e. /opt/mqm/samp/bin/amqsaxe on Linux) that is pretty simple to set up and test out the answer to your question. The provided amqsaxe0.c source (i.e. /opt/mqm/samp/amqsaxe0.c on Linux) also gives examples of how to set up this exit. If you run this test with say the amqsput sample, you will see that the API exit runs under the ampsput address space when the PUT is invoked by amqsput.
As far as calling the exit function from the ApiExit, that would not be advisable, unless you want your application to come to a crashing halt!  _________________ Working with MQ since 2010. |
|
Back to top |
|
 |
bruce2359 |
Posted: Tue Dec 01, 2015 1:58 pm Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
The last few posts here have brought up some questions. I'm mostly an MVS internals guy, so forgive my questions if they use mainframe terminology.
When is an exit fetched from the .dll library? Qmgr startup? First use?
Is only one instance fetched? Or does each app that calls the .dll get a copy? Is the .dll exit code re-entrant - mainframe-speak indicating that the .dll does not modify itself in any way (create state-data, for example)? Re-entrant code allows multiple callers to use the same instance of the code. _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
gbaddeley |
Posted: Tue Dec 01, 2015 3:00 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
bruce2359 wrote: |
The last few posts here have brought up some questions. I'm mostly an MVS internals guy, so forgive my questions if they use mainframe terminology.
When is an exit fetched from the .dll library? Qmgr startup? First use?
Is only one instance fetched? Or does each app that calls the .dll get a copy? Is the .dll exit code re-entrant - mainframe-speak indicating that the .dll does not modify itself in any way (create state-data, for example)? Re-entrant code allows multiple callers to use the same instance of the code. |
DLL = Dynamic Link Library. Windows loads it into each process when it is first called. Should always be coded as re-entrant (module only contains static constant data). _________________ Glenn |
|
Back to top |
|
 |
bruce2359 |
Posted: Tue Dec 01, 2015 6:16 pm Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
gbaddeley wrote: |
DLL = Dynamic Link Library. Windows loads it into each process when it is first called. Should always be coded as re-entrant (module only contains static constant data). |
Still a bit confused.
By "into each process" do you mean each qmgr process? Or does "into each process" mean each app process which calls the API exit? If the former, then there is only one instance of the exit - per qmgr. If the latter, there will be n instances - one for each concurrent app calling the API.
Re-entrant in MVS-speak also means that if the exit needs to store any data (count something, or compose a print-line, as examples), it must acquire that storage in the address-space of the caller. _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
tczielke |
Posted: Tue Dec 01, 2015 7:18 pm Post subject: |
|
|
Guardian
Joined: 08 Jul 2010 Posts: 941 Location: Illinois, USA
|
Using Linux as an example, the API exit would be loaded into each application process. For example, if you had 100 amqpsut processes running, each one would have the API exit loaded in their address space. However, the exit is a shared object file that is memory mapped. So in reality, all 100 exits are pointing at the same copy of the module (the executable part) in physical storage. Of course, each process would have its own separate data section of the exit.
Here are some comparisons I have in my mind between z/OS and distributed.
1) address space in z/OS is similar to a distributed process
2) TCB in z/OS is similar to a distributed thread
3) cross memory services is kind of like distributed shared memory, but cross memory services is much more sophisticated.
4) The z/OS subspace group facility is one of the cleverest things I have ever seen with an operating system and I have never seen anything remotely like that in a distributed operating system . . .
In my opinion, z/OS is vastly more sophisticated and robust than distributed systems. But maybe that is just me.  _________________ Working with MQ since 2010. |
|
Back to top |
|
 |
bruce2359 |
Posted: Wed Dec 02, 2015 9:39 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
tczielke wrote: |
But maybe that is just me.  |
In a job interview, I was once asked which was my favorite operating system. Generally, my reply remains the same, namely: the o/s that meets the business requirements of the client. Over a beer, I'll be more precise. _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
yashgt |
Posted: Wed Dec 02, 2015 2:13 pm Post subject: |
|
|
Apprentice
Joined: 11 Nov 2014 Posts: 38
|
Here is something that confuses me. The application may be a Java program. If the API exit function runs in the process space of the application, how is it that a library written in C gets executed in a JVM? |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Dec 02, 2015 2:50 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
yashgt wrote: |
Here is something that confuses me. The application may be a Java program. If the API exit function runs in the process space of the application, how is it that a library written in C gets executed in a JVM? |
There is a standard JNI call for those libraries. Especially the security exits (client side).
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|