Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Implementing Server Push using LCDS 2.6

Avatar

Former Community Member

Hi All,

We have created an application where we are using polling to get certain constant updates. Now this polling is client polling wherein the client polls the server at regular intervals to get the fresh data for certain actions.

Now we wish to take this to another level and implement Server Data Push so that the client does not keep polling unnecessarily and the server notifies the client as and when the data gets updated with the server. For this we have the DataService Transaction class that needs to be implemented.

But there are a couple of questions that are in my mind regarding this technology. It would be great if someone could answer them.

My questions are:

1) Does the LCDS server know which client to push data to in case of multiple clients looking at the same data scenario. e.g. Two clients A and B are looking at the same data. A performs an action and that action needs some time to get completed at the server. Now in case we use Server Data Push, will the LCDS be intelligent enough to send the message on completion of the requested activity to only A and not B.

2) In order to push data to the client, the server will invoke some method which will return the desired data to te client. How do we keep the parameters registered with the server that this method would need while getting invoked. SInce, the call to the method will not be client initiated, how does the server know what parameters to be passed to the method in order to invoke it. How will this work in a multi-user looking at the same data/screen scenario.

The answers to these questions will really help us. In case anyone is well versed with this technology, please pitch in to give your inputs.

Many Thanks.

Regards,

Shally

1 Accepted Solution

Avatar

Correct answer by
Level 2

Before we can answer, I think we need a little more detail...Are you trying to have LCDS be the point of contact to initiate an asynchronous third party service that will then come back and tell LCDS to use data push to alert the client that made the request that it has been completed?

I think that is a little beyond the scope of LCDS's 'out of the box' capabilities...but not impossible at all

To answer your questions though:

1. No, LCDS out of the box will not know which client to push a message to automatically, but yes, you can send the response to a specific client through their client ID, and if you can track that ID by sending the ID off with your initial request to your third party service and have it return it back as well so your client can be pushed to.

2. This is a little more complex and I think we need more detail before we can even begin to answer this one...

View solution in original post

4 Replies

Avatar

Correct answer by
Level 2

Before we can answer, I think we need a little more detail...Are you trying to have LCDS be the point of contact to initiate an asynchronous third party service that will then come back and tell LCDS to use data push to alert the client that made the request that it has been completed?

I think that is a little beyond the scope of LCDS's 'out of the box' capabilities...but not impossible at all

To answer your questions though:

1. No, LCDS out of the box will not know which client to push a message to automatically, but yes, you can send the response to a specific client through their client ID, and if you can track that ID by sending the ID off with your initial request to your third party service and have it return it back as well so your client can be pushed to.

2. This is a little more complex and I think we need more detail before we can even begin to answer this one...

Avatar

Former Community Member

Hi,

Thanks for your prompt reply.

You are correct in understanding that LCDS will be a point of contact to initiate a Java Service which in turn initiates the operations to be performed at the backend as a result of an action perfomred at the client. Now there will be a scheduler at the server side which wll be constatntly monitoring the module that is doing the processing for the action perfomed. As and when this service gets the completion flag, this service will tell the LCDS to use data push to alert the client that had made the request.

Let me give you an overview of the various layers in our application.

There is a client(Flex UI) which allows user to initiate a request. This UI calls a method of the Utility.jar which is deployed in Flex. war which inturn calls the ejb and then the spring component. Finally this request is submitted to the Queues (Rabbit MQ) which finally submit the message to the module responsible for doing the actions for the request submitted by the client. This is an async process. When the client submits the request, we inform the client that the message has been submitted. But when the module responsible for perfoming the actions is through with its job, it needs to push the completion status to the appropriate client. For this we plan to have a scheduler monitoring the module and getting to know from it as to when the action has got completed and tell LCDS that now it can pass on the message to the appropriate client.

As told by you for using the clientId to push message to teh apprprite client, can you please let me know a link of the same. Or is it there in the Adobe LiveCycle docs.

Thanks again for your help and prompt reply.

Regards,

Shally

Avatar

Level 2

Okay, sounds like what I was expecting.  I could ramble on about how to achieve this using a custom implementation of push messaging, but I think that would actually be overkill..the simple answer is if you have access to LCDS then you have access to RTMP which allows for non-polling message topics.  Could you possibly setup a RTMP channel with subtopics enabled and each client that makes the request brings up a subtopic that the server will respond to when done?  Then you could use an asynchronous consumer on the client side to wait for the response?

The only downside to this is that you have no idea of knowing if the client is still connected at that point...but I'm going to assume you can keep it in a message queue or database and instead of pushing the full data back automatically, just alert the client that they need to then make a request for the data once it is completed by posting a message on the topic...that way you know when they got the data and you can hold on to it until the next time the client hooks up and ping for any pending data

Avatar

Former Community Member

Hi,

As also, suggested by you, we were thinking of using an RTMP channel only for this since its a two way socket that establishes a communication channel between the client and the server and then helps keep messages moving to and fro.

We have successfully implemented RTMP channel and achieved the following functionalities.

1) A client initiated change which gets propagated to the server and then to all the clients.

2) Server push to all the clients.

Now our last step is to implement data push to a particular client. As told by you, we will use the client id but we have some doubts and questions regarding this since we do not have the code examples or anything that could help us in implementing the same.

I would therefore request you to kindly lead us on the following fronts:

1) Is the client id the one that is part of the request- response thread, I saw a client id being printed in the logs when a request is made and the response comes.

2) What code needs to be written on the server side to extract this client id once a call is made so that it can keep this client id with itself to push a message later on.

3) What methods or API are available to be used to push this message to a particular client? Do we need to call the fill method of a particular client using the client id parameter and inform the client that its requested job has been done.

For (3) is the Messaging(Publish and Subscribe model) the right way to go??

It would be great if you could provide us some code snippets just to give us an idea from where we can take it up ourselves.

Looking forward to hear from you.

Many Thanks,

Shally

Message was edited by: testing34