Does the PAS for OE supports JMS out of the box?

Posted by Valeriy Bashkatov on 20-Feb-2017 07:19

Hello,

Does the PAS for OE supports JMS out of the box? or is necessary to develop a custom application?

For example, I have a following task:

It is necessary that at the start of PAS-instance, the PAS server connect to the SonicMQ and listened specific queue, when in the queue something appears, PAS should take and process the request, and then send back a response.

I did not find anything like that in PAS documentation and I think that it can be implemented on the ABL through PAS4OE.

But perhaps there is some other solution?

Regards,
Valeriy

Posted by David Cleary on 27-Feb-2017 10:29

PASOE supports the Sonic Adapter using Broker Connect. You need to have Sonic installed as well as the Sonic Adapter for OpenEdge.

All Replies

Posted by Irfan on 20-Feb-2017 09:09

Hi Valeriy,

We do not support anything related to JMS out of the box for PASOE.

For your-use, I think you can run an asynchronous procedure in an agentStartupProcedure which would subscribe to the Queue in MQ and do the respective actions.

Posted by Valeriy Bashkatov on 21-Feb-2017 03:18

Hi Irfan,

Thank you! Where can I find an example of such a procedure?

Regards,

Valeriy

Posted by marian.edu on 21-Feb-2017 04:04

Hi Irfan,


just out of curiosity, how will the appsrv broker know when an agent is busy responding to a message, wouldn’t it still show as available for the broker? Server sockets were not allowed inside the appsrv, client sockets could also get one into this situation when async model is used, is that supported and the appsrv can handle the situation or simply no one had an issue before?

Cheers


Marian Edu

Acorn IT 
+40 740 036 212

Posted by Irfan on 21-Feb-2017 09:30

Hi Marian,

I haven't tried this use-case, so not sure if that might go into issues or not. The assumption is that I can always keep one session busy listening to  the JMS Queue. I can give a shot and see how it works.

Posted by Valeriy Bashkatov on 27-Feb-2017 01:25

Hi Irfan,

[quote user="Irfan "]

For your-use, I think you can run an asynchronous procedure in an agentStartupProcedure which would subscribe to the Queue in MQ and do the respective actions.

[/quote]
I have created such a procedure (JMSServerExample.p):
DEFINE INPUT PARAMETER inputParam AS CHAR.

DEFINE VARIABLE ptpsession AS HANDLE.

DEFINE VARIABLE replyMessage AS HANDLE.
DEFINE VARIABLE consumerH AS HANDLE.

define var      BrokerURL     as character no-undo.
def    var      Is_connected  as logical   no-undo.

BrokerURL = "tcp://172.16.95.131:2506".

run jms/ptpsession.p persistent set ptpsession ("-SMQConnect").
run setConnectionURLs in ptpsession (BrokerURL).
run setReconnectTimeout in ptpsession (600). /* in minutes */
RUN setReconnectInterval IN ptpsession (10). /* in seconds */
run setPingInterval in ptpsession (5) .
run setFaultTolerant in ptpsession(false).
run setNoErrorDisplay in ptpsession (true).
run setUser in ptpsession ("Administrator").
run setPassword in ptpsession ("Administrator").

do on error undo, leave:
    run beginSession in ptpsession.
    Is_connected = true.
end.

if   Is_connected then
do:
	RUN createTextMessage IN ptpsession (OUTPUT replyMessage).

	RUN createMessageConsumer IN ptpsession (
                              THIS-PROCEDURE,    /* This proc will handle it */
                             "requestHandler",  /* name of internal procedure */
                              OUTPUT consumerH).

	RUN receiveFromQueue IN ptpsession ("PASQ1",   /* request queue */
                                     ?,               /* No message selector */
                                     consumerH).      /* Handles the messages */

	RUN startReceiveMessages IN ptpsession.

	RUN waitForMessages IN ptpsession ("inWait", THIS-PROCEDURE, ?).

end.
else 
do:
    message "No connection to the broker!". pause 0.
end.

