Class UserCreatedEvent

java.lang.Object
com.broadleafcommerce.customer.messaging.domain.UserCreatedEvent
All Implemented Interfaces:
Serializable

public class UserCreatedEvent extends Object implements Serializable
A message event received when a user in Auth is created.

There are two scenarios for this event:

  1. User registration
  2. Customer create via API. This triggers a User creation event in Auth.
In case #1, the event originates from an action in Auth. This is fairly straightforward, with an Auth user creation, then a corresponding customer creation for that Auth user.

In case #2, the event originates from an action in Customer. This scenario results in a bit of back and forth. There is a soft link between an Auth user and Customer via an attribute on Customer, the "user_id", but when a customer is created via API, an Auth user does not exist. The flow is:

  1. Customer is created - Triggers customer creation event
  2. Auth receives customer creation event - Creates user
  3. Customer receives user created event - Updates customer with auth generated user ID
  4. Auth receives customer update event - The User data here has not changed. This is a no-op in Auth.

As mentioned above, keep in mind that auth listens to customer update events. Because of this, customer does not listen to auth User update events. We would have an infinite loop of updates as both services would constantly trigger update events. Therefore, any changes to a customer's data that synchronizes with Auth (e.g. name, email, etc.) after initial creation should only be done via the Customer API.

See Also:
  • Constructor Details

    • UserCreatedEvent

      public UserCreatedEvent()
  • Method Details

    • isPreview

      public boolean isPreview()
      Indicates whether the user was created from a preview context.
    • getAttributes

      public Map<String,Object> getAttributes()
      Additional custom information that was provided as part of the user registration process.

      Client implementations may choose to populate and utilize this field for custom behavior.

    • setUser

      public void setUser(User user)
    • setPreview

      public void setPreview(boolean preview)
      Indicates whether the user was created from a preview context.
    • setAttributes

      public void setAttributes(Map<String,Object> attributes)
      Additional custom information that was provided as part of the user registration process.

      Client implementations may choose to populate and utilize this field for custom behavior.

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getUser

      @NonNull public User getUser()