prooph / snapshotter

Take aggregate snapshots with ease
http://getprooph.org
BSD 3-Clause "New" or "Revised" License
19 stars 11 forks source link

making TakeSnapshot command async #12

Closed guyradford closed 7 years ago

guyradford commented 8 years ago

Hi,

I see that the TakeSnapshot command is tightly bound to the SnapshotPlugin. I am looking for a way to run this async and wanted to add the AsyncMessage interface. This would require quote a bit of work extending classes. Would you have any objections to a config item to set the TakeSnapshot command, which defaults to what you already have?

Thank you Guy

prolic commented 8 years ago

Just route this command to the async message producer

Am 11.09.2016 20:27 schrieb "Guy Radford" notifications@github.com:

Hi,

I see that the TakeSnapshot command is tightly bound to the SnapshotPlugin. I am looking for a way to run this async and wanted to add the AsyncMessage interface. This would require quote a bit of work extending classes. Would you have any objections to a config item to set the TakeSnapshot command, which defaults to what you already have?

Thank you Guy

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/prooph/snapshotter/issues/12, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYEvFnbTn7aPJmJLdc7gMwx5l_ut7FJks5qo7t_gaJpZM4J58tX .

guyradford commented 8 years ago

Just tried it... because I am using the Async Message router it keeps getting routed back to the async message producer :(

prolic commented 8 years ago

Can you post your config? I'll give it a shot tomorrow.

guyradford commented 8 years ago

prooph:
  bernard_producer:

  service_bus:
    command_bus:
      plugins:
        - 'async_command_router'
      router:
        routes:
#          'Prooph\Snapshotter\TakeSnapshot': Prooph\Snapshotter\Snapshotter
          'Prooph\Snapshotter\TakeSnapshot': 'aysnc_message_producer'
          # list of commands with corresponding command handler

#    event_bus:
#      router:
#        routes:
#          # list of events with a list of projectors
#          'Prooph\ProophessorDo\Model\User\Event\UserWasRegistered':
#            - 'Prooph\ProophessorDo\Projection\User\UserProjector'
  event_store:
    # list of aggregate repositories
    send_collection:
      repository_class: 'TooBigToEmailApiBundle\Infrastructure\Repository\EventStoreSendCollection'
      aggregate_type: 'TooBigToEmailApiBundle\Model\Send\Send'
      aggregate_translator: 'Prooph\EventSourcing\EventStoreIntegration\AggregateTranslator'
      snapshot_store: 'Prooph\EventStore\Snapshot\SnapshotStore'

  snapshotter:
    version_step: 1 #every 5 events a snapshot
    aggregate_repositories:
      TooBigToEmailApiBundle\Model\Send\Send: 'TooBigToEmailApiBundle\Model\Send\SendCollection'
    TooBigToEmailApiBundle\Libs\CommandRouter:
        class: TooBigToEmailApiBundle\Libs\CommandRouter
        arguments:
          - '@service_container'

    aysnc_message_producer:
        class: \Prooph\ServiceBus\Message\Bernard\BernardMessageProducer
        factory: ['@TooBigToEmailApiBundle\Service\BernardMessageProducer.factory', '__invoke']

    TooBigToEmailApiBundle\Service\BernardMessageProducer.factory:
        class: TooBigToEmailApiBundle\Service\BernardMessageProducer
        arguments:
          - '@service_container'

    async_command_router:
        class: Prooph\ServiceBus\Plugin\Router\AsyncSwitchMessageRouter
        arguments:
          - '@toobigtoemailapibundle\libs\commandrouter'
          - '@aysnc_message_producer'

This happily sends it to the Async message producer. However my Command Router is wrapped with AsyncSwitchMessageRouter and uses the same command routes, so just keeps sending it back to the Async message producer.

Thank you

prolic commented 7 years ago

This is obsolete with the new major release