Monday, February 8, 2010

Sending and Receiving Message using Spring, Oracle AQ and JMS

Project:Spring_OracleAQ
IDE: Eclipse
JARS:
aqapi.jar
commons-dbcp-1.2.2.jar
commons-logging-1.1.1.jar
javax.jms.jar
jta.jar
ojdbc14.jar
spring.jar (2.5.6)

XML Configuration

<bean id="aqConnectionFactoryInitialiser" class="com.somellc.spring_oracleaq.OracleAqConnectionFactoryInitialiser"/>
<bean id="aqConnectionFactory" factory-bean="aqConnectionFactoryInitialiser" factory-method="createConnectionFactory" /><bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"></bean>
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"></bean>
<bean id="testMqMessageListener" class="com.somellc.spring_oracleaq.TestMqMessageListener"/><bean id="messageListener1" class="org.springframework.jms.listener.adapter.MessageListenerAdapter"> <property name="delegate" ref="testMqMessageListener"/> <property name="defaultListenerMethod" value="processRequest"/></bean>


Client.java:
ApplicationContext context = new ClassPathXmlApplicationContext(filename);
JmsTemplate jmsTemplate = (JmsTemplate) context.getBean("jmsTemplate");
jmsTemplate.convertAndSend(msg);

OracleAqConnectionFactoryInitialiser.java:
oracle.jms.AQjmsFactory.getQueueConnectionFactory

OracleAqDestinationFactoryBean.java:
(AQjmsSession) connectionFactory.createQueueConnection

TestMqMessageListener.java:
Has method processRequest (String message)

2 comments:

  1. Am unable to see the code of the classes? Is there something wrong?

    ReplyDelete
  2. It very good, it will be nice if you can share the complete code base for this example.

    ReplyDelete