/** * Method is called if all defined conditions are met and the feature is marked as enabled. * Use this method to configure and initialize all required components for the feature like * the steps in the pipeline or the instances/factories in the container. * * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { /** @var OutboundTransport $outboundTransport */ $outboundTransport = $settings->get(OutboundTransport::class); $sendInfrastructure = $outboundTransport->configure($settings); $builder->defineSingleton(MessageDispatcherInterface::class, $sendInfrastructure->getMessageDispatcherFactory()); }
/** * Method is called if all defined conditions are met and the feature is marked as enabled. * Use this method to configure and initialize all required components for the feature like * the steps in the pipeline or the instances/factories in the container. * * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { $localAddress = $settings->get(KnownSettingsEnum::LOCAL_ADDRESS); $builder->defineSingleton(UnicastRouterInterface::class, function () use($localAddress, $builder, $settings) { return new UnicastRouter($localAddress, $builder->build(UnicastRoutingTable::class), $settings->get(TransportInfrastructure::class)); }); $pipelineModifications->registerStep('UnicastSendRoutingConnector', UnicastSendRoutingConnector::class, function () use($builder) { return new UnicastSendRoutingConnector($builder->build(UnicastRouterInterface::class), $builder->build(OutgoingContextFactory::class)); }); $pipelineModifications->registerStep('UnicastReplyRoutingConnector', UnicastReplyRoutingConnector::class, function () use($builder) { return new UnicastReplyRoutingConnector($builder->build(OutgoingContextFactory::class)); }); $pipelineModifications->registerStep('MulticastPublishRoutingConnector', MulticastPublishRoutingConnector::class, function () use($builder) { return new MulticastPublishRoutingConnector($builder->build(OutgoingContextFactory::class)); }); $canReceive = !$settings->get(KnownSettingsEnum::SEND_ONLY); if ($canReceive) { $pipelineModifications->registerStep('AttachReplyToAddressPipelineStep', AttachReplyToAddressPipelineStep::class, function () use($localAddress) { return new AttachReplyToAddressPipelineStep($localAddress); }); /** @var TransportInfrastructure $transportInfrastructure */ $transportInfrastructure = $settings->get(TransportInfrastructure::class); $subscriptionManagerFactory = $transportInfrastructure->configureSubscriptionInfrastructure(); $builder->defineSingleton(SubscriptionManagerInterface::class, $subscriptionManagerFactory->getSubscriptionManagerFactory()); $pipelineModifications->registerStep('SubscribeTerminator', SubscribeTerminator::class, function () use($builder) { return new SubscribeTerminator($builder->build(SubscriptionManagerInterface::class)); }); $pipelineModifications->registerStep('UnsubscribeTerminator', UnsubscribeTerminator::class, function () use($builder) { return new UnsubscribeTerminator($builder->build(SubscriptionManagerInterface::class)); }); } }
/** * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { $this->registerStartupTask(function (BuilderInterface $builder) { /** @var MessageHandlerRegistry $handlerRegistry */ $handlerRegistry = $builder->build(MessageHandlerRegistry::class); return new SubscriptionApplierStartupTask($handlerRegistry->getEventFqcns()); }); }
/** * Method is called if all defined conditions are met and the feature is marked as enabled. * Use this method to configure and initialize all required components for the feature like * the steps in the pipeline or the instances/factories in the container. * * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { $pipelineModifications->registerStep('OutgoingPhysicalToDispatchConnector', OutgoingPhysicalToDispatchConnector::class, function () use($builder) { return new OutgoingPhysicalToDispatchConnector($builder->build(OutgoingContextFactory::class), $builder->build(DateTimeConverter::class), $builder->build(ClockInterface::class)); }); $pipelineModifications->registerStep('ImmediateDispatchTerminator', ImmediateDispatchTerminator::class, function () use($builder) { return new ImmediateDispatchTerminator($builder->build(MessageDispatcherInterface::class)); }); }
/** * Method is called if all defined conditions are met and the feature is marked as enabled. * Use this method to configure and initialize all required components for the feature like * the steps in the pipeline or the instances/factories in the container. * * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { $pipelineModifications->registerStep('OutgoingLogicalMessageMutation', OutgoingLogicalMessageMutationPipelineStep::class, function () use($builder) { return new OutgoingLogicalMessageMutationPipelineStep($builder->build(MessageMutatorRegistry::class)); }); $pipelineModifications->registerStep('OutgoingPhysicalMessageMutation', OutgoingPhysicalMessageMutationPipelineStep::class, function () use($builder) { return new OutgoingPhysicalMessageMutationPipelineStep($builder->build(MessageMutatorRegistry::class)); }); }
/** * Method is called if all defined conditions are met and the feature is marked as enabled. * Use this method to configure and initialize all required components for the feature like * the steps in the pipeline or the instances/factories in the container. * * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { $maxRetries = $this->getMaxRetries($settings); $builder->defineSingleton(FirstLevelRetryStorage::class, new FirstLevelRetryStorage()); $builder->defineSingleton(FirstLevelRetryPolicy::class, new FirstLevelRetryPolicy($maxRetries)); $pipelineModifications->registerStep('FirstLevelRetryPipelineStep', FirstLevelRetryPipelineStep::class, function () use($builder) { return new FirstLevelRetryPipelineStep($builder->build(FirstLevelRetryStorage::class), $builder->build(FirstLevelRetryPolicy::class)); }); }
/** * Method is called if all defined conditions are met and the feature is marked as enabled. * Use this method to configure and initialize all required components for the feature like * the steps in the pipeline or the instances/factories in the container. * * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { $outboxEnabled = FeatureSettingsExtensions::isFeatureActive(OutboxFeature::class, $settings); if ($outboxEnabled) { $builder->defineSingleton(OutboxStorageInterface::class, function () use($builder, $settings) { return new InMemoryOutboxStorage(); }); } }
/** * Method is called if all defined conditions are met and the feature is marked as enabled. * Use this method to configure and initialize all required components for the feature like * the steps in the pipeline or the instances/factories in the container. * * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { $pipelineModifications->registerStep('LoadHandlersConnector', LoadHandlersConnector::class, function () use($builder) { return new LoadHandlersConnector($builder->build(MessageHandlerRegistry::class), $builder->build(IncomingContextFactory::class)); }); $pipelineModifications->registerStep('InvokeHandlerTerminator', InvokeHandlerTerminator::class, function () use($builder) { return new InvokeHandlerTerminator(); }); }
/** * @param string $stageContextFqcn * @param PipelineModifications $pipelineModifications * * @return PipelineInterface */ public function createStartingWith($stageContextFqcn, PipelineModifications $pipelineModifications) { $stepChainBuilder = $this->chainBuilderFactory->createChainBuilder($stageContextFqcn, $pipelineModifications); $stepRegistrations = $stepChainBuilder->build(); $stepInstances = []; foreach ($stepRegistrations as $registration) { $stepInstances[] = $this->builder->build($registration->getStepFqcn()); } return new Pipeline($stepInstances); }
/** * Method is called if all defined conditions are met and the feature is marked as enabled. * Use this method to configure and initialize all required components for the feature like * the steps in the pipeline or the instances/factories in the container. * * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { /** @var QueueBindings $queueBindings */ $queueBindings = $settings->get(QueueBindings::class); $queueBindings->bindReceiving($settings->get(KnownSettingsEnum::LOCAL_ADDRESS)); /** @var InboundTransport $inboundTransport */ $inboundTransport = $settings->get(InboundTransport::class); $receiveInfrastructure = $inboundTransport->configure($settings); $builder->defineSingleton(MessagePusherInterface::class, $receiveInfrastructure->getMessagePusherFactory()); $builder->defineSingleton(QueueCreatorInterface::class, $receiveInfrastructure->getQueueCreatorFactory()); $this->registerInstallTask(function () use($builder, $settings) { return new QueueCreatorFeatureInstallTask($builder->build(QueueCreatorInterface::class), $settings); }); }
/** * Method is called if all defined conditions are met and the feature is marked as enabled. * Use this method to configure and initialize all required components for the feature like * the steps in the pipeline or the instances/factories in the container. * * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { /** @var SerializationDefinition $definition */ $definition = $settings->get(SerializationDefinition::class); $serializerFactory = $definition->formalize($settings); $builder->defineSingleton(MessageSerializerInterface::class, $serializerFactory); $builder->defineSingleton(MessageDeserializerResolver::class, function () use($builder) { $serializer = $builder->build(MessageSerializerInterface::class); return new MessageDeserializerResolver([$serializer], get_class($serializer)); }); $builder->defineSingleton(IncomingLogicalMessageFactory::class, new IncomingLogicalMessageFactory()); $pipelineModifications->registerStep('DeserializeLogicalMessageConnector', DeserializeLogicalMessageConnector::class, function () use($builder) { return new DeserializeLogicalMessageConnector($builder->build(MessageDeserializerResolver::class), $builder->build(IncomingLogicalMessageFactory::class), $builder->build(IncomingContextFactory::class)); }); $pipelineModifications->registerStep('SerializeMessageConnector', SerializeMessageConnector::class, function () use($builder) { return new SerializeMessageConnector($builder->build(MessageSerializerInterface::class), $builder->build(OutgoingContextFactory::class)); }); }
/** * @return EndpointInstance */ public function start() { if (!$this->isPrepared) { $this->prepare(); } if (!$this->settings->tryGet(KnownSettingsEnum::SEND_ONLY)) { /** @var TransportReceiver $transportReceiver */ $transportReceiver = $this->builder->build(TransportReceiver::class); $transportReceiver->start(); } return new EndpointInstance($this->busContext); }
/** * Method is called if all defined conditions are met and the feature is marked as enabled. * Use this method to configure and initialize all required components for the feature like * the steps in the pipeline or the instances/factories in the container. * * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { $builder->defineSingleton(LogicalConnection::class, new LogicalConnectionFactory($settings)); $builder->defineSingleton(OutboxPersister::class, function () use($builder, $settings) { return new OutboxPersister($builder->build(LogicalConnection::class), $settings->get(Doctrine1KnownSettingsEnum::OUTBOX_MESSAGES_TABLE_NAME), $settings->get(Doctrine1KnownSettingsEnum::OUTBOX_ENDPOINTS_TABLE_NAME)); }); $builder->defineSingleton(OutboxStorageInterface::class, function () use($builder, $settings) { return new Doctrine1OutboxStorage($builder->build(OutboxPersister::class), new OutboxMessageConverter(), $settings->get(Doctrine1KnownSettingsEnum::OUTBOX_ENDPOINT_ID)); }); $this->registerStartupTask(function () use($builder, $settings) { return new EndpointIdLoaderFeatureStartupTask($builder->build(OutboxPersister::class), $settings, $settings->get(KnownSettingsEnum::ENDPOINT_NAME)); }); $this->registerStartupTask(function () use($builder, $settings) { return new OutboxCleanerFeatureStartupTask($builder->build(OutboxPersister::class), new \DateTime('now', new \DateTimeZone('UTC')), $settings->tryGet(KnownSettingsEnum::DAYS_TO_KEEP_DEDUPLICATION_DATA)); }); $this->registerInstallTask(function () use($builder, $settings) { return new OutboxTablesCreatorFeatureInstallTask($builder->build(LogicalConnection::class), new OutboxEndpointSchemaProvider(), new OutboxMessageSchemaProvider(), $settings->get(Doctrine1KnownSettingsEnum::OUTBOX_ENDPOINTS_TABLE_NAME), $settings->get(Doctrine1KnownSettingsEnum::OUTBOX_MESSAGES_TABLE_NAME)); }); }
/** * Method is called if all defined conditions are met and the feature is marked as enabled. * Use this method to configure and initialize all required components for the feature like * the steps in the pipeline or the instances/factories in the container. * * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { $errorQueue = $settings->get(KnownSettingsEnum::ERROR_QUEUE); /** @var QueueBindings $queueBindings */ $queueBindings = $settings->get(QueueBindings::class); $queueBindings->bindSending($errorQueue); $localAddress = $settings->get(KnownSettingsEnum::LOCAL_ADDRESS); $builder->defineSingleton(ExceptionToHeadersConverter::class, function () use($builder) { return new ExceptionToHeadersConverter($builder->build(ClockInterface::class), $builder->build(DateTimeConverter::class)); }); $registration = $pipelineModifications->registerStep('MoveErrorsToErrorQueuePipelineStep', MoveErrorsToErrorQueuePipelineStep::class, function () use($errorQueue, $localAddress, $builder) { /** @var PipelineFactory $pipelineFactory */ $pipelineFactory = $builder->build(PipelineFactory::class); return new MoveErrorsToErrorQueuePipelineStep($errorQueue, $localAddress, $pipelineFactory->createStartingWith(DispatchContext::class, $builder->build(PipelineModifications::class)), $builder->build(ExceptionToHeadersConverter::class), $builder->build(OutgoingContextFactory::class)); }); $registration->insertBeforeIfExists('FirstLevelRetryPipelineStep'); $registration->insertBeforeIfExists('SecondLevelRetryPipelineStep'); }
/** * Method is called if all defined conditions are met and the feature is marked as enabled. * Use this method to configure and initialize all required components for the feature like * the steps in the pipeline or the instances/factories in the container. * * @param Settings $settings * @param BuilderInterface $builder * @param PipelineModifications $pipelineModifications */ public function setup(Settings $settings, BuilderInterface $builder, PipelineModifications $pipelineModifications) { $supportedStorageTypes = $settings->get(KnownSettingsEnum::SUPPORTED_STORAGE_TYPE_VALUES); if (!in_array(StorageType::OUTBOX, $supportedStorageTypes)) { throw new UnexpectedValueException("Selected persistence doesn't have support for outbox storage. " . "Please select another storage or disable the outbox feature using endpointConfigurator.disableFeature."); } $pipelineModifications->registerStep('OutboxConnector', OutboxConnector::class, function () use($builder) { /** @var PipelineFactory $pipelineFactory */ $pipelineFactory = $builder->build(PipelineFactory::class); return new OutboxConnector($pipelineFactory->createStartingWith(DispatchContext::class, $builder->build(PipelineModifications::class)), $builder->build(OutboxStorageInterface::class), $builder->build(IncomingContextFactory::class), $builder->build(OutgoingContextFactory::class), new TransportOperationsConverter(new OutboxTransportOperationFactory())); }); }
/** * @param BuilderInterface $builder */ public function registerInBuilder(BuilderInterface $builder) { if ($this->factory) { $builder->defineSingleton($this->stepFqcn, $this->factory); } }