CommandPattern vs Server side Event Bus?

164 views
Skip to first unread message

Chris

unread,
Sep 29, 2009, 3:37:05 PM9/29/09
to Google Web Toolkit
Just had a quick question... I can see the benefits of the
CommandPattern to some extent, what I'm not sure about is why, if
we're using an Event Bus on the client side, one might not try and use
an event bus on the server side too with an "event bridge" (you might
say) in the middle.

- Each event would define whether it propagates to the server.
- The clients would be listening for events and all they would see is
their relevant events being fired. They wouldn't know whether the
event originated from the server and the client.
- The server components would be listening on to the server-side event
bus. In this case, the server would just fire off its response in the
form of an event that all other server components could see and if
need be this would propagate to the clients.

Just wondering what people think of that pattern? I'm rather new to
GWT and want to make my app as simple as possible, and it seems to me
it would be rather nice if my

Client Module says: "I need a list of names",
Server Module sees message "someone needs a list of names".
Server Module says "Someone needed a list of names and here it is"...

I guess in that way, the response can be shared by many clients. The
bridge in the middle could do some caching/filtering in the middle,
since clearly not all events would need to be propagated to the
server...

Just some thoughts...

charlie

unread,
Sep 29, 2009, 4:41:59 PM9/29/09
to google-we...@googlegroups.com
+1

PJ Gray

unread,
Sep 29, 2009, 5:09:24 PM9/29/09
to google-we...@googlegroups.com
Yeah, I have thought the same thing as I was implementing MVP/CommandPattern.   I have a few eventbus events that I handle with EventHandlers, but then I have the whole gwt rpc mechanism that uses my own generic action classes.   

Combining the two might be a good move, however it might get tricky crossing the great wall of javascript.   I am no gwt expert, so I don't know how tight a coupling you can get from your server side stuff and GwtEvent (assuming you still want to use eventhandlers).   

I am sure its doable though.

-pj

Trevis

unread,
Sep 30, 2009, 10:51:23 AM9/30/09
to Google Web Toolkit
The enherent problem with having a server side bus that talks to a
client bus is that the server can't initiate the event. . (due to the
non-push nature of the web) but the second issue is that a client bus
services one client where as the server bus would need to service
many. Questions spud arise like can a server event fire to a specific
client or only to an individual client?

In the application that I'm developing I have a polling thread in the
gwt client and an event broadcast system on he server to allow the
server to notify clients of notworthy activities. I don't use a bus
on the server to handle requests though I just use RPC and command
pattern.

On Sep 29, 4:09 pm, PJ Gray <pj4...@gmail.com> wrote:
> Yeah, I have thought the same thing as I was implementing
> MVP/CommandPattern.   I have a few eventbus events that I handle with
> EventHandlers, but then I have the whole gwt rpc mechanism that uses my own
> generic action classes.
>
> Combining the two might be a good move, however it might get tricky crossing
> the great wall of javascript.   I am no gwt expert, so I don't know how
> tight a coupling you can get from your server side stuff and GwtEvent
> (assuming you still want to use eventhandlers).
>
> I am sure its doable though.
>
> -pj
>

István Szoboszlai

unread,
Sep 30, 2009, 6:03:21 PM9/30/09
to google-we...@googlegroups.com
Hello,

Sure by nature http does not support events instantiated on by the server. But there are some workarounds. Try to google for http server push, or comet.

Best - Istvan
--
Best Regards
- István Szoboszlai
istvan.s...@inepex.com | +36 30 432 8533 | inepex.com

pedjak

unread,
Nov 17, 2009, 4:03:54 AM11/17/09
to Google Web Toolkit
> Sure by nature http does not support events instantiated on by the server.
> But there are some workarounds. Try to google for http server push, or
> comet.

Have you heard for Errai (http://jboss.org/errai) ? It seems that it
does exactly what you need.

Best,

Predrag

hbraun

unread,
Nov 25, 2009, 1:47:49 PM11/25/09
to Google Web Toolkit
right, errai-bus might be what you are looking for. Is does server
push and has an easy to use programming model.

Youngster

unread,
Nov 26, 2009, 3:48:22 AM11/26/09
to Google Web Toolkit
Wouldn't it become much slower if you handle all event via the server?
Reply all
Reply to author
Forward
0 new messages