Message Driven Beans & Oracle AQ
Posted: 08/09/2011 Filed under: Advanced Queuing, EE, Oracle, Weblogic | Tags: AQ, Database, Java EE, JMS, MDB, Oracle, Weblogic Leave a comment »I’ve followed the chapter “Interoperating with Oracle AQ JMS” in order to integrate Oracle Streams Advanced Queuing (AQ) with Weblogic. All is working properly now, but I’ve had some problems programming a Message Driven Bean (MDB) which consumes messages enqueued by a PL/SQL procedure, so I would like to specify the minimum configuration properties you need to deploy this type of bean, apart from the queue name, of course.
The first one is the destination type for the MDB destination, which should be configured to either: javax.jms.Queue or javax.jms.Topic, and the second one is the connection factory JNDI name that you’ve configured on Weblogic. Here you have a basic example:
@MessageDriven(mappedName = "aqjms/TestTopicQ",
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Topic")})
@MessageDestinationConfiguration(connectionFactoryJNDIName = "aqjms/TestTopicCF")
public class TestMDB implements MessageListener {
static final Logger logger = LoggingHelper.getServerLogger();
public void onMessage(Message message) {
TextMessage msg = null;
try {
if (message instanceof TextMessage) {
msg = (TextMessage) message;
logger.info("MESSAGE BEAN: Message received: " + msg.getText());
} else {
logger.warning("Message of wrong type: " +
message.getClass().getName());
}
} catch (JMSException e) {
logger.severe("TestMDB.onMessage: JMSException: " + e.toString());
e.printStackTrace();
} catch (Throwable te) {
logger.severe("TestMDB.onMessage: Exception: " + te.toString());
te.printStackTrace();
}
}
}
References
