spring-projects / spring-projects/spring-boot

RabbitAutoConfiguration does not have properties for channel transacted

Open
#11,821 6 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

Spring Boot version: 1.5.9.RELEASE

Spring Boot autoconfiguration for RabbitMQ does not have properties to make the channels of the underlying RabbitTemplate transactional. A workaround is needed to enable it anyway. We did this by implementing a custom BeanPostProcessor

private static class RabbitTransactedBeanPostProcessor implements BeanPostProcessor {

    /**
     * Make RabitTemplate channel transacted because RabbitAutoConfiguration does not allow to set this
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
      if (bean instanceof RabbitTemplate) {
        RabbitTemplate rabbitTemplate = (RabbitTemplate) bean;
        rabbitTemplate.setChannelTransacted(true);
      }

      return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
      return bean;
    }
  }

It is of course also possible to override the RabbitTemplate bean definition, but this would require duplication of the property handling logic. Could you add support for making the Rabbit channel transacted in RabbitAutoConfiguration and RabbitProperties?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with RabbitAutoConfiguration and RabbitProperties to trace how RabbitMQ settings reach the auto-configured RabbitTemplate. Add support for configuring transactional channels through those components, then verify that the resulting RabbitTemplate honors the setting and that existing property handling remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, rabbitmq, spring-boot
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.