Git Product home page Git Product logo

Comments (6)

garyrussell avatar garyrussell commented on April 19, 2024

We could add autoStartup to the @RabbitListener itself, if set it would override the default.

BTW, for your workaround, if you want the other boot properties applied to your container factory, you should pass it to the configurer as is done in the boot autoconfig.

	@Bean
	@ConditionalOnMissingBean(name = "rabbitListenerContainerFactory")
	public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(
			SimpleRabbitListenerContainerFactoryConfigurer configurer,
			ConnectionFactory connectionFactory) {
		SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
		configurer.configure(factory, connectionFactory);
		return factory;
	}

You really don't need a subclass, just set the factory's autoStartup to false after the configurer has done its work.

from spring-amqp.

garyrussell avatar garyrussell commented on April 19, 2024

AMQP-774.

from spring-amqp.

artembilan avatar artembilan commented on April 19, 2024

Does this work for you

/**
	 * If provided, the listener container for this listener will be added to a bean
	 * with this value as its name, of type {@code Collection<MessageListenerContainer>}.
	 * This allows, for example, iteration over the collection to start/stop a subset
	 * of containers.
	 * @return the bean name for the group.
	 * @since 1.5
	 */
	String group() default "";

?

from spring-amqp.

dustinschultz avatar dustinschultz commented on April 19, 2024

@artembilan I definitely looked at the group feature but unfortunately had no luck.

The listener is already started by the time I get access to the Collection<MessageListenerContainer> and if there's items already in the queue, I run the risk of them being consumed before I can call stop().

I tried getting access to the Collection<MessageListenerContainer> earlier in the process via the ContextRefreshed event but that hook is called after a context refresh. Ideally ... something like a BeforeContextRefresh event would work but I couldn't find one.

from spring-amqp.

artembilan avatar artembilan commented on April 19, 2024

Let's try this!

@Autowired
@Qualifier("myGroup")
Collection<AbstractMessageListenerContainer> containers;

@PostConstruct
public void setup() {
     this.containers.forEach(c -> c.setAutoStartup(false));
}

from spring-amqp.

dustinschultz avatar dustinschultz commented on April 19, 2024

Awesome! Thanks for the help guys and thanks for the awesome framework.

from spring-amqp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.