I have some troubles with sending message to Artemis MQ in Spring Boot:
Uncategorized exception occurred during JMS processing; nested exception is ActiveMQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=AMQ219013: Timed out waiting to receive cluster topology. Group:null]
I use docker container for Artemis (docker image: apache/activemq-artemis:latest-alpine). I wasn’t configure it and open 5672 port.
If I try to send message by JMS template I got this error.
My beans (on Kotlin):
@EnableJms
@Configuration
class JmsConfig {
@Bean
fun jmsTemplate(connectionFactory: ConnectionFactory): JmsTemplate {
val jmsTemplate = JmsTemplate(connectionFactory)
jmsTemplate.messageConverter = messageConverter()
return jmsTemplate
}
@Bean
fun messageConverter(): MessageConverter {
val converter = MappingJackson2MessageConverter()
converter.setTargetType(MessageType.TEXT)
converter.setTypeIdPropertyName("_type")
return converter
}
}
@Configuration
class ActiveMQConfig {
@Bean
fun connectionFactory(): ConnectionFactory {
return ActiveMQConnectionFactory("tcp://localhost:5672?protocols=STOMP,AMQP,MQTT", "artemis", "artemis")
}
}
The place where I send message
@Service
class EmailGateway (
private val template: JmsTemplate,
) {
fun sendEmail(to: String, letter: Letter) {
template.convertAndSend("test-queue", EmailInfo(to, letter))
}
}
EmailInfo is a business logic class, just class with fields.
My depedendencies
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-quartz")
implementation("org.springframework.boot:spring-boot-starter-artemis")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0")
implementation("io.jsonwebtoken:jjwt:0.12.5")
implementation("javax.jms:javax.jms-api:2.0.1")
implementation("org.apache.activemq:artemis-jakarta-client:2.33.0")
implementation("org.apache.activemq:artemis-jakarta-server:2.33.0")
implementation("org.apache.activemq:artemis-jms-server:2.33.0")
implementation("org.apache.activemq:artemis-jms-client:2.33.0")
implementation("org.springframework.boot:spring-boot-starter-mail")
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
If I turn off Artemis error will be changed to “Uncategorized exception occurred during JMS processing; nested exception is ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ219007: Cannot connect to server(s). Tried with all available servers.]”
I think I need to configure my Artemis but I didn’t find some extra settings in my case.
Spring Boot guidelines tell what I just need to use JMS template.
Korlivar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.