src/Messaging/Config/MessagingSystemConfiguration.php
public function buildMessagingSystemFromConfiguration(ReferenceSearchService $referenceSearchService): ConfiguredMessagingSystem
    {
        foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
            if (!array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->channelBuilders)) {
                if (array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->defaultChannelBuilders)) {
                    $this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = $this->defaultChannelBuilders[$messageHandlerBuilder->getInputMessageChannelName()];
                } else {
                    $this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = SimpleMessageChannelBuilder::createDirectMessageChannel($messageHandlerBuilder->getInputMessageChannelName());
                }
            }
        }


        $interfaceToCallRegistry = InterfaceToCallRegistry::createWithInterfaces($this->interfacesToCall);
        $converters = [];
        foreach ($this->converterBuilders as $converterBuilder) {
            $converters[] = $converterBuilder->build($referenceSearchService);
        }
        $referenceSearchService = InMemoryReferenceSearchService::createWithReferenceService($referenceSearchService, [
            ConversionService::REFERENCE_NAME => AutoCollectionConversionService::createWith($converters),
            InterfaceToCallRegistry::REFERENCE_NAME => $interfaceToCallRegistry
        ]);

        $channelResolver = $this->createChannelResolver($referenceSearchService);
        $this->configureInterceptors($interfaceToCallRegistry);

        /** @var GatewayBuilder[][] $preparedGateways */
        $preparedGateways = [];
        foreach ($this->gatewayBuilders as $gatewayBuilder) {
            $preparedGateways[$gatewayBuilder->getReferenceName()][] = $gatewayBuilder;
        }
        $gateways = $this->configureGateways($preparedGateways, $referenceSearchService, $channelResolver);

        $consumerEndpointFactory = new ConsumerEndpointFactory($channelResolver, $referenceSearchService, $this->consumerFactories, $this->pollingMetadata);
        $consumers = [];

        foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
            $consumers[] = $consumerEndpointFactory->createForMessageHandler($messageHandlerBuilder);
        }

        foreach ($this->channelAdapters as $channelAdapter) {
            $consumers[] = $channelAdapter->build($channelResolver, $referenceSearchService, array_key_exists($channelAdapter->getEndpointId(), $this->pollingMetadata) ? $this->pollingMetadata[$channelAdapter->getEndpointId()] : null);
        }

        return MessagingSystem::create($consumers, $gateways, $channelResolver);
    }
public function buildMessagingSystemFromConfiguration(ReferenceSearchService $referenceSearchService): ConfiguredMessagingSystem
    {
        foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
            if (!array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->channelBuilders)) {
                if (array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->defaultChannelBuilders)) {
                    $this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = $this->defaultChannelBuilders[$messageHandlerBuilder->getInputMessageChannelName()];
                } else {
                    $this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = SimpleMessageChannelBuilder::createDirectMessageChannel($messageHandlerBuilder->getInputMessageChannelName());
                }
            }
        }


        $interfaceToCallRegistry = InterfaceToCallRegistry::createWithInterfaces($this->interfacesToCall);
        $converters = [];
        foreach ($this->converterBuilders as $converterBuilder) {
            $converters[] = $converterBuilder->build($referenceSearchService);
        }
        $referenceSearchService = InMemoryReferenceSearchService::createWithReferenceService($referenceSearchService, [
            ConversionService::REFERENCE_NAME => AutoCollectionConversionService::createWith($converters),
            InterfaceToCallRegistry::REFERENCE_NAME => $interfaceToCallRegistry
        ]);

        $channelResolver = $this->createChannelResolver($referenceSearchService);
        $this->configureInterceptors($interfaceToCallRegistry);

        /** @var GatewayBuilder[][] $preparedGateways */
        $preparedGateways = [];
        foreach ($this->gatewayBuilders as $gatewayBuilder) {
            $preparedGateways[$gatewayBuilder->getReferenceName()][] = $gatewayBuilder;
        }
        $gateways = $this->configureGateways($preparedGateways, $referenceSearchService, $channelResolver);

        $consumerEndpointFactory = new ConsumerEndpointFactory($channelResolver, $referenceSearchService, $this->consumerFactories, $this->pollingMetadata);
        $consumers = [];

        foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
            $consumers[] = $consumerEndpointFactory->createForMessageHandler($messageHandlerBuilder);
        }

        foreach ($this->channelAdapters as $channelAdapter) {
            $consumers[] = $channelAdapter->build($channelResolver, $referenceSearchService, array_key_exists($channelAdapter->getEndpointId(), $this->pollingMetadata) ? $this->pollingMetadata[$channelAdapter->getEndpointId()] : null);
        }

        return MessagingSystem::create($consumers, $gateways, $channelResolver);
    }
