最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

rabbitmq - spring boot 3 upgrade causing delays in receiving message from rabbit mq - Stack Overflow

programmeradmin1浏览0评论

I'm upgrading from Spring Boot 2.7 to Spring Boot 3.3

  • Publisher(another app) publishes to exchange migration.rxi to queue migration.wq to exchange migration.rxo to queue migration.q

Mine is spring integration app with libraries : spring-boot-starter-amqp , spring-integration-amqp spring-boot-starter-integration

The application is currently on single consumer.

Using SimpleMessageListenerContainer : AUTO Acknowledgement Mode

  • Consumes message from queue migration.q
  • Calls various endpoints
  • If an exception occurs, goes to error Channel
  • In error channel retry count is incremented and message is put on retry exchange migration.rxo which delivers it to main queue migration.q for re-processing.

When publisher sends to exchange migration.rxo it is quick(microseconds)

When My App sends to exchange (for retry)migration.rxo it takes 5-6 seconds in Spring Boot 2. It is now taking around 35 seconds delay in Spring Boot 3.

My rabbit mq configuration is here :

    {
  "users": [
    {
      "name": "admin",
      "password_hash": "xyz",
      "hashing_algorithm": "pqr",
      "tags": "administrator"
    },
    {
      "name": "user",
      "password_hash": "abc",
      "hashing_algorithm": "mno",
      "tags": ""
    }
  ],
  "vhosts": [
    {
      "name": "/"
    }
  ],
  "permissions": [
    {
      "user": "user",
      "vhost": "/",
      "configure": "",
      "write": ".*",
      "read": ".*"
    },
    {
      "user": "admin",
      "vhost": "/",
      "configure": ".*",
      "write": ".*",
      "read": ".*"
    }
  ],
  "exchanges": [
    {
      "name": "migration.rxi",
      "vhost": "/",
      "type": "direct",
      "durable": false,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    },
    {
      "name": "migration.rxo",
      "vhost": "/",
      "type": "direct",
      "durable": false,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    },
    {
      "name": "migration.dlx",
      "vhost": "/",
      "type": "direct",
      "durable": false,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    },
    {
      "name": "migration.large.rxi",
      "vhost": "/",
      "type": "direct",
      "durable": false,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    },
    {
      "name": "migration.large.rxo",
      "vhost": "/",
      "type": "direct",
      "durable": false,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    },
    {
      "name": "migration.large.dlx",
      "vhost": "/",
      "type": "direct",
      "durable": false,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    }
  ],
  "queues": [
    {
      "name": "migration.q",
      "vhost": "/",
      "durable": false,
      "auto_delete": false,
      "arguments": {
        "x-dead-letter-exchange": "migration.dlx",
        "x-max-length": 10000
      }
    },
    {
      "name": "migration.wq",
      "vhost": "/",
      "durable": false,
      "auto_delete": false,
      "arguments": {
        "x-dead-letter-exchange": "migration.rxo",
        "x-message-ttl": 15000
      }
    },
    {
      "name": "migration.dlq",
      "vhost": "/",
      "durable": false,
      "auto_delete": false,
      "arguments": {}
    },
    {
      "name": "migration.large.q",
      "vhost": "/",
      "durable": false,
      "auto_delete": false,
      "arguments": {
        "x-dead-letter-exchange": "migration.large.dlx",
        "x-max-length": 100000
      }
    },
    {
      "name": "migration.large.wq",
      "vhost": "/",
      "durable": false,
      "auto_delete": false,
      "arguments": {
        "x-dead-letter-exchange": "migration.large.rxo",
        "x-message-ttl": 15000
      }
    },
    {
      "name": "migration.large.dlq",
      "vhost": "/",
      "durable": false,
      "auto_delete": false,
      "arguments": {}
    }
  ],
  "bindings": [
    {
      "source": "migration.rxi",
      "vhost": "/",
      "destination": "migration.wq",
      "destination_type": "queue",
      "routing_key": "",
      "arguments": {}
    },
    {
      "source": "migration.rxo",
      "vhost": "/",
      "destination": "migration.q",
      "destination_type": "queue",
      "routing_key": "",
      "arguments": {}
    },
    {
      "source": "migration.dlx",
      "vhost": "/",
      "destination": "migration.dlq",
      "destination_type": "queue",
      "routing_key": "",
      "arguments": {}
    },
    {
      "source": "migration.large.rxi",
      "vhost": "/",
      "destination": "migration.large.wq",
      "destination_type": "queue",
      "routing_key": "",
      "arguments": {}
    },
    {
      "source": "migration.large.rxo",
      "vhost": "/",
      "destination": "migration.large.q",
      "destination_type": "queue",
      "routing_key": "",
      "arguments": {}
    },
    {
      "source": "migration.large.dlx",
      "vhost": "/",
      "destination": "migration.large.dlq",
      "destination_type": "queue",
      "routing_key": "",
      "arguments": {}
    }
  ]
}