PROCEDURE requestHandler:
	DEFINE INPUT PARAMETER requestH AS HANDLE.
	DEFINE INPUT PARAMETER msgConsumerH AS HANDLE.
	DEFINE OUTPUT PARAMETER replyH AS HANDLE.

	DEFINE VAR replyText AS CHAR.


	/* Creates a reply message. The reply is sent automatically when control
	   returns to the 4GL-To-JMS implementation.
	*/
	replyText=inputParam + " executed " + DYNAMIC-FUNCTION('getText':U IN requestH).
	message replyText. pause 0.
	RUN deleteMessage IN requestH.
	replyH = replyMessage.
	RUN setText IN replyH (replyText).

end.

FUNCTION inWait RETURNS LOGICAL.
	RETURN true.
end.

I used the code from the example of documentation, OpenEdge® Development: Messaging and ESB (example21.p), Messaging Examples topic.

Then define this procedure in agentStartupProc and restart the server. To test the listener I used example20.p from the same documentation. At first glance everything seems to be working fine.

Nevertheless, it may be necessary to add something to a procedure (JMSServerExample.p) for better performance and reliability? How do you think?

Regards,
Valeriy

Posted by David Cleary on 27-Feb-2017 10:29

PASOE supports the Sonic Adapter using Broker Connect. You need to have Sonic installed as well as the Sonic Adapter for OpenEdge.

Posted by David Cleary on 27-Feb-2017 10:36

Both Classic and PASOE AppServer are not designed to process JMS messages without creating a backdoor. If you want to listen to messages and send them to an AppServer for processing, you should use a batch client that calls into the AppServer. Or, the ESB Adapter was another way we provided this support. No difference here between PASOE and Classic, and you certainly shouldn't create calls out to the MQ Adapter in an Agent Startup proc.

Posted by David Cleary on 27-Feb-2017 10:44

batch client - dispatch to AppServer. This is the proper architecture. Everything else creates a backdoor and bypasses security and will cause heartburn even if you get it working. Both Classic and PASOE would need a long running orphan session in order to process incoming messages.

Posted by David Cleary on 27-Feb-2017 10:46

You understand your agent startup proc never returns. Surprised it actually works, but certainly not supported.

Posted by Valeriy Bashkatov on 28-Feb-2017 01:04

Hi David,

Thank you for your clarification!

Yes, I have noticed that my procedure is not completed after stopping agent. I had to manually kil that session.

Do I understand correctly that the listener architecture should look like this:

1. Run the batch process, which will start my ABL-program (JMSServerExample.p with small modifications), for example by cron.

2. Once the process receives a message, it calls the procedure on an application server to process the message and waits for the result.

3. Once the result is received, the process sends a response to queue in ESB.

In this architecture, I do not understand how to stop the work the batch process.

I'm new to this.

Maybe there are some ready examples to see how to implement it.

Regards,

Valeriy

Posted by Valeriy Bashkatov on 28-Feb-2017 02:25

Where can I find an example of configuring and using Sonic Adapter for OpenEdge on PASOE?

Posted by marian.edu on 28-Feb-2017 06:16

Valeriy,


what David depicted there should indeed work but I wouldn’t really go that route unless the only thing you have in your toolbox is a hammer… having a batch 4gl process to handle MQ messages, given it’s single threaded nature, the lack of control and the requirement of an ‘adapter’ doesn’t really compare with doing that in Java, just make a small web-app that you can deploy on tomcat - could even be the same instance running the PAS appsrv if you use that.

All it has to do is have some sort of configuration - for MQ and for appsrv - make the connection to the appsrv, listen to MQ queue/topic and make the calls on the appsrv, if need be push the response back through MQ to anyone interested in the result.

  
Marian Edu

Acorn IT 
+40 740 036 212

Posted by Valeriy Bashkatov on 01-Mar-2017 01:35

Hi Marian,

Thanks for the advice!

I'll think about it.

Regards,

Valeriy

Posted by marian.edu on 01-Mar-2017 02:52

Valeriy, 


if you need help cracking the Java bean let me know, we probably have more coffee than blood in our system already :)

Or I can just point you to akera.io, an MQ plugin can be easily crafted on top of Stomp (https://github.com/easternbloc/node-stomp-client) or IBM’s MQ Light for the impatient developers.

Cheers,

Marian Edu

Acorn IT 
+40 740 036 212

This thread is closed