PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: codecraig on October 02, 2008, 03:01:58



Title: Consumers Connected for a Long Time - Where to keep them?
Post by: codecraig on October 02, 2008, 03:01:58
So I have a Consumer which "subscribes" to a JMS topic.  Initially I had this thing in a Proxy so that it could get results and update its data, etc.

However, I felt like using Commands was a better approach.  The problem with a command is we must not use it to maintain state.  So, I shouldn't keep the "Consumer" object in it....b/c later I need to invoke "Consumer.unsubscribe" to clean up my connection.

Any suggestions on this?


Title: Re: Consumers Connected for a Long Time - Where to keep them?
Post by: puremvc on October 02, 2008, 04:55:03
Put the Consumer in a Proxy. You can always have a Command manipulate the Proxy if you feel the need, but don't make Commands long-lived. There's no way to retrieve a running Command to fiddle with this long-lived thing. This is the whole reason for the Proxy class, which is long lived, retrievable and is is intended to encapsulate any communications with the server necessary while making the data available to the rest of the app.
-=Cliff>