Tuesday, January 17, 2012

How to pass JNDI name dynamically to an Adapter

Recently, I've been trying configure an MQ adapter that could enqueue data of any structure into specified queue based on the specified JNDI, all passed dynamically at runtime. This post decsribes how you can pass the JNDI Name dynamically to an Adapter.

All you have to do is define a
String variable (say myJndiName) that stores your JNDI name (eis/MQ/someThing...already configured on Weblogic) and pass this variable into Invoke Activity properties directly in the .bpel source.   

Note that you'll not be able to find this property in the
Invoke Activity > Properties tab.


And that's it. You can assign different values on the fly to the variable myJndiName and same adapter can enqueue in different JNDI locations. It also works for FTP and JMS adapters too. 

6 comments:

  1. Hey Neeraj,

    This was a breather for us.
    You have provided a very useful information. We were successfully able to dynamically select a JNDI and also dynamically select a queue and post a message to the same.

    Thanks a lot!

    Regards,
    Pavan

    ReplyDelete
    Replies
    1. Hi Pavan,
      Were you able to pass Queue name also dynamically?

      Thanks,

      Delete
  2. Hi Neeraj,

    thx for useful post,actually I follow the http://shrikworld.blogspot.in/2011/04/change-db-jndi-dynamically-in-soa-11g.html and I use BPEL 2.0 so I set the property as you mention but when I try to change the JNDI in Attribute Properties as mentioned in the above link,it it is not changed and I get the old jndi only,Plz tell where I missed.

    Regards
    Mani

    ReplyDelete
  3. Hello Neeraj

    Your example for setting dynamically a JDNI in dbAdapter is great and pointed us in the right direction.
    But we have a veri different problem now with dbDapter. We need to set all the connection parameters at runtime (ConnectionURL,password,username) for the dbAdapter. Is that possible with dbAdapter or maybe we should try a different approach or technology.

    Regards
    Sergio

    ReplyDelete
    Replies
    1. Hi Sergio,

      I'd suggest creating all the DB connections in the WLS with different JNDIs and then pass the JNDI as input parameter for the desired connection.

      Regards,
      Neeraj Sehgal

      Delete
  4. Neeraj,
    This was really helpful,I used this property for my AQ Adapter JNDI.Is there any way to send the queue name dynamically for AQ.I saw your post for MQ,but I am not fincing similar property for AQ Adapter.

    Thanks,

    ReplyDelete