1
package com.tasks.cache.config
3
import org.springframework.context.annotation.Configuration
4
import org.springframework.jms.config.DefaultJmsListenerContainerFactory
5
import org.springframework.jms.core.JmsTemplate
6
import org.apache.activemq.ActiveMQConnectionFactory
7
import org.springframework.beans.factory.annotation.Value
8
import org.springframework.context.annotation.Bean
13
@Value("#{environment['amq.url']}")
14
lateinit var brokerUrl:String
15
@Value("#{environment['amq.username']}")
16
lateinit var brokerUserName:String
18
@Value("#{environment['amq.password']}")
19
lateinit var brokerPassword:String
22
fun connectionFactory(): ActiveMQConnectionFactory {
23
val connectionFactory = ActiveMQConnectionFactory()
24
connectionFactory.brokerURL = brokerUrl
25
connectionFactory.password = brokerUserName
26
connectionFactory.userName = brokerPassword
27
return connectionFactory
31
fun jmsTemplate(): JmsTemplate {
32
val template = JmsTemplate()
33
template.connectionFactory = connectionFactory()
38
fun jmsListenerContainerFactory(): DefaultJmsListenerContainerFactory {
39
val factory = DefaultJmsListenerContainerFactory()
40
factory.setConnectionFactory(connectionFactory())
41
factory.setConcurrency("1-1")