You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by "Robert A. Decker" <de...@robdecker.com> on 2012/07/22 19:14:03 UTC

proper way to do save and events?

Hi,

I create a node and save it, then fire off an event that starts a process that begins updating the node.

However, there are times when the node hasn't been written by the first save yet, and so my job processor has nothing to work on.

Is the correct strategy to have the job processor wait a few milliseconds and try again? and again and again…?


Rob

Re: proper way to do save and events?

Posted by "Robert A. Decker" <de...@robdecker.com>.
Ah, ok. That makes sense.

thanks,
Rob

On Jul 22, 2012, at 3:26 PM, Sarwar Bhuiyan wrote:

> There should be a sling event already fired after your node is created.
> That is the application event they are referring to.
> 
> Sarwar
> 
> On Sunday, 22 July 2012, Robert A. Decker wrote:
> 
>> Would that break the 'basic principles' as written here:
>> http://sling.apache.org/site/eventing-and-jobs.html
>> 
>> "The application should try to use application events instead of low level
>> JCR events whereever possible."
>> 
>> Is there a way to only receive node created events of a certain
>> sling:resourceType? Or will all node creation events come to my handler?
>> 
>> R
>> 
>> 
>> On Jul 22, 2012, at 1:59 PM, James Stansell wrote:
>> 
>>> Hi Robert,
>>> 
>>> You should also be able to setup a listener for the newly saved node and
>>> use it to fire the job event.
>>> 
>>> -james.
>>> 
>>> On Sun, Jul 22, 2012 at 12:30 PM, Robert A. Decker wrote:
>>> 
>>>> Or should I fire off the job again?
>>>> 
>>>> R
>>>> 
>>>> On Jul 22, 2012, at 1:14 PM, Robert A. Decker wrote:
>>>> 
>>>>> Hi,
>>>>> 
>>>>> I create a node and save it, then fire off an event that starts a
>>>> process that begins updating the node.
>>>>> 
>>>>> However, there are times when the node hasn't been written by the first
>>>> save yet, and so my job processor has nothing to work on.
>>>>> 
>>>>> Is the correct strategy to have the job processor wait a few
>>>> milliseconds and try again? and again and again…?
>>>>> 
>>>>> 
>>>>> Rob
>>>> 
>>>> 
>> 
>> 


Re: proper way to do save and events?

Posted by Sarwar Bhuiyan <sa...@gmail.com>.
There should be a sling event already fired after your node is created.
That is the application event they are referring to.

Sarwar

On Sunday, 22 July 2012, Robert A. Decker wrote:

> Would that break the 'basic principles' as written here:
> http://sling.apache.org/site/eventing-and-jobs.html
>
> "The application should try to use application events instead of low level
> JCR events whereever possible."
>
> Is there a way to only receive node created events of a certain
> sling:resourceType? Or will all node creation events come to my handler?
>
> R
>
>
> On Jul 22, 2012, at 1:59 PM, James Stansell wrote:
>
> > Hi Robert,
> >
> > You should also be able to setup a listener for the newly saved node and
> > use it to fire the job event.
> >
> > -james.
> >
> > On Sun, Jul 22, 2012 at 12:30 PM, Robert A. Decker wrote:
> >
> >> Or should I fire off the job again?
> >>
> >> R
> >>
> >> On Jul 22, 2012, at 1:14 PM, Robert A. Decker wrote:
> >>
> >>> Hi,
> >>>
> >>> I create a node and save it, then fire off an event that starts a
> >> process that begins updating the node.
> >>>
> >>> However, there are times when the node hasn't been written by the first
> >> save yet, and so my job processor has nothing to work on.
> >>>
> >>> Is the correct strategy to have the job processor wait a few
> >> milliseconds and try again? and again and again…?
> >>>
> >>>
> >>> Rob
> >>
> >>
>
>

Re: proper way to do save and events?

Posted by "Robert A. Decker" <de...@robdecker.com>.
Would that break the 'basic principles' as written here:
http://sling.apache.org/site/eventing-and-jobs.html

"The application should try to use application events instead of low level JCR events whereever possible."

Is there a way to only receive node created events of a certain sling:resourceType? Or will all node creation events come to my handler?

R


On Jul 22, 2012, at 1:59 PM, James Stansell wrote:

> Hi Robert,
> 
> You should also be able to setup a listener for the newly saved node and
> use it to fire the job event.
> 
> -james.
> 
> On Sun, Jul 22, 2012 at 12:30 PM, Robert A. Decker wrote:
> 
>> Or should I fire off the job again?
>> 
>> R
>> 
>> On Jul 22, 2012, at 1:14 PM, Robert A. Decker wrote:
>> 
>>> Hi,
>>> 
>>> I create a node and save it, then fire off an event that starts a
>> process that begins updating the node.
>>> 
>>> However, there are times when the node hasn't been written by the first
>> save yet, and so my job processor has nothing to work on.
>>> 
>>> Is the correct strategy to have the job processor wait a few
>> milliseconds and try again? and again and again…?
>>> 
>>> 
>>> Rob
>> 
>> 


Re: proper way to do save and events?

Posted by James Stansell <js...@gmail.com>.
Hi Robert,

You should also be able to setup a listener for the newly saved node and
use it to fire the job event.

-james.

On Sun, Jul 22, 2012 at 12:30 PM, Robert A. Decker wrote:

> Or should I fire off the job again?
>
> R
>
> On Jul 22, 2012, at 1:14 PM, Robert A. Decker wrote:
>
> > Hi,
> >
> > I create a node and save it, then fire off an event that starts a
> process that begins updating the node.
> >
> > However, there are times when the node hasn't been written by the first
> save yet, and so my job processor has nothing to work on.
> >
> > Is the correct strategy to have the job processor wait a few
> milliseconds and try again? and again and again…?
> >
> >
> > Rob
>
>

Re: proper way to do save and events?

Posted by "Robert A. Decker" <de...@robdecker.com>.
Or should I fire off the job again?

R

On Jul 22, 2012, at 1:14 PM, Robert A. Decker wrote:

> Hi,
> 
> I create a node and save it, then fire off an event that starts a process that begins updating the node.
> 
> However, there are times when the node hasn't been written by the first save yet, and so my job processor has nothing to work on.
> 
> Is the correct strategy to have the job processor wait a few milliseconds and try again? and again and again…?
> 
> 
> Rob


Re: proper way to do save and events?

Posted by Justin Edelson <ju...@gmail.com>.
Hi Robert,
Once you save the Session, the saved nodes should be visible to other
Sessions. Is your job processor using a long-lived session? If so, try
calling refresh on the Session. This is especially true if you are using
some kind of clustering.

Regards,
Justin
On Jul 22, 2012 1:14 PM, "Robert A. Decker" <de...@robdecker.com> wrote:

> Hi,
>
> I create a node and save it, then fire off an event that starts a process
> that begins updating the node.
>
> However, there are times when the node hasn't been written by the first
> save yet, and so my job processor has nothing to work on.
>
> Is the correct strategy to have the job processor wait a few milliseconds
> and try again? and again and again…?
>
>
> Rob