Hello,

We would like to use an embedded Artemis broker, but when we define a bean of type ConnectionFactory the embedded broker is not started. I believe this is due to the fact that there is a @ConditionalOnMissingBean(ConnectionFactory) annotation on the ArtemisAutoConfiguration class itself.

Thanks in advance.

Comment From: snicoll

It is yes. Why are you doing this?

Comment From: shalastra

Thanks for the quick response. We use multiple connection factories in our app, and we run with an embedded broker for testing. We are trying to switch from activemq to artemis and we just came accross this (it worked fine previously).

Comment From: snicoll

it worked fine previously

That's not really comparable since ActiveMQ embeds the broker automatically via the datasource URL. You just don't have that feature with Artemis anymore (as far as I know). If you define your own DataSource spring boot will back off. What you did previously was just using ActiveMQ feature, not Spring Boot.

Comment From: snicoll

Maybe we could have something similar to what we do regarding the database in tests? (forcing the use of an embedded broker).

Comment From: shalastra

Yes, you're right, thanks for pointing that out.

Correct me if I'm wrong, but something like multiple JmsTemplates using a single DataSource doesn't make much sense. But I think that multiple ConnectionFactory instances with a single embedded broker does make sense (at least for us).

Wouldn't it be enough to move the @ConditionalOnMissingBean(ConnectionFactory) off the ArtemisAutoConfig, allowing multiple connection factories for an embedded broker?

Comment From: snicoll

multiple ConnectionFactory instances with a single embedded broker does make sense

It does not to me but that doesn't mean I think it is wrong. I am not keen on moving any condition there: we start the embedded broker because we know "we have something to do". You don't want the embedded broker to start behind your back, do you? Especially if you have ConnectionFactory of your own in your configuration... potentially on a different broker. The current logic to figure out if we have something to do is quite clear to understand and I like the fact the whole thing backs off as soon as you have an opinion. We could split it in its own auto-configuration but then we wouldn't be able to keep the same nice logic. I could make that class public but it has conditions that are not meant to be used on a regular config class.

In such a scenrio, I recommend that you configure the embedded broker yourself since you have your own JMS configuration anyway.

Comment From: loetscher

Maybe we could have something similar to what we do regarding the database in tests? (forcing the use of an embedded broker).

That was exactly our use case: we have in production several connections to different brokers, but want to use a single embedded one for "integration" tests. Sample configuration with multiple connection factories is provoided in https://github.com/loetscher/springbootembeddedartemisserver Btw. if the embedded container is only in tests needed: move the configuration to the src/test/... folder.

Providing a class "AutoConfigureTestArtemis" (like the database solution you mentioned above) would really simplify the configuration.