Reputation: 949
I am new to Spring JMS. My application is developed using Spring Boot and is deployed in JBoss EAP 7.2.0. I have a remote queue which is an ActiveMQ Artemis queue which is also embedded within JBoss EAP 7.2.0. Can anyone please suggest me how to send a message to the remote JMS queue using JmsTemplate
of Spring Boot? Basically I am not getting how should I define the remote ConnectionFactory
to connect to the remote queue.
Upvotes: 3
Views: 6854
Reputation: 8203
spring.jms.jndi-name=java:/<your connection factory name for artemis>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-artemis</artifactId>
</dependency>
@Component
public class MyMessageSender {
@Autowired
JmsTemplate jmsTemplate;
public void send(String msg){
jmsTemplate.convertAndSend("my.queue.name", msg);
}
}
@Bean // Serialize message content to json using TextMessage
public MessageConverter jacksonJmsMessageConverter() {
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setTargetType(MessageType.TEXT);
converter.setTypeIdPropertyName("_type");
return converter;
}
Upvotes: 2