public function buildMessagingSystemFromConfiguration ( ReferenceSearchService $ referenceSearchService ) : ConfiguredMessagingSystem { foreach ( $ this -> messageHandlerBuilders as $ messageHandlerBuilder ) { if ( ! array_key_exists ( $ messageHandlerBuilder -> getInputMessageChannelName ( ) , $ this -> channelBuilders ) ) { if ( array_key_exists ( $ messageHandlerBuilder -> getInputMessageChannelName ( ) , $ this -> defaultChannelBuilders ) ) { $ this -> channelBuilders [ $ messageHandlerBuilder -> getInputMessageChannelName ( ) ] = $ this -> defaultChannelBuilders [ $ messageHandlerBuilder -> getInputMessageChannelName ( ) ] ; } else { $ this -> channelBuilders [ $ messageHandlerBuilder -> getInputMessageChannelName ( ) ] = SimpleMessageChannelBuilder :: createDirectMessageChannel ( $ messageHandlerBuilder -> getInputMessageChannelName ( ) ) ; } } } $ interfaceToCallRegistry = InterfaceToCallRegistry :: createWithInterfaces ( $ this -> interfacesToCall ) ; $ converters = [ ] ; foreach ( $ this -> converterBuilders as $ converterBuilder ) { $ converters [ ] = $ converterBuilder -> build ( $ referenceSearchService ) ; } $ referenceSearchService = InMemoryReferenceSearchService :: createWithReferenceService ( $ referenceSearchService , [ ConversionService :: REFERENCE_NAME => AutoCollectionConversionService :: createWith ( $ converters ) , InterfaceToCallRegistry :: REFERENCE_NAME => $ interfaceToCallRegistry ] ) ; $ channelResolver = $ this -> createChannelResolver ( $ referenceSearchService ) ; $ this -> configureInterceptors ( $ interfaceToCallRegistry ) ; /** @var GatewayBuilder[][] $preparedGateways */ $ preparedGateways = [ ] ; foreach ( $ this -> gatewayBuilders as $ gatewayBuilder ) { $ preparedGateways [ $ gatewayBuilder -> getReferenceName ( ) ] [ ] = $ gatewayBuilder ; } $ gateways = $ this -> configureGateways ( $ preparedGateways , $ referenceSearchService , $ channelResolver ) ; $ consumerEndpointFactory = new ConsumerEndpointFactory ( $ channelResolver , $ referenceSearchService , $ this -> consumerFactories , $ this -> pollingMetadata ) ; $ consumers = [ ] ; foreach ( $ this -> messageHandlerBuilders as $ messageHandlerBuilder ) { $ consumers [ ] = $ consumerEndpointFactory -> createForMessageHandler ( $ messageHandlerBuilder ) ; } foreach ( $ this -> channelAdapters as $ channelAdapter ) { $ consumers [ ] = $ channelAdapter -> build ( $ channelResolver , $ referenceSearchService , array_key_exists ( $ channelAdapter -> getEndpointId ( ) , $ this -> pollingMetadata ) ? $ this -> pollingMetadata [ $ channelAdapter -> getEndpointId ( ) ] : null ) ; } return MessagingSystem :: create ( $ consumers , $ gateways , $ channelResolver ) ; }
Initialize messaging system from current configuration

@param ReferenceSearchService $referenceSearchService
@return ConfiguredMessagingSystem
@throws NoConsumerFactoryForBuilderException
@throws MessagingException
Initialize messaging system from current configuration