I am using akka 2.4 with eventstore 4.0.0.7 and I am new to event adapters

I have a Old event known us UserEvent (Class) which has only one class 
member known as email. Now I am switching to username and therefore this 
event variable email changes to username.

I have written a adapter to catch all UserEvent instances using instanceof 
and then convert it into UserEventV2 and return the new Object

Currently My adapter nor the akka system throws any error on console - But 
I get username as null, when the domain object is recovered.


Here's my code

class UserEventEmailToUsername implements EventAdapter {

      @Override
      public String manifest(Object event) {
        return ""; // if no manifest needed, return ""
      }

      @Override
      public Object toJournal(Object event) {
        return event; // identity
      }

      @Override
      public EventSeq fromJournal(Object event, String manifest) {
        if (event instanceof UserEvent) {
          UserEvent evt = (UserEvent) event;
          return EventSeq.single(new 
UserEventWithUsernameVersion(evt.getEmail()));
        }
        return EventSeq.single(event); // identity
      }
    }

here's my old event and new event class

@AllArgsConstructor@ToStringpublic class UserEvent extends EventWithTimeStamps 
implements Serializable {
  private static final long serialVersionUID = 1L;
  @Getter private String email;}
@AllArgsConstructor@ToStringpublic class UserEventWithUsernameVersion extends 
EventWithTimeStamps implements Serializable {
  private static final long serialVersionUID = 1L;
  @Getter private String username;}

akka configuration

      eventstore {
        event-adapters {
          userEvent-upcasting = 
"com.wt.domain.write.events.adapter.UserEventEmailToUsername"
        }

        event-adapter-bindings {
          "com.wt.domain.write.events.UserEvent"    = [userEvent-upcasting]
        }
      }

am I doing something wrong ? if not then why am I getting null value in 
username ?


Note: My debugger never touches in adapter :( - I believe there is some 
configuration issue's - please help

-- 
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
>>>>>>>>>> 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to