On Tue, Nov 10, 2009 at 4:19 PM, glenn <[email protected]> wrote:
>
> David,
>
> (This is a copy of an earlier reply to your Migration Guide post. I
> didn't get any response there, so I'm listing it on this
> thread since it seems somewhat related to the current discussion)
>
> I attempted to follow your blog piece and rewrite the code in
> Integrating Flex, BlazeDS, and Scala/Lift, at
> http://flexonrails.net/?p=103.
>
> Maybe I'm being a bit ambitious to redo this, but when I run just the
> Lift portion (without Flex/BazeDS) and make a call to my LiftActor
> implementation, nothing happens. Shouldn't the
> messageHandler be called automatically (There is nothing to "start",
> is there?). It doesn't when I trace through the code. What am I doing
> wrong?
>
> Here's my rewrite of Notifier using LiftActor:
>
> class Notifier extends LiftActor{
>
> val msgBroker = MessageBroker.getMessageBroker(null)
> val clientID = UUIDUtils.createUUID()
> val msg = new AsyncMessage()
> var notificationsSent = 0;
>
> val currentTime = new Date().getTime();
>
> protected def messageHandler = {
> case Notify =>{
> msg.setDestination("notifications")
> msg.setClientId(clientID)
> msg.setTimestamp(currentTime)
> msg.setBody(new Notification(notificationsSent, "Hello from
> Scala/Lift", new Date()))
> msgBroker.routeMessageToService(msg,null)
> notificationsSent = 1
>
> }
>
> LAPinger.schedule(this, Notify, 500L)
>
> }
>
> }
>
> case object Notify
>
> class Notification(var id: Int, var message: String, var timesent:
> Date){
> def getId = id
> def setId(id: Int) = this.id = id
> def getMessage = message
> def setMessage(m: String) = message = m
> def getTimesent = timesent
> def setTimesent(t: Date) = timesent = t
>
> }
>
> I also have an XMLApiHelper with:
>
> def dispatch: LiftRules.DispatchPF = {
> case Req("webservices" :: c :: Nil, "", GetRequest)=> () =>
> start_feed(c:String)
>
> and start_feed simply calls new Notifiier().
>
> Given this code, the URL: http://localhost:8080/webservices/Notify
> successfully calls into
> start_feed and creates Notifier but the messageHandler isn't called.
>
messageHandler will be called when a message is put into the Actor's
mailbox. There's nothing in any of this code that sends a Notify message to
a Notifier instance. That would look like:
val myNotifier = new Notifier
myNotifier ! Notify
Note that you have a: LAPinger.schedule(this, Notify, 500L) call that's
*inside* the Notify message handler case. This will send a Notify message
to this in 500 ms, but that scheduling will only happen as part of a Notify
message. If you change the code to:
class Notifier extends LiftActor{
val msgBroker = MessageBroker.getMessageBroker(null)
val clientID = UUIDUtils.createUUID()
val msg = new AsyncMessage()
var notificationsSent = 0;
val currentTime = new Date().getTime();
protected def messageHandler = {
case Notify =>{
msg.setDestination("notifications")
msg.setClientId(clientID)
msg.setTimestamp(currentTime)
msg.setBody(new Notification(notificationsSent, "Hello from
Scala/Lift", new Date()))
msgBroker.routeMessageToService(msg,null)
notificationsSent = 1
}
}
LAPinger.schedule(this, Notify, 500L)
}
The LAPinger call is part of the Notifier constructor (yeah, I think the
random constructors all over the class body is a mistake, but Martin
doesn't) and you'll get pinged in 500 ms.
Also, as a process note, I've been swamped with family issues over the last
3 weeks (our nanny's finally back so I don't have 1/2 of my workday devoted
to childcare), Derek's traveling with his family and Tim and Marius are
swamped at work. The questions on the list have backed up quite a bit. I'm
hoping to try to get some of the backlog of questions and tickets resolved.
Thanks,
David
>
> Any help is appreciated?
>
> Thanks,
>
> Glenn
>
> On Nov 10, 3:58 pm, David Pollak <[email protected]>
> wrote:
> > Can you code up a full working example of what you want to do and post it
> on
> > GitHub?
> >
> >
> >
> > On Sat, Nov 7, 2009 at 10:15 AM, oshyshko <[email protected]> wrote:
> >
> > > Removing BlazeDS servlet from LiftFilter coverage is a bad idea:
> > > If it is done so, lift-mapper creates separate transactions for all
> > > operations.
> >
> > >http://groups.google.com/group/liftweb/browse_thread/thread/e2c0dd2c5.
> ..
> >
> > > This means LiftFilter and BlazeDS servlet should become friends.
> >
> > > "LiftRules.passNotFoundToChain = true" is in my Boot.scala. The
> > > response is:
> > > ================================
> > > HTTP/1.1 200 OK
> > > Expires: Thu, 01 Jan 1970 00:00:00 GMT
> > > Set-Cookie: JSESSIONID=1a8mg0498vrwd;Path=/
> > > Content-Length: 0
> > > Server: Jetty(6.1.21)
> > > ================================
> >
> > > Note: if I remove LiftFilter, the servlet works fine.
> >
> > > Any ideas how to make LiftFilter not to intrude into BlazeDS deeds?
> >
> > > On Oct 31, 2:19 pm, Timothy Perrett <[email protected]> wrote:
> > > > You needed to specify the passNotFoundToChain var, thats why you were
> > > > getting the 404 originally - as you detail, its not needed to
> > > > explicitly set the /messagebroker URL in your web.xml.
> >
> > --
> > Lift, the simply functional web frameworkhttp://liftweb.net
> > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > Follow me:http://twitter.com/dpp
> > Surf the harmonics
> >
>
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---