Thursday, May 19, 2011

Weblogic 11g - MDB accessing secure JMS Queue

Now that we have a secure queue (from the prevous post), let's leverage that from an MDB.

The MDB will simply consume the messages - the only logic our onMessage() requires is -

public void onMessage(Message message) {


if (message instanceof TextMessage) {
TextMessage txtMsg = (TextMessage) message;
System.out.println("**** Message: " + txtMsg.getText());

catch(Exception e){

Step 1. - Create a new project in JDeveloper

Step 2. - Create a new MDB in the project
-- File --> New --> EJB --> Message Driven Bean --> 2.1

Step 3 - Set up security
-- run-as identity is specified in the ejb-jar.xml
-- security-role is specified in the ejb-jar.xml

-- Map run-as identity to principal-name in weblogic-ejb-jar.xml

Step 3.1 - ejb-jar.xml

-- These properties can be set via the properties palette (Right mouse click on the bean and select Properties)

Step 3.2. weblogic-ejb-jar.xml

-- These properties can also be set via the palette

Step 4. Deploy

Step 5. Test

-- Check WLS log for the output message

-- Change principal-name in weblogic-ejb-jar.xml to weblogic

-- Re-test

No comments: