I am using ActiveMQ Artemis 2.13.0.redhat-00006 for messaging. I've deployed the ActiveMQ Artemis JCA RA in Weblogic.
I am facing the requirement to prioritize messages to be executed from Weblogic. I would like to utilize work manager concept provided by Weblogic. I have created 2 domain scoped work managers in Weblogic:
WorkManagerHighPriority
WorkManagerLowPriority
I am trying to patch ActiveMQ, so that it utilizes my custom work manager(e.g. WorkManagerLowPriority
), instead of the default work manager. I found this method in ActiveMQResourceAdapter
:
public WorkManager getWorkManager() {
if (logger.isTraceEnabled()) {
logger.trace("getWorkManager()");
}
if (ctx == null) {
return null;
}
return ctx.getWorkManager();
}
In my naive thinking I modified this method to:
public WorkManager getWorkManager() {
if (logger.isTraceEnabled()) {
logger.trace("getWorkManager()");
}
InitialContext ic = null;
WorkManager wm = null;
try {
Hashtable env = new Hashtable();
// WebLogic Server 10.x/12.x connection details
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://localhost:28010");
ic = new InitialContext(env);
wm = (WorkManager) ic.lookup("java:comp/env/wm/WorkManagerLowPriority");
if (wm == null) {
throw new RuntimeException();
}
} catch (NamingException e) {
e.printStackTrace();
}
return wm;
}
Everything was working fine. However, after deploying this patch I get these errors:
"message": "Not an ActiveMQ Artemis Destination:ActiveMQQueue[online.eingabe.MyQueue]",
"name": "javax.jms.InvalidDestinationException",
"extendedStackTrace": "javax.jms.InvalidDestinationException: Not an ActiveMQ Artemis Destination:ActiveMQQueue
Additionally, I continuously get this warning:
"extendedStackTrace":"java.lang.NoClassDefFoundError: io/netty/util/collection/IntObjectHashMap$2
at io.netty.util.collection.IntObjectHashMap.values(IntObjectHashMap.java:221)
Questions:
ActiveMQResourceAdapter.getWorkManager()
in order to achieve my goal?I don't think this approach is ultimately viable. If you're just trying to hack something together as a proof of concept in the development phase then maybe this makes sense, but deploying a custom patched version of the ActiveMQ Artemis JCA resource adapter to one or more production systems for an enterprise-grade solution is almost certainly going to cause head-aches later.
It's important to note that the ctx
variable used by the ActiveMQ Artemis JCA RA here is a javax.resource.spi.BootstrapContext
which is provided by the container (i.e. Weblogic) to the RA when it starts. The RA uses this BootstrapContext
to get the work manager from the container. So, ultimately the container is providing the work manager implementation to the RA. If you want to use a different work manager then this is where the change needs to happen.
I know very little about Weblogic, but I imagine it has a way to configure the actual work manager implementation that is used here. I recommend you investigate what configuration options that Weblogic provides. It wouldn't make a lot of sense for a container to allow multiple work managers without also providing a way to supply those to the various Java EE applications that need them.