GithubHelp home page GithubHelp logo

Comments (5)

roblaszczak avatar roblaszczak commented on July 24, 2024

Hello@flamedmg, could you post some example code? Can you also post logs output? Thanks!

from watermill.

flamedmg avatar flamedmg commented on July 24, 2024

Here is how i create a router:

func NewRouter(config RouterConfig, pub message.Publisher, logger logur.Logger) (*message.Router, error) {
	h, err := message.NewRouter(
		message.RouterConfig{
			CloseTimeout: config.CloseTimeout,
		},
		watermilllog.New(logur.WithField(logger, "component", "watermill")),
	)
	if err != nil {
		return nil, errors.WithMessage(err, "failed to create message router")
	}

	retryMiddleware := middleware.Retry{}
	retryMiddleware.MaxRetries = 1
	retryMiddleware.MaxInterval = time.Second * 60

	h.AddMiddleware(
		PoisonQueue(pub),
		retryMiddleware.Middleware,
		middleware.Recoverer,
		middleware.CorrelationID,
	)

	return h, nil
}

If there is no such a queue in rabbitmq, there is no errors generated and poisoned messages are not delivered anywhere. I solved this by creating topology manually i.e. topology creates poisoned queue.

from watermill.

dwaynelavon avatar dwaynelavon commented on July 24, 2024

I am experiencing this issue as well.

from watermill.

roblaszczak avatar roblaszczak commented on July 24, 2024

Yeah, we had this issue as well. But to be honest I have no idea how to solve that properly. I see 2 options:

  1. Publisher should fail if it's publishing to queue that doesn't exist. But it may be tricky to "query" that. It can have performance implications as well.
  2. We can pass Subscriber to the middleware and call SubscribeInitializer.SubscribeInitialize(). It should create what is needed. Unfortunately, it's a bit weird that we need to provide subscriber for middleware.

I solved this by creating topology manually i.e. topology creates poison queue.

That sounds like the best idea, but it's easy to forget :(

@flamedmg @dwaynelavon any thoughts on that?

from watermill.

farzadmf avatar farzadmf commented on July 24, 2024

@flamedmg can I ask you how you implemented your own topology builder?

I'm trying to implement it, but it seems like the BuildTopology is not being called; something like this (this is just me testing to see if the functions are called)

type myBuilder struct {
	inner amqp.TopologyBuilder
}

func (m *myBuilder) BuildTopology(
	channel *stread_amqp.Channel,
	queueName string,
	exchangeName string,
	config amqp.Config,
	logger watermill.LoggerAdapter,
) error {
	fmt.Println("In BuildTopology")
	panic("error")
}

func (m myBuilder) ExchangeDeclare(
	channel *stread_amqp.Channel,
	exchangeName string,
	config amqp.Config,
) error {
	fmt.Println("In ExchangeDeclare")
	return m.inner.ExchangeDeclare(
		channel,
		exchangeName,
		config,
	)
}

func newMyBuilder() *myBuilder {
	return &myBuilder{
		inner: &amqp.DefaultTopologyBuilder{},
	}
}

and Then I'm setting this in my config:

poisonRabbitCfg := amqp.NewDurablePubSubConfig(
	cfg.RabbitURI,
	func(topic string) string {
		return topic
	},
)
poisonRabbitCfg.TopologyBuilder = newMyBuilder()

I see ExchangeDeclare being called, but the BuildTopology is not being called (as you see I'm even panicing in there to see if it's called, but it's not

I also tried with amqp.NewDurableQueueConfig (in my Rabbit config), but doesn't change anything

from watermill.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.