DefaultJmsListenerContainerFactory vs DefaultMessageListenerContainer

荒凉一梦 提交于 2019-12-04 08:32:41

The factory was introduced to support the creation of listener containers for @JmsListener annotated POJO methods.

If you are not using that mechanism, you can continue to define your DLMC directly.

EDIT

When using @JmsListener, the containers are not registered as beans themselves, but are available using the registry bean; you can get a reference to the container so you can start/stop etc.

See the javadocs for the JmsListenerEndpointRegistry for how to get references to the containers either individually by id, or all.

EDIT2

I am not sure what you mean in comment 3; the registry has all containers, regardless of which container factory was used to create the container...

@JmsListener(id="foo", destination="foo", containerFactory="one")
public void listen1(String payload) {
    System.out.println(payload + "foo");
}

@JmsListener(id="bar", destination="bar", containerFactory="two")
public void listen2(String payload) {
    System.out.println(payload + "bar");
}

If you are using configureListenerContainers() to programmatically create endpoints, you have to provide them with containers not container factories.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!