I'm upgrading from Spring Boot 2.7 to Spring Boot 3.3

  • Publisher(another app) publishes to exchange migration.rxi to queue migration.wq to exchange migration.rxo to queue migration.q

Mine is spring integration app with libraries : spring-boot-starter-amqp , spring-integration-amqp spring-boot-starter-integration

The application is currently on single consumer.

Using SimpleMessageListenerContainer : AUTO Acknowledgement Mode

  • Consumes message from queue migration.q
  • Calls various endpoints
  • If an exception occurs, goes to error Channel
  • In error channel retry count is incremented and message is put on retry exchange migration.rxo which delivers it to main queue migration.q for re-processing.

When publisher sends to exchange migration.rxo it is quick(microseconds)

When My App sends to exchange (for retry)migration.rxo it takes 5-6 seconds in Spring Boot 2. It is now taking around 35 seconds delay in Spring Boot 3.

My rabbit mq configuration is here :

    {
  "users": [
    {
      "name": "admin",
      "password_hash": "xyz",
      "hashing_algorithm": "pqr",
      "tags": "administrator"
    },
    {
      "name": "user",
      "password_hash": "abc",
      "hashing_algorithm": "mno",
      "tags": ""
    }
  ],
  "vhosts": [
    {
      "name": "/"
    }
  ],
  "permissions": [
    {
      "user": "user",
      "vhost": "/",
      "configure": "",
      "write": ".*",
      "read": ".*"
    },
    {
      "user": "admin",
      "vhost": "/",
      "configure": ".*",
      "write": ".*",
      "read": ".*"
    }
  ],
  "exchanges": [
    {
      "name": "migration.rxi",
      "vhost": "/",
      "type": "direct",
      "durable": false,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    },
    {
      "name": "migration.rxo",
      "vhost": "/",
      "type": "direct",
      "durable": false,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    },
    {
      "name": "migration.dlx",
      "vhost": "/",
      "type": "direct",
      "durable": false,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    },
    {
      "name": "migration.large.rxi",
      "vhost": "/",
      "type": "direct",
      "durable": false,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    },
    {
      "name": "migration.large.rxo",
      "vhost": "/",
      "type": "direct",
      "durable": false,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    },
    {
      "name": "migration.large.dlx",
      "vhost": "/",
      "type": "direct",
      "durable": false,
      "auto_delete": false,
      "internal": false,
      "arguments": {}
    }
  ],
  "queues": [
    {
      "name": "migration.q",
      "vhost": "/",
      "durable": false,
      "auto_delete": false,
      "arguments": {
        "x-dead-letter-exchange": "migration.dlx",
        "x-max-length": 10000
      }
    },
    {
      "name": "migration.wq",
      "vhost": "/",
      "durable": false,
      "auto_delete": false,
      "arguments": {
        "x-dead-letter-exchange": "migration.rxo",
        "x-message-ttl": 15000
      }
    },
    {
      "name": "migration.dlq",
      "vhost": "/",
      "durable": false,
      "auto_delete": false,
      "arguments": {}
    },
    {
      "name": "migration.large.q",
      "vhost": "/",
      "durable": false,
      "auto_delete": false,
      "arguments": {
        "x-dead-letter-exchange": "migration.large.dlx",
        "x-max-length": 100000
      }
    },
    {
      "name": "migration.large.wq",
      "vhost": "/",
      "durable": false,
      "auto_delete": false,
      "arguments": {
        "x-dead-letter-exchange": "migration.large.rxo",
        "x-message-ttl": 15000
      }
    },
    {
      "name": "migration.large.dlq",
      "vhost": "/",
      "durable": false,
      "auto_delete": false,
      "arguments": {}
    }
  ],
  "bindings": [
    {
      "source": "migration.rxi",
      "vhost": "/",
      "destination": "migration.wq",
      "destination_type": "queue",
      "routing_key": "",
      "arguments": {}
    },
    {
      "source": "migration.rxo",
      "vhost": "/",
      "destination": "migration.q",
      "destination_type": "queue",
      "routing_key": "",
      "arguments": {}
    },
    {
      "source": "migration.dlx",
      "vhost": "/",
      "destination": "migration.dlq",
      "destination_type": "queue",
      "routing_key": "",
      "arguments": {}
    },
    {
      "source": "migration.large.rxi",
      "vhost": "/",
      "destination": "migration.large.wq",
      "destination_type": "queue",
      "routing_key": "",
      "arguments": {}
    },
    {
      "source": "migration.large.rxo",
      "vhost": "/",
      "destination": "migration.large.q",
      "destination_type": "queue",
      "routing_key": "",
      "arguments": {}
    },
    {
      "source": "migration.large.dlx",
      "vhost": "/",
      "destination": "migration.large.dlq",
      "destination_type": "queue",
      "routing_key": "",
      "arguments": {}
    }
  ]
}
Share Improve this question edited Mar 28 at 11:16 Harshit Bansal asked Mar 27 at 22:22 Harshit BansalHarshit Bansal 711 silver badge9 bronze badges 6
  • I sense it could be that consumer is blocked to receive message. Although the message is sent out of spring-integration flow .handle(Amqp.outboundGateway(rabbitTemplate).exchangeName("migration.rxo"), e -> e.requiresReply(false)); – Harshit Bansal Commented Mar 28 at 11:23
  • Please, share with us a simple project where we can reproduce. Plus instructions how to reproduce. – Artem Bilan Commented Mar 28 at 15:30
  • Sample project github/harshitbansal1992/DemoSpringIntegrationAmqp – Harshit Bansal Commented Mar 31 at 6:18
  • /springframework/integration/spring-integration-core/5.5.20/spring-integration-core-5.5.20.jar!//springframework/integration/gateway/MessagingGatewaySupport.class this.replyTimeout = 1000L; template.setSendTimeout(1000L); template.setReceiveTimeout(this.replyTimeout); I see this has now changed to 30000 in spring-integration 6 – Harshit Bansal Commented Mar 31 at 11:25
  • 1 The gateway is about request-reply. So, if another side does not produce a reply, I don't see a reason in using gateway. Sounds like you have found solution with an outbound channel adapter, which is just "send" service. Feel free to add an answer to your own question to help community to avoid similar problems in their projects. – Artem Bilan Commented Mar 31 at 15:14
 |  Show 1 more comment

1 Answer 1

Reset to default 0

I found out, for gateways the default timeout has changed from 1000ms to 30000ms.

Other then that, the solution that worked for me is changing from outbound gateway to outbound adapters.

Gateway is about request-responseand waits for response whereas adapters is just about send.

As per my requirements, adapters work well. So, I moved from outbound gateway to outbound adapter.

发布评论

评论列表(0)

  1. 暂无评论