Код: Выделить всё
Uncategorized exception occurred during JMS processing; nested exception is ActiveMQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=AMQ219013: Timed out waiting to receive cluster topology. Group:null]
Если я попытаюсь отправить сообщение по шаблону JMS, я получу эту ошибку.
Мои bean-компоненты (на 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")
}
}
Код: Выделить всё
@Service
class EmailGateway (
private val template: JmsTemplate,
) {
fun sendEmail(to: String, letter: Letter) {
template.convertAndSend("test-queue", EmailInfo(to, letter))
}
}
Мои зависимости
Код: Выделить всё
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")
}
Код: Выделить всё
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.]
В рекомендациях Spring Boot указано, что мне просто нужно использовать для использования шаблона JMS. .
P.S. во встроенной конфигурации все работает корректно
Подробнее здесь: https://stackoverflow.com/questions/784 ... pring-boot