-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
messaging/src/main/java/edu/tamu/weaver/messaging/config/MessagingConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package edu.tamu.weaver.messaging.config; | ||
|
||
import org.apache.activemq.ActiveMQConnectionFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.jms.config.DefaultJmsListenerContainerFactory; | ||
import org.springframework.jms.config.JmsListenerContainerFactory; | ||
import org.springframework.jms.connection.CachingConnectionFactory; | ||
import org.springframework.jms.core.JmsTemplate; | ||
|
||
@Configuration | ||
public class MessagingConfig { | ||
|
||
@Value("${spring.activemq.broker-url}") | ||
private String brokerUrl; | ||
|
||
@Bean | ||
public CachingConnectionFactory cachingConnectionFactory() { | ||
return new CachingConnectionFactory(defaultActiveMQConnectionFactory()); | ||
} | ||
|
||
@Bean | ||
public JmsTemplate jmsTopicTemplate() { | ||
JmsTemplate jmsTemplate = new JmsTemplate(cachingConnectionFactory()); | ||
jmsTemplate.setPubSubDomain(true); | ||
return jmsTemplate; | ||
} | ||
|
||
public ActiveMQConnectionFactory defaultActiveMQConnectionFactory() { | ||
ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(); | ||
activeMQConnectionFactory.setBrokerURL(brokerUrl); | ||
return activeMQConnectionFactory; | ||
} | ||
|
||
@Bean | ||
public JmsListenerContainerFactory<?> topicContainerFactory() { | ||
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); | ||
factory.setConnectionFactory(defaultActiveMQConnectionFactory()); | ||
factory.setPubSubDomain(true); | ||
return factory; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters