chore(rabbitmq-channel): looking for the best channel configuration t…#408
chore(rabbitmq-channel): looking for the best channel configuration t…#408acostapazo wants to merge 1 commit intomainfrom
Conversation
…o publish and subscribe
|
Other option is not calling |
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.
RabbitMqConnector is a singleton, so we need to do it when call get_channel to configure it proporly.
From pika doc: This made me wonder if he did some extra checking to reconcile all the channels. Anyway, the problem was resolved. If we use a 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 isFailurefrom 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 |
…o publish and subscribe