Тайм-аут подключения ActiveMQ Artemis в Spring BootJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Тайм-аут подключения ActiveMQ Artemis в Spring Boot

Сообщение Anonymous »

У меня возникли проблемы с отправкой сообщения в ActiveMQ Artemis в 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]
Я использую Docker-контейнер apache/activemq-artemis:latest-alpine. Я не настроил его и не открыл порт 5672.
Если я попытаюсь отправить сообщение по шаблону 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))
}
}
EmailInfo — это класс бизнес-логики, просто класс с полями.
Мои зависимости

Код: Выделить всё

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")
}
Если я отключу ActiveMQ Artemis, ошибка изменится на:

Код: Выделить всё

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.]
Я думаю, мне нужно настроить ActiveMQ Artemis, но в моем случае я не нашел дополнительных настроек.
В рекомендациях Spring Boot указано, что мне просто нужно использовать для использования шаблона JMS. .
P.S. во встроенной конфигурации все работает корректно

Подробнее здесь: https://stackoverflow.com/questions/784 ... pring-boot
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»