Thursday, March 25, 2010

Enqueue JMS message to Oracle AQ Queue from standalone Java Client

I am currently exploring Oracle SOA 11g and faced a bit of trouble with publishing a JMS message to an AQ queue from a standalone Java client. Many might think whats the big deal in it......!! Well, not a big deal for sure but given that 11g or Weblogic server 10.3 to be precise now deals with Foreign Server configurations (mind you, something different from the normal JMS servers we are so used to) it is a bit confusing for to start with.

The oracle docs will provide the config detail
s through which it is easy to connect to a JMS adapter from BPEL using the adapter's outbound connection pool JNDI and Queue JNDI as inputs. But I wanted to connect to an AQ from a Java client using the QueueConnectionFactory and Queue JNDI, both configured as a part of the Foreign Server. The docs mention that to connect to an AQ Queue, change the Foreign Server initial context to the Aqjms context and proceed with providing the JNDI property key and value for the datasource.
Even though the mentioned configuration will help you connect to a Queue through JMS adapter from BPEL, it will not help you connect the same Queue through a standalone client using server context. To achieve the same, you must add the db_url and java.naming.security.principal as the keys and the jdbc connection url and the
DB user as the values respectively as mentioned in the link http://download.oracle.com/docs/cd/E12839_01/web.1111/e13738/aq_jms.htm#JMSAD565 under the topic "Stand-alone WebLogic AQ JMS Clients" and "Configure a Foreign Server using a Database's JDBC URL".
To elaborate the same, earlier my jms config.xml had a ForeignServer configuration as below:

<foreign-server name="11GEvalForeignServer">
.
.
.
<initial-context-factory> oracle.jms.AQjmsInitialContextFactory</initial-context-factory>
<jndi-properties-credential-encrypted>{AES}TqzwTRUIKdpaT/wgp5OiNU85BlmhrEJiu/z/p3EofWo=</jndi-properties-credential-encrypted>
<jndi-property>

<key>datasource</key>
<value>jdbc/11GEvalJMSUserDataSource</value>
</jndi-property>
</foreign-server>

...but later I added the jdbc url and user to it as follows :
<jndi-property>
<key>java.naming.security.principal<key>
<value>jmsuser</value>
</jndi-property>
<jndi-property>
<key>db_url<key>

<value>jdbc:oracle:thin:@10.209.125.21:1521/ORCL1</value>
</jndi-property>

and Voila! the standalone client just worked !! In short, it is the limitation of the standalone client support as mentioned in the same link mentioned above, section "Limitations when using Stand-alone WebLogic AQ JMS Clients", point 3.

Here is my Java code that connects to the Queue.


3 comments:

  1. Hi Aparajeetha, nice collection. And im new to this jms server and Aq.Can u pls help me how to send the jms topic messages to oracle AQ.

    ReplyDelete
    Replies
    1. Hi Johny. Am glad my blog interests you.
      Am afraid, I didn't quite get your question. Here, I am sending a javax.jms.Message to an AQ Queue. What exactly do you mean by a 'jms topic message'. Message cannot be specific to a Queue or a Topic if thats what u mean?

      Delete
  2. Hi Aparajeeta,
    I followed the steps mentioned above and now after restart my jms config file looks ok with db_url and java.naming.security.principal added, but still while executing my java class sendQueue , receiveQueue I am getting the same error as earlier :
    Exception in thread "main" javax.naming.NamingException: The configuration of the AQjmsInitialContext is not complete. The configuration must contain datasource or (db_url,java.naming.security.principal,java.naming.security.credentials) or both

    Please guide me where I am going wrong.
    Waiting for quick reply.
    Thanks in advance.

    ReplyDelete