Skip to content

chore(rabbitmq-channel): looking for the best channel configuration t…#408

Draft
acostapazo wants to merge 1 commit intomainfrom
fix/rabbitmq-channel-config
Draft

chore(rabbitmq-channel): looking for the best channel configuration t…#408
acostapazo wants to merge 1 commit intomainfrom
fix/rabbitmq-channel-config

Conversation

@acostapazo
Copy link
Copy Markdown
Contributor

…o publish and subscribe

@acostapazo acostapazo marked this pull request as draft September 5, 2023 21:59
@acostapazo
Copy link
Copy Markdown
Contributor Author

Other option is not calling basic_qos when we use it for publishing

Copy link
Copy Markdown
Contributor

@fgsalomon fgsalomon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand these changes...is it just a refactor?
Why not make the global_qos parameter configurable too?

Other option is not calling basic_qos when we use it for publishing

Why do you think this parameter is causing connection issues?

@acostapazo
Copy link
Copy Markdown
Contributor Author

I don't understand these changes...is it just a refactor?

I thought this channel configuration might be affecting publishers, but the error looks like it could be from using threads on subscribers and initializing another channel.

Why not make the global_qos parameter configurable too?

RabbitMqConnector is a singleton, so we need to do it when call get_channel to configure it proporly.

Other option is not calling basic_qos when we use it for publishing

Why do you think this parameter is causing connection issues?

From pika doc:

:param bool global_qos:    Should the QoS apply to all channels on the
                                             connection.

This made me wonder if he did some extra checking to reconcile all the channels.


Anyway, the problem was resolved. If we use a DomainEventBus into a subscriber it must be the inner one (self.domain_event_bus).

from petisco import DomainEvent, DomainEventSubscriber

class SmsSent(DomainEvent): ...

class SendSmsOnUserConfirmed(DomainEventSubscriber):
    def subscribed_to(self) -> List[Type[DomainEvent]]:
        return [UserConfirmed]

    def handle(self, domain_event: DomainEvent) -> BoolResult:
        print(f"> Send sms on {domain_event.format()}\n")
        
        self.domain_event_bus.publish(SmsSent()). # <----------- Use inner `domain_event_bus`

        return isSuccess  # if fails, returns isFailure

⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ The following code will raise connection errors ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️

from petisco import DomainEvent, DomainEventSubscriber

class SmsSent(DomainEvent): ...

class SendSmsOnUserConfirmed(DomainEventSubscriber):
    def subscribed_to(self) -> List[Type[DomainEvent]]:
        return [UserConfirmed]

    def handle(self, domain_event: DomainEvent) -> BoolResult:
        print(f"> Send sms on {domain_event.format()}\n")
    
        domain_event_bus = Container.get(DomainEventBus) # <----------- Don't use this. This will raise connection error
        domain_event_bus.publish(SmsSent())
        return isSuccess  # if fails, returns isFailure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants