houseofcat / turbocookedrabbit

A user friendly RabbitMQ library written in Golang.
MIT License
107 stars 20 forks source link

confirm no response #12

Closed aadog closed 4 years ago

aadog commented 4 years ago

confirm no response

   conn,err:=tcr.NewConnectionPool(&tcr.PoolConfig{
        ConnectionName:       "TurboCookedRabbit",
        URI:                  "amqp://localhost",
        ConnectionTimeout: 10,
        Heartbeat: 6,
        MaxConnectionCount: 10,
        MaxCacheChannelCount: 50,
        SleepOnErrorInterval: 100,
    })
    if err != nil {
        panic(err)
    }

    config, err := tcr.ConvertJSONFileToConfig("testseasoning.json")
    if err != nil {
        panic(err)
    }
    publisher := tcr.NewPublisherFromConfig(config, conn)
    letter := tcr.CreateMockRandomLetter("refush_token")
    publisher.PublishWithConfirmation(letter, time.Millisecond*500)

    for {
        select {
        case receipt := <-publisher.PublishReceipts():
            if !receipt.Success {
                fmt.Println(receipt)
                // log?
                // requeue?
                // break WaitLoop?
            }
        default:
            time.Sleep(time.Millisecond * 1)
        }
    }
houseofcat commented 4 years ago

I am sorry but there is not enough detail in this ticket to fully understand.

Your code never terminates. Your URI is also wrong in above, perhaps its correct in your code?

PublishWithConfirmation confirms internally - not externally - but you will get a receipt. You are only looking at failures (!receipt.Success) though so you never saw it. And you are in an infinite loop.