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,
 
_))
  }

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.

Reply via email to