Lift module for Amazon SNS

107 views
Skip to first unread message

Richard Dallaway

unread,
Oct 4, 2012, 4:10:05 PM10/4/12
to lif...@googlegroups.com
Jono and I have published the Lift module we use to talk to Amazon SNS (Simple Notification Service):


It's available for Lift 2.4 and 2.5-M1.  

SNS is Amazon's pub/sub system. The module lets you register a function to receive messages from an SNS topic, and allows you to send messages to SNS.

We use it with comet actors across multiple servers. I.e. we use Amazon SNS as Diego uses CouchDB in his excellent post on distributed comet at https://fmpwizard.telegr.am/blog/distributed-comet-chat-lift 

We pimp LiftActor to add a >! method which "does the right thing" and either shuttle a message off to SNS as serialised JSON or just delivers it to the local actor if you've not configured SNS (e.g., during development). 

I'll blog about it when I next come up for air... :-)

Richard



David Pollak

unread,
Oct 4, 2012, 9:38:15 PM10/4/12
to lif...@googlegroups.com
Excellent!

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
 
 
 



--
Telegram, Simply Beautiful CMS https://telegr.am
Lift, the simply functional web framework http://liftweb.net


Diego Medina

unread,
Oct 4, 2012, 11:55:16 PM10/4/12
to lif...@googlegroups.com

Wow, this is really cool!

Diego
Sent from my android cell

Diego Medina

unread,
Oct 5, 2012, 1:16:05 AM10/5/12
to lif...@googlegroups.com
I just had a few minutes to read the code, looks very cool.

I saw a comment on SNS.scala#L91
https://github.com/SpiralArm/liftmodules-aws-sns/blob/master/src/main/scala/net/liftmodules/aws/sns/SNS.scala#L91

and yes, parse(s) will through an exception if by any chance you don;t
get valid json (I had that happened to me when I was parsing twitter
tweets, error messages come in html format, instead of json messages).

I used this instead:

https://github.com/fmpwizard/lift_starter_2.4/blob/lift_twitter_dispatch_comet/src/main/scala/com/fmpwizard/lib/TweetParser.scala#L18

val json = tryo{ t: Throwable => logger.info("Tried to parse
%s".format(s))}( parse(s) )

I hope I get some time to play around with your module and maybe add
other backends (I had in mind trying hornetq [1] )

[1] https://www.jboss.org/hornetq

Thanks

Diego
--
Diego Medina
Lift/Scala Developer
di...@fmpwizard.com
http://www.fmpwizard.com

Richard Dallaway

unread,
Oct 5, 2012, 6:45:07 AM10/5/12
to lif...@googlegroups.com
Thank you for the code review :-)  You're right, we should probably nicely log that case rather than let the exception bubble out - good idea.  I'll note it for next time we touch the code.

Cheers
Richard

Tyler Weir

unread,
Oct 5, 2012, 9:59:08 AM10/5/12
to lif...@googlegroups.com

We pimp LiftActor to add a >! method which "does the right thing" and either shuttle a message off to SNS as serialised JSON or just delivers it to the local actor if you've not configured SNS (e.g., during development). 

Nice! 

Richard Dallaway

unread,
Oct 6, 2012, 8:54:01 AM10/6/12
to lif...@googlegroups.com
On 5 October 2012 14:59, Tyler Weir <tyler...@gmail.com> wrote:

We pimp LiftActor to add a >! method which "does the right thing" and either shuttle a message off to SNS as serialised JSON or just delivers it to the local actor if you've not configured SNS (e.g., during development). 

Nice! 

Thank you, and further details are here: http://richard.dallaway.com/distributed-comet

Diego Medina

unread,
Oct 6, 2012, 1:37:51 PM10/6/12
to lif...@googlegroups.com
Thanks for the write up, one question, from

implicit object ChatFormat extends SNSSerializer[Chat] {
def json(t: Chat) : JObject = ("msg" -> chat.text)
}


is it suposed to be t.text ?

Thanks.

Diego

Richard Dallaway

unread,
Oct 6, 2012, 1:47:31 PM10/6/12
to lif...@googlegroups.com
Yes! Thank you.
Reply all
Reply to author
Forward
0 new messages