marschall / jakarta-jms-adapter

adapts a javax.jms JMS provider to a jakarta.jms JMS provider
6 stars 3 forks source link

Suggestion: Make wrapped objects public #3

Closed victorgawk closed 6 months ago

victorgawk commented 7 months ago

Hi. thank you for making this adapter. It's being useful to me.

I would like to ask if it's possible to make JakartaQueue class and its constructor public?

I am using a Weblogic JMS server and use a context lookup to get a javax.jms.Queue instance through JNDI but I can't use JakartaQueue class to wrap into jakarta.jms.Queue because it's package protected.

marschall commented 6 months ago

I released 1.3.0 to Maven Central. Let me know if this works for you.

marschall commented 6 months ago

I don't know enough about WebLogic, I don't assume there is a way to hook into JNDI and register your own objects, eg through ObjectFactory?

victorgawk commented 6 months ago

The queue instance from Weblogic JMS server is obtained through a JNDI lookup. For instance:

import java.util.Hashtable;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.github.marschall.jakartajmsadapter.JakartaQueue;
import jakarta.jms.Queue;

public class JndiLookupExample {

  public static void main(String[] args) throws NamingException {
    // creates a hashtable with the Weblogic server parameters
    Hashtable<String, String> env = new Hashtable<>();
    env.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
    env.put("java.naming.provider.url", "t3://host:port");

    // creates the initial context for the JNDI lookup
    InitialContext ctx = new InitialContext(env);

    // obtain a JMS Queue by JNDI lookup
    Queue queue = new JakartaQueue((javax.jms.Queue) ctx.lookup("queue JNDI here"));
  }

}