Code Monkey home page Code Monkey logo

Comments (4)

valinurovam avatar valinurovam commented on May 28, 2024

It's looke like some issue is here

log.Printf("callback: publish confirmed status [%v] from queue [%s]\n", confirm.Ack, ch.Queue())

channel.Queue method has a lock

func (ch *Channel) Queue() string {
	ch.baseChan.mu.RLock()
	defer ch.baseChan.mu.RUnlock()
	
	return ch.queue
}

If you change ch.Queue() for simple string, for example "queueName" - all is good

from garagemq.

valinurovam avatar valinurovam commented on May 28, 2024

It looks like lock/unluck on ch.Queue is useless and make some decrease in performance

from garagemq.

sujit-baniya avatar sujit-baniya commented on May 28, 2024

@valinurovam Thank you for response.

So you mean, If I remove lock, it might work?

Question: Is lock necessary there? Because I don't see any operations that might cause deadlock

from garagemq.

valinurovam avatar valinurovam commented on May 28, 2024

Looks like deadlock somewhere. If you change method like this

// Queue returns the active (as indicated by [IsDestination] option in topology options) queue name.
// Useful for finding the server assigned name.
func (ch *Channel) Queue() string {
	fmt.Println("try to get lock... ")
	ch.baseChan.mu.RLock()
	fmt.Println(" locked.")
	defer func() {
		fmt.Println(" unlocked.\n")
		ch.baseChan.mu.RUnlock()
	}()

	return ch.queue
}

Logs

try to get lock... 
2023/12/29 19:11:40 going to send: test number 1623
 locked.
 unlocked.

callback: publish confirmed status [true] from queue [workload]
try to get lock... 
2023/12/29 19:11:40 going to send: test number 1624
 locked.
 unlocked.

callback: publish confirmed status [true] from queue [workload]
2023/12/29 19:11:40 going to send: test number 1625
2023/12/29 19:11:40 going to send: test number 1626
2023/12/29 19:11:40 going to send: test number 1627
2023/12/29 19:11:40 going to send: test number 1628
try to get lock... 
2023/12/29 19:11:40 going to send: test number 1629
 locked.
 unlocked.

callback: publish confirmed status [true] from queue [workload]
try to get lock... 


from garagemq.

Related Issues (19)

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.