On Tue, Apr 22, 2014 at 11:06 PM, Ramon Buckland <[email protected]>wrote:
> Hi All, > > Before I go and wind back my code change to my project.. I though I would > throw out to comment.. > > *Requirement: *That my Commands into the Processors carry metaData > (timestamp, accountId, userId) > And that my Events carry the same info on the way > out. > > *Problem: *If I use composition (put the "cmd" in a wrapper command, and > the same for the event) I have to peek inside the events to see what it > really was. > > *Details:(code samples)* > > My application is based off of my shared library - akka-escqrs ( > https://github.com/rbuckland/akka-escqrs) > This is just some application styled wrappers around akka-persistence.. > very much early days). > > The Scenario: > > spray.io --> command from client comes in as JSON and Gets Marshalled > into a specific CampusCommand (for example - AddNewCampus) > > I wanted to put some "metaData" on that Command , (I have been here before > ... https://groups.google.com/forum/#!topic/scala-user/ro57WMdH5EY ) > - so two options - > (1) composition newCmd = > (CampusESCommand(timestamp,metadata,campusCommand)) .. processor ask(newCmd) > (2) or macros .. > https://groups.google.com/forum/#!topic/scala-user/ro57WMdH5EY > > But .. when I changed my code around .. (bit of pimping) I note that My > Events that will come out (because of design) as the less specific > Composite versions and I would need to peek inside to see what it is. Of > course match / case will grab them, but I want to avoid all events going to > canidates just to check them unncessarily. > > This is my boilerplate code + a pimp to make me an ESCommand. > See https://gist.github.com/rbuckland/11193810 > > In essence .. > > processor ? addCampusCmd.toESCommand(accountId,userId) // sends a > CampusESCommand > > // processor will send out an CampusESEvent .. > > *My problem* > Problem is that "listeners" to the events are actually interested in > the CampusESEvent.event .. because it is "NewCampusAdded" > It is not as fine grained, so listening on channels, you would have to > unwrap all processor events of a type to see what real business event it is > carrying, which seems too much. > > Currently I have this type of code in some event listeners.. > > def messagesWeListenFor = Seq( classOf[NewCampusAdded] ) > > override def preStart() { > super.preStart() > > messagesWeListenFor.foreach(this.context.system.eventStream.subscribe(this.self, > _)) > } > > I'm trying to understand what the real problem is here. Is the problem that you publish the events via the eventStream and when you wrap the events all subscribers will receive all events and have to filter them after the fact? If that is the problem I would suggest that you publish the events via something else than the normal eventStream. Something that is aware of this wrapping. It can be an actor, or another implementation of EventBus Subchannelclassification<http://doc.akka.io/docs/akka/2.3.2/scala/event-bus.html#Subchannel_Classification> . Regards, Patrik > The alternative is to go down the route of writing a Macro .. so that all > events and commands carry the metadata directly . no wrapping. > > thoughts ? > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- Patrik Nordwall Typesafe <http://typesafe.com/> - Reactive apps on the JVM Twitter: @patriknw JOIN US. REGISTER TODAY! <http://www.scaladays.org/> Scala <http://www.scaladays.org/> Days <http://www.scaladays.org/> June 16th-18th, <http://www.scaladays.org/> Berlin <http://www.scaladays.org/> -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
