Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-16707

camel-rabbitmq connection leak on error during 'declare'

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6.0
    • Fix Version/s: 3.7.5, 3.11.0
    • Component/s: camel-rabbitmq
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      camel-rabbitmq component causes a connection leak when there is an error during declaration of exchanges/queues (e.g. when an exchange with the same name but different type already exists).

      Problem lies in org.apache.camel.component.rabbitmq.RabbitConsumer:

      
          RabbitConsumer(RabbitMQConsumer consumer) {
              // super(channel);
              this.consumer = consumer;
              try {
                  Connection conn = consumer.getConnection();
                  this.channel = openChannel(conn);
              } catch (IOException | TimeoutException e) {
                  LOG.warn("Unable to open channel for RabbitMQConsumer. Continuing and will try again", e);
              }
          }
      
          //...
      
          private Channel openChannel(Connection conn) throws IOException {
              Channel channel = //... channel gets created
              //...
              if (consumer.getEndpoint().isDeclare()) {
                  consumer.getEndpoint().declareExchangeAndQueue(channel);
              }
              return channel;
          }
      

      if declareExchangeAndQueue gets called, and if it throws an exception (e.g. because the exchange is already declared with different configuration) the exception is caught and consumed in the constructor, and the channel is never closed. I think the exception should be propagated in this case, because it is not recoverable (or at least there should be an option for this). It would also cause the app startup to fail, which would be a good thing in this case.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rastislav.papp Rastislav Papp
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: