09.12.2012 Views

Advanced Queuing - Oracle

Advanced Queuing - Oracle

Advanced Queuing - Oracle

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

General Features of JMS<br />

Using JNDI to Look Up Destination Objects<br />

As described in "Connection Factory" on page 12-5, the database can be configured<br />

to register schema objects with an LDAP server. If a database has been configured to<br />

use LDAP and the GLOBAL_TOPIC_ENABLED parameter has been set to TRUE,<br />

then all JMS queues and topics are automatically registered with the LDAP server<br />

when they are created.<br />

The administrator can also create aliases to the queues and topics registered in<br />

LDAP using the DBMS_AQAQDM.add_alias_to_ldap PL/SQL procedure.<br />

Queues and topics that are registered in LDAP can be looked up through JNDI<br />

using the queue/topic name or one of their aliases.<br />

Example Code<br />

Lets say we have a new orders queue OE.OE_neworders_que stored in LDAP, it<br />

can be looked up as follows:<br />

public static void get_Factory_from_LDAP() throws Exception<br />

{<br />

Hashtable env = new Hashtable(5, 0.75f);<br />

env.put(Context.INITIAL_CONTEXT_FACTORY, AQjmsConstants.INIT_CTX_FACTORY);<br />

}<br />

// aqldapserv is your LDAP host and 389 is your port<br />

env.put(Context.PROVIDER_URL, "ldap://aqldapserv:389);<br />

// now authentication info<br />

// username/password scheme, user is OE, password is OE<br />

env.put(Context.SECURITY_AUTHENTICATION, "simple");<br />

env.put(Context.SECURITY_PRINCIPAL, "cn=oe,cn=users,cn=acme,cn=com");<br />

env.put(Context.SECURITY_CREDENTIALS, "oe");<br />

DirContext inictx = new InitialDirContext(env);<br />

// initialize context with the distinguished name of the database server<br />

inictx=(DirContext)inictx.lookup("cn=db1,cn=<strong>Oracle</strong>Context,cn=acme,cn=com");<br />

// go to the destination holder<br />

DirContext destctx = (DirContext)inictx.lookup("cn=<strong>Oracle</strong>DBQueues");<br />

// get the destination OE.OE_new_orders queue<br />

Queue myqueue = (Queue)destctx.lookup("cn=OE.OE_new_orders_que");<br />

Methods on the Destination Object include:<br />

12-14 <strong>Oracle</strong>9i Application Developer’s Guide - <strong>Advanced</strong> <strong>Queuing</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!