Skip to content

Allow objects in message payload / enforce scalar values only for infrastructure reasons #68

@fritz-gerneth

Description

@fritz-gerneth

From Gitter earlier:

Sascha-Oliver Prolic
@fritz-gerneth you should be able to decide one day to integrate rabbitmq with a few simple steps, you shouldn't need to rewrite big parts of your application. Also you shouldn't know if the message is sent over the wire or not. Your stuff is supposed to just work, no matter what infrastructure is on the other side. Allowing objects in payload for most of the time (and sometimes not) only makes much bigger problems on the other end. I understand that you know your infrastructure and that you don't send messages somewhere else, but your limited situation is no reason for me to make the thing much more complex. Also how would you store events payload in the event store? This at least is a common problem with objects already, even if all your consumers would be PHP.

[...]
Fritz Gerneth
but I think the correct behavor would be that the default factories / converter throw the exception, not the message itself. that's what happening most of the time anway already. aka it should not the message to care about that but the infrastructure level. the default one does not allow objects, that's probably easier for everyone

Use-Case:

  • Event contains a composable VO (tree like structure with many different implementations of a shared composable interface)
  • Currently needs static mapping from array to object structure, very closed for extension, very open for modification, breaks modular approach and extensibility
  • Handle built-in types better (e.g. date)

My stance on this:

  • Messages itself should allow objects as payload
  • Validation should only be done on the infrastructure level
    -- MessageConverter / MessageFactgory implementations are responsible for this
    -- For the event store, the event store strategy is responsible for this
  • Default behvaior should still be to throw exceptions
  • This allows custom MessageConverters / .. capable of handling objects in the payload

Alternatives:

  • Re-implement command / event / query message types
  • Fix inconsistent behavior that messages can be created with objects in payload but fail validation when metadata is updated (which triggers payload validation, payload validation should be checked on set)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions