I am trying to connect to Oracle AQ using JMS template to publish and subscribe. However, I am unable to get it working. I might be lacking basic understanding of connecting to Oracle AQ in general. Any advice would be appreciated
Following is my code
import java.sql.SQLException;
import javax.jms.QueueConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.support.converter.MappingJackson2MessageConverter;
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.jms.support.converter.MessageType;
import oracle.jdbc.pool.OracleDataSource;
import oracle.jms.AQjmsFactory;
@EnableJms
public class DataSourceConfig {
@Value("${spring.datasource.username}")
String username;
@Value("${spring.datasource.password}")
String password;
@Value("${spring.datasource.url}")
String url;
@Bean
private OracleDataSource dataSource() throws SQLException {
OracleDataSource dataSource = new OracleDataSource();
dataSource.setUser(username);
dataSource.setPassword(password);
dataSource.setURL(url);
dataSource.setImplicitCachingEnabled(true);
dataSource.setFastConnectionFailoverEnabled(true);
return dataSource;
}
@Bean
public QueueConnectionFactory connectionFactory() throws Exception {
return AQjmsFactory.getQueueConnectionFactory(dataSource());
}
@Bean
public JmsTemplate jmsTemplate() throws Exception {
JmsTemplate jmsTemplate = new JmsTemplate();
jmsTemplate.setConnectionFactory(connectionFactory());
return jmsTemplate;
}
}
Driver class
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Primary;
import org.springframework.jms.core.JmsTemplate;
@SpringBootApplication
public class AQProcessorApplication implements CommandLineRunner {
@Autowired
@Qualifier("jmsTemplate")
JmsTemplate template;
public static void main(String[] args) {
SpringApplication.run(AQProcessorApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
template.convertAndSend("QUEUE_NAME", "test");
System.out.println("------------- MESSAGE SENT--------------------------");
}
I get MESSAGE SENT in console but I do not see anything in Oracle DB