Implementing Eventhandler from Extension

Implementing Eventhandler from Extension

  

Hello,


Case: Integrating Message Queueing in Outsystems


Problem:

I have build an Extension which takes care of sending and receiving messages from a Message Queue.

When receiving a message I want to invoke a method in Outsystems.


I have an EventHandler in my extension. Normally the client-backend implements this method to receive the message and handle it. Now i want Outsystems to be able to implement that method so that i can show a list of received messages.

Hi Tim,

In what way have you implemented receiving the messages? Actions inside an Extension can be called from an OutSystems application, but afaik there's no way to have it stay listening in the background, so you'll always have to actively poll the message queue.

Solution

Hello Tim

Maybe this will be of help.

https://www.roelvanlisdonk.nl/2013/11/06/how-to-dynamically-call-an-action-in-outsystems-based-on-the-espace-name-and-action-name/

But beware, as I think this kind of implementation makes use of undocumented features (speaking of OutSystems) and can become incompatible In the future, I guess...

Cheers.

Solution

Eduardo,

I would personally use BPT for this (using the LogRecords API from the extension etc.), but I wouldn't want to complicate things before knowing what Tim's up to :).

I agree with you Kilian,

Even more because you can implement a message system that can "talk" between sessions and users, what I think is not possible with the method above.

But it is an interesting possibility anyway.

One that, in fact, we should be very cautious about using it... ??

Cheers

Hello guys,


Thanks for the quick reaction, I was prepared to wait for a couple of days.


The use case isn't really there, since i'm just researching the Integration of Outsystems with different systems/techniques.

One use case i could come up with is a chat application where you want to retain any messages if the person is offline. (Just a quick example).


I know that it is possible with actively polling, although I think this would be a compromise and not as effective.

I'll be sure to check the blog you send me Eduardo. I was already thinking of using some reflection, but had no clue how i should go about it.


At this point i think that using reflection would best suit my problem, so i will look into implementing that.


Greetings,

Tim

Tim, 

Just a couple comments.
I think the solution presented in the link will not work "cross session".

For a "chat" system, you have some nice solutions in forge, including something kind of "ready to use", an example of how to implement a Chat, that works both in Web and Mobile. And could be adapted to a "message system" that is not a chat, anyway.

The BPT solution is even more suited if you are dealing with "processes", so the messages are triggered due actions/new records, etc. 

As to offline, you will always have to resort to database, and in this case, BPT probably would be better.

Cheers.

Hey Eduardo,


I think the solution will work cross session. It just depends on what Queue you are listening, although since i havent tested it yet I can't be certain.

The chat system was just an easy example of where Message Queueing could be used. I do not intent to actually build a chat app.


I will also be sure to check into BPT for my reseach.

With offline i meant when a user went offline that any messages sent would still be in the queue and he would be able to receive them when he starts listening to the queue again., sorry for the confusion there.


I will try to make some time to run some tests next week and post the results in here for future reference.


Greetings,

Tim

Hi Tim,

A last thought: if you are integrating with a message queue, can't the mq call a REST service? If so, you can expose a REST service in OutSystems, which will be called anytime there's something in the queue. You can process it directly, or use BPT, or a timer, or whatever you want to do with it.

Kilian Hekhuis wrote:

Hi Tim,

A last thought: if you are integrating with a message queue, can't the mq call a REST service? If so, you can expose a REST service in OutSystems, which will be called anytime there's something in the queue. You can process it directly, or use BPT, or a timer, or whatever you want to do with it.

This might indeed work, although i want to try calling on action on the screen (not yet sure if its possible with Reflection, or just the Server actions in general).


And this feels like a big workaround for the problem. Although i have to say that using the reflection will also be a workaround, but i think that is a bit cleaner. Although the Rest call would be better maintainable since Outsystems supports it.


I will take this into considering for my research, thanks for the addition.


Ok, 


I found a solution that works. It's not pretty though, but not that ugly.


Let me first say what i did:

My rabbitMQ server gives the signal that there is a new message.

My extension catches that signal and calls a Rest method.


From this point i used https://www.outsystems.com/forge/component/1493/pusherwebsockets/ 

My Rest method called the server side from the Pusherwebsockets. 

In my webpage the client is located. This receives the onNotify. In the onNotify I now have the message.

Now i am free to do with the message whatever i want. and it will automatically receive new messages.


What failed:

Reflection did not work. The reason for this is that the RabbitMQ server called the receive, not Outsystems. So the library didnt have access to Outsystems at that time. (My guess, since it also wouldnt log here)


Thanks for all the help.

Hi Tim,

Since an extension always runs in the context of an eSpace, and eSpaces afaik aren't loaded until needed, I'm really curious how you created an extension that seemingly always responds to the MQ.