This may help:
http://activemq.apache.org/how-does-a-queue-compare-to-a-topic.html


On Mon, Jul 4, 2016 at 8:22 AM, Giang Tran <secm...@gmail.com> wrote:

> it's because you use single queue for both of consumer, in fanout
> exchange, message is copy to all the queue bind to this exchange.
> Inorder to has 2 copy, you must have to use 2 queue(use different queue
> name).
>
>
> On Monday, July 4, 2016 at 10:09:03 PM UTC+7, Rakesh Goyal wrote:
>>
>>
>>
>> down votefavorite
>> <http://stackoverflow.com/questions/38186283/golang-rabbit-mq-fanout-exchange-multiple-consumers#>
>>
>> I am publishing messages in fanout exchange from Java application. I am
>> able to receive message in multiple consumer in Java. I have 2 consumers in
>> golang app but only one of the consumer (alternatively ) is receiving the
>> message (Not both of them for a published message).
>>
>> func HandleMessageFanout1(){
>>
>>     conn := system.EltropyAppContext.RabbitMQConn
>>
>>     channel, err := conn.Channel()
>>
>>     if(err!=nil){
>>         log.Println(err)
>>     }
>>     //forever := make(chan bool)
>>
>>
>>
>>     deliveries,err := channel.Consume(
>>         "example.queue", //queue
>>         "qw",
>>         true,
>>         false,
>>         false,
>>         false,
>>         nil)
>>
>>     if(err!=nil){
>>         log.Println(err)
>>     }
>>
>>     go func() {
>>
>>         for d := range deliveries {
>>             log.Printf("Message recived in fanout 1")
>>             log.Printf("Received a message: %s", d.Body)
>>         }
>>     }()
>>
>>     //<-forever
>>
>> }
>>
>> //2nd Consumer
>>
>> package consumer
>>
>> import (
>>     "github.com/eltropy/shehnai/backend/golang/common-packages/system"
>>     log "github.com/Sirupsen/logrus"
>> )
>>
>>     func HandleMessageFanout2() {
>>
>>         conn := system.EltropyAppContext.RabbitMQConn
>>
>>         channel, err := conn.Channel()
>>
>>         if (err!=nil) {
>>             log.Println(err)
>>         }
>>
>>         //forever := make(chan bool)
>>
>>         deliveries, err := channel.Consume(
>>             "example.queue", //queue
>>             "q2",
>>             true,
>>             false,
>>             false,
>>             false,
>>             nil)
>>
>>         if (err!=nil) {
>>             log.Println(err)
>>         }
>>
>>         go func() {
>>             for d := range deliveries {
>>                 log.Printf("Message recived in fanout 2")
>>                 log.Printf("Received a message: %s", d.Body)
>>             }
>>         }()
>>
>>         //<-forever
>>
>>     }
>>
>> I am using https://github.com/streadway/amqp library for rabbit mq.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to