Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

SimpleMessageListenerContainerFactory doesn't propagate queueMessageHandler field when SimpleMessageListenerContainer bean is created via createSimpleMessageListenerContainer #795

Open
setu9760 opened this issue Nov 2, 2021 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged type: bug A general bug

Comments

@setu9760
Copy link

setu9760 commented Nov 2, 2021

Type: Bug

Component:
SQS messaging

Describe the bug
SimpleMessageListenerContainerFactory has queueMessageHandler field and has setter for this. However when public method createSimpleMessageListenerContainer is called to create the actual bean SimpleMessageListenerContainer this field is not propagated. Ideally for the factory bean we would want all the relevant properties/fields propagated to the underlying bean without having to manually inject it twice in factory and then the underlying bean.

Sample

@Bean
@Primary
public SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory(
    QueueMessageHandler queueMessageHandler, AmazonSQSAsync amazonSqs) {
  var factory = new SimpleMessageListenerContainerFactory();
  factory.setQueueMessageHandler(queueMessageHandler);
  factory.setAmazonSqs(amazonSqs);
  factory.setAutoStartup(true);
  factory.setMaxNumberOfMessages(1);
  return factory;
}

@Bean
@Primary
public SimpleMessageListenerContainer simpleMessageListenerContainer(
    SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory,
    QueueMessageHandler queueMessageHandler) {
  var simpleMessageListenerContainer= simpleMessageListenerContainerFactory.createSimpleMessageListenerContainer();
  simpleMessageListenerContainer.setMessageHandler(queueMessageHandler);
  return simpleMessageListenerContainer;
}

in the above code the simpleMessageListenerContainer.setMessageHandler(queueMessageHandler); line shouldn't be required and the call simpleMessageListenerContainerFactory.createSimpleMessageListenerContainer() should ensure all fields from factory are injected into the bean.

@github-actions github-actions bot added type: bug A general bug status: waiting-for-triage An issue we've not yet triaged labels Nov 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: waiting-for-triage An issue we've not yet triaged type: bug A general bug
Development

No branches or pull requests

1 participant