Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

Consumer configured via application.yml not working #136

Open
gtors opened this issue Jul 30, 2018 · 5 comments
Open

Consumer configured via application.yml not working #136

gtors opened this issue Jul 30, 2018 · 5 comments

Comments

@gtors
Copy link

gtors commented Jul 30, 2018

With configuration below, the consumer class is not listen incoming messages and not displayed in active connections of RabbitMQ

application.yml:

rabbitmq:
    connections:
      - name: default
        host: localhost
        username: guest
        password: guest
    queues:
      - name:  test
        durable: true
    consumers:
      MyConsumer:
        queue: test

MyConsumer.groovy:

class MyConsumer {

    // static rabbitConfig = [
    //    "queue": "test"
    // ]

    def handleMessage(String body, MessageContext context) {
       // ...
    }
}

But, if uncomment rabbitConfig in the class and remove configuration of consumer from application.yml, then all works as expected.

@gtors
Copy link
Author

gtors commented Jul 30, 2018

Fixed this by changing config:

    consumers:
      MyConsumer:
        queue: test
        match: all

@gtors gtors closed this as completed Jul 30, 2018
@kuceram
Copy link

kuceram commented Jan 2, 2019

Why closing this? I think that the match attribute should not be required. If it is required, than I would mention it in docs.

@budjb budjb reopened this Jan 2, 2019
@budjb
Copy link
Owner

budjb commented Jan 2, 2019

I'd need more information to be able to understand what's going on here, but match is only required when using a header exchange. I don't see an exchange configuration here (or binding, for that matter). @gtors what kind of exchange is that queue bound to, or is it? And how are you sending messages to that queue?

@gtors
Copy link
Author

gtors commented Jan 3, 2019

I no longer have access to the source code. But as far as I remember, the default exchange was used (i.e. it wasn't explicitly configured)

@kuceram
Copy link

kuceram commented Jan 3, 2019

In our case, we have following configuration:
Grails: 3.3.9
rabbitmq-native: 3.4.5

rabbitmq:
    connections:
        - host: my.host.com
          username: rabbitmg
          password: rabbitmg
          virtualHost: rabbitmg
          isDefault: true
          requestedHeartbeat: 10
    exchanges:
        - name: amq.topic
          type: topic
          durable: true
    queues:
        - name: my-server:message
          durable: true
          exchange: amq.topic
          binding: 'message.#'
    consumers:
        MessageConsumer:
            queue: my-server:message

This doesn't work: I don't receive the message into MessageConsumer:

class MessageConsumer {

    def handleMessage(def body) {
        log.debug("received rabbitmq message $body")
    }
}

When we add match: all to the configuration, it starts magically work:

rabbitmq:
    ...
    consumers:
        MessageConsumer:
            queue: my-server:message
            match: all

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants