Wilfly10 apache artemis - JMS implementation - jms

In Jboss 5.x, JMS model- queue (Point to point) used to be implemented as follows (MDB class and ejb-jar.xml)
MDB
package receiver;
import javax.jms.JMSException;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import javax.jms.Message;
public class WildFlyJmsQueueReceiveLocal implements MessageListener {
public void onMessage(Message msg) {
try {
System.out.println("[WildFlyJmsQueueReceiveLocal][onMessage]There are three kinds of basic JMS connection-factory that depends on the type of connectors that is used.");
String msgText;
if (msg instanceof TextMessage) {
msgText = ((TextMessage)msg).getText();
} else {
msgText = msg.toString();
}
if (msgText.equalsIgnoreCase("quit")) {
synchronized(this) {
this.notifyAll(); // Notify main thread to quit
}
}
} catch (JMSException | InterruptedException jmse) {
jmse.printStackTrace();
}
}
}
ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<display-name>MDB</display-name>
<enterprise-beans>
<message-driven>
<display-name>MDB1</display-name>
<ejb-name>MDB1</ejb-name>
<ejb-class>receiver.WildFlyJmsQueueReceiveLocal</ejb-class>
<transaction-type>Container</transaction-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>jms/queue/TestQ</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>maxSession</activation-config-property-name>
<activation-config-property-value>2</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
</enterprise-beans>
</ejb-jar>
Now i am migrating from jboss 5.x to wildfly10. In wildfly 10, JMS feature has been implemented using 'Apache ActiveMQ Artemis'.
So In wildfly 10, first i configured queue 'jms/queue/TestQ' and tried to deploy same code (which was used in jboss 5.x), It was running successfully. I thought i have to create 'ActiveMQConnectionFactory' object and do the further stuff, but it was not like that. The JMS API which i had used in Jboss 5.x,was working fine in wildfly10.
JMS sender and receiver is deployed on same wildfly instance. Am i implementing correctly the JMS queue feature? Is it the right way to do in wildfly10. If not please direct me to the link/documentation.
My Que is
Java code which i had used in Jboss 5.x (for JMS-Queue implementation) will work in Wildfly-10 without any change?

For Jboss 5.x go to JMS links :
https://docs.jboss.org/jbossas/guides/j2eeguide/r2/en/html/ch6.chapt.html

Related

IBM MQ Message property is null in MDB

I am publishing JMS text message to topic and consumer is able to consumer ( MDB ) the text message. But not able to get Message Object and String property. it is null in MDB consumer side. I have defined MDB in ejb-jar.xml under META-INF folder. I am using
TomEE plus 7.0.2
JMS 2.0
IBM MQ 8
JDK 1.8
Topic
I refereed below mentioned Tomee official example. In example they used tomee.xml instead i used resource.xml and don't use web.xml
Consumer is MessageDrivenBean
Consumer is able to get Text or Object Message. But Message property is null.
http://tomee.apache.org/tomee-and-webspheremq.html
#Resource(name = "qcf")
private ConnectionFactory connectionFactory;
#Resource(name = "wmq-javax.jms.Topic")
private Topic topic;
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(topic);
TextMessage message = session.createTextMessage();
message.setText("Test Message");
message.setObjectProperty("a","b");
message.setStringProperty("c","D");
connection.start();
producer.send(message);
session.close();
connection.close();
Consumer
<ejb-jar id="ejb-jar_ID" version="3.1"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">
<display-name>SampleTransactionMDB</display-name>
<enterprise-beans>
<message-driven>
<display-name>SampleTransactionMDB</display-name>
<ejb-name>SampleTransactionMDB</ejb-name>
<ejb-class>com.example.SampleTransactionMDB</ejb-class>
<transaction-type>Container</transaction-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>openejb:Resource/projectname/topicname</activation-config-property-value>
</activation-config-property>
</activation-config>
<activation-config-property>
<activation-config-property-name>useJNDI</activation-config-property-name>
<activation-config-property-value>true</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>HostName</activation-config-property-name>
<activation-config-property-value>x.x.x.x</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>Port</activation-config-property-name>
<activation-config-property-value>123</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>QueueManager</activation-config-property-name>
<activation-config-property-value>xxxxx</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>Channel</activation-config-property-name>
<activation-config-property-value>xxxx</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>TransportType</activation-config-property-name>
<activation-config-property-value>CLIENT</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>subscriptionName</activation-config-property-name>
<activation-config-property-value>xxxxxx</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>sharedSubscription</activation-config-property-name>
<activation-config-property-value>true</activation-config-property-value>
</activation-config-property>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
</assembly-descriptor>
</ejb-jar>
Guide me why message property is null in MDB consumer.
I found the root cause of the problem. it is my mistake. TopicProxy's targetClient should be JMS. I wrongly configured as MQ. so I was able to get message but not property.
After changing targetClient value to JMS. I am able to get message and property
http://tomee.apache.org/tomee-and-webspheremq.html
MessageProducer producer = session.createProducer(queue);
If you are publishing a message to topic then why are you using a variable named 'queue'? A topic string generally looks like 'test/ABC/one' (no quotes).
Secondly, why didn't you post the code for the consumer? Update your original posting to include the consumer code.

Spring Integration : MQSeries Message Driven Adapter Not Working

I am able to successfully integrate ActiveMQ(in bound message driven channel) and Kafka (as outbound channel). It working fine.
Now, since Both ActiveMQ and MQ Series are JMS compliant, i thought transition would be easier. But, its throwing below error :
Setup of JMS Message listener invoker failed for destination 'queue://abcd' - trying to recover - Cause: JMSQ1112: The operation for a domain specific object was not valid. The operation 'createConsumer' is not valid for type 'com.ibm.mq.jms.MQQueue'
My spring integration config looks like below:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.springframework.org/schema/integration/jms"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
http://www.springframework.org/schema/integration/kafka
http://www.springframework.org/schema/integration/kafka/spring-integration-kafka.xsd">
<jms:message-driven-channel-adapter id="requestChannelAdapter" channel="requestChannel"
container="requestListenerContainer" error-channel=""/>
<int-kafka:outbound-channel-adapter
id="kafkaOutboundChannelAdapter" kafka-template="kafkaTemplate"
auto-startup="true" sync="true" channel="inputToKafka" topic="test">
</int-kafka:outbound-channel-adapter>
</beans>
And my respective code looks like below:
public MQQueueConnectionFactory jmsConnectionfactory() {
MQQueueConnectionFactory jmsFactory = new MQQueueConnectionFactory();
jmsFactory.setHostName(hostname);
jmsFactory.setPort(1444);
jmsFactory.setQueueManager(//valid queue manager);
jmsFactory.setChannel(//valid channel name);
jmsFactory.setTransportType(1);
jmsFactory.setSSLCipherSuite(// valid suite);
return jmsFactory;
}
#Bean
public DefaultMessageListenerContainer requestListenerContainer() {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(jmsConnectionfactory());
container.setSessionTransacted(true);
container.setDestination(helloJMSQueue());
return container;
}
#Bean
public Queue helloJMSQueue() {
return new MQQueue(HELLO_QUEUE);
}
Why I am getting this error ? I saw some posts that it is due to pubLocal value not available in jmsTemplate w.r.t MQQueue but that was dated back to 2005 and i noticed the change has been released.
Use just container.setDestinationName(HELLO_QUEUE) instead and let the container to resolve it properly over Session.

High Efficient MDB using spring jms or ntegration

I have requirement where I need receive message from MQ every seconds , the message will be in XML format , so i need to write a high effecient MDB. Problem here is I am new to MQ,JMS,Spring JMS and Spring Integration but not spring tough.
Based on google search so far I am able to write below code
MDB
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
public class MyMessageListener implements MessageListener{
#Override
public void onMessage(Message m) {
TextMessage message=(TextMessage)m;
try{
System.out.println(message.getText());
}catch (Exception e) {e.printStackTrace(); }
}
}
XMl config
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms.xsd">
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"
p:brokerURL="tcp://localhost:61616" />
<bean id="listener" class="com.springexample.MyMessageListener"></bean>
<jms:listener-container container-type="default" connection-factory="connectionFactory"
acknowledge="auto">
<jms:listener destination="myfirstqueue" ref="listener" method="onMessage"></jms:listener>
</jms:listener-container>
</beans>
I know what i have written is very basic one but i dont know what is the efficient one , how to provide transaction support and how to handle such load where i am going to recieve message every seconds.
Should i use Spring JMS or Spring Integration any help is much appreciated.
The question you asked is which to use: definitely go Spring JMS

Starting a simple WebSocket Server with Spring integration

I am trying to start a simple websocket server in a spring integration application.
I build my application thanks to the following dependancies :
dependencies {
compile("org.springframework.boot:spring-boot-starter-integration")
compile("org.springframework:spring-websocket")
compile("org.springframework.integration:spring-integration-ip")
compile("org.springframework.integration:spring-integration-websocket")
compile('com.fasterxml.jackson.core:jackson-databind')
compile("org.springframework.integration:spring-integration-feed")
}
I launch my application thanks to the following Java file :
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
org.springframework.integration.annotation.IntegrationComponentScan;
#Configuration
#EnableAutoConfiguration
#IntegrationComponentScan
public class Application {
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext ctx = new SpringApplication("/integration.xml").run(args);
System.out.println("Hit Enter to terminate");
System.in.read();
ctx.close();
}
}
Here is my "integartion.xml" :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:file="http://www.springframework.org/schema/integration/file"
xmlns:feed="http://www.springframework.org/schema/integration/feed"
xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
xmlns:ws="http://www.springframework.org/schema/integration/websocket"
xsi:schemaLocation="http://www.springframework.org/schema/integration/feed http://www.springframework.org/schema/integration/feed/spring-integration-feed.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd
http://www.springframework.org/schema/integration/websocket http://www.springframework.org/schema/integration/websocket/spring-integration-websocket.xsd">
<int-ip:udp-inbound-channel-adapter id="udpReceiver"
channel="udpOutChannel"
port="11111"
receive-buffer-size="500"
multicast="true"
multicast-address="225.6.7.8"/>
<int:object-to-string-transformer input-channel="udpOutChannel" output-channel="stringified"/>
<bean id="nmeaParser" class="transformers.NMEAParser"/>
<int:transformer input-channel="stringified" ref="nmeaParser" output-channel="parsedData"/>
<int:channel id="jsondata"/>
<int:object-to-json-transformer input-channel="parsedData" output-channel="jsondata"/>
<ws:server-container id="server" path="/position"/>
<ws:outbound-channel-adapter container="server" channel="jsondata"/>
</beans>
As you can see, I create an UDP inbound channel. This channels works like a charm. I am able to see that data are sucessfully passed to my "NMEAParser" bean.
I think that my Websocket server doesn't work because :
I can't connect to it with wscat... When I try to do :
wscat -c ws://127.0.0.1:8080/position
I receive a "CONNECTION REFUSED", the same message I receive when nothing is launched.
In the Spring log's I can read this :
Starting beans in phase 0
Adding {object-to-string-transformer} as a subscriber to the 'udpOutChannel' channel
Channel 'application:8080.udpOutChannel' has 1 subscriber(s).
started org.springframework.integration.config.ConsumerEndpointFactoryBean#0
Adding {transformer} as a subscriber to the 'stringified' channel
Channel 'application:8080.stringified' has 1 subscriber(s).
started org.springframework.integration.config.ConsumerEndpointFactoryBean#1
Adding {object-to-json-transformer} as a subscriber to the 'parsedData' channel
Channel 'application:8080.parsedData' has 1 subscriber(s).
started org.springframework.integration.config.ConsumerEndpointFactoryBean#2
Adding {websocket:outbound-channel-adapter} as a subscriber to the 'jsondata' channel
Channel 'application:8080.jsondata' has 1 subscriber(s).
started org.springframework.integration.config.ConsumerEndpointFactoryBean#3
Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
Channel 'application:8080.errorChannel' has 1 subscriber(s).
started _org.springframework.integration.errorLogger
Starting beans in phase 1073741823
started udpReceiver
Started Application in 0.792 seconds (JVM running for 1.121)
We can see here that all my beans are launched, except the bean "server" which is my server container. There is no trace of this bean in this log message.
To write my application I read carrefully this sampe and this doc.
What am I doing wrong, or what I forgot ?
As discussed in the chat after our lengthy comment back and forth, you need org.springframework.boot:spring-boot-starter-websocket in your dependencies, this will bring in spring-boot-starter-web and org.springframework.boot:spring-boot-starter-tomcat transitively, giving you a websocket runtime.

How to map commonj.work.WorkManager with weblogic 10.3 Work Manager

I am trying to use WorkManagers in Weblogic 10.3. I have defined work managers in weblogic-ejb-jar.xml. I declared a resource reference for commonj.work.WorkManager in ejb-jar.xml with the res-ref-name same as the Work manager defined in weblogic-ejb-jar.xml. Here I am posting the code
MDB
package test;
import javax.annotation.Resource;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.jms.TextMessage;
import commonj.work.WorkManager;
#MessageDriven(mappedName="TEST_Q", name="MDBWithWorkManager", activationConfig = {
#javax.ejb.ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
#javax.ejb.ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
#javax.ejb.ActivationConfigProperty(propertyName = "transactionType", propertyValue = "Container")
})
public class MDBWithWorkManager implements MessageListener {
#Resource(mappedName="TestWorkManager")
private WorkManager workManager;
#Override
public void onMessage(Message arg0) {
System.out.println("onMessage() called ");
System.out.println("workManager : "+workManager);
if(arg0 instanceof TextMessage){
TextMessage msg= (TextMessage)arg0;
try {
System.out.println("Message received-->"+msg.getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}
}
ejb-jar.xml
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/j2ee/ejb-jar_3_0.xsd"
version="3.0">
<enterprise-beans>
<message-driven>
<ejb-name>MDBWithWorkManager</ejb-name>
<ejb-class>test.MDBWithWorkManager
</ejb-class>
<resource-ref>
<description>Test work manager</description>
<res-ref-name>TestWorkManager</res-ref-name>
<res-type>commonj.work.WorkManager</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</message-driven>
</enterprise-beans>
</ejb-jar>
weblogic-ejb-jar.xml
<?xml version = '1.0'?>
<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/weblogic-ejb-jar"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-ejb-jar.xsd">
<weblogic-enterprise-bean>
<ejb-name>MDBWithWorkManager</ejb-name>
</weblogic-enterprise-bean>
<work-manager>
<name>TestWorkManager</name>
<fair-share-request-class>
<name>TestWorkShare</name>
<fair-share>70</fair-share>
</fair-share-request-class>
<min-threads-constraint>
<name>TestMinThread</name>
<count>1</count>
</min-threads-constraint>
<max-threads-constraint>
<name>TestMaxThread</name>
<count>8</count>
</max-threads-constraint>
</work-manager>
</weblogic-ejb-jar>
Getting the following error while deploying
Unable to deploy EJB: MDBWithWorkManager from MDBWithWorkManager.jar:
[EJB:011026]The EJB container failed while creating the java:/comp/env namespace for this EJB deployment.
weblogic.deployment.EnvironmentException: [EJB:010176]The resource-env- ref 'test.MDBWithWorkManager/workManager' declared in the ejb-jar.xml descriptor or an
notation has no JNDI name mapped to it. The resource-ref must be mapped to a JNDI name using the resource-description element of the weblogic-ejb-jar.xml des
criptor or corresponding annotation.
at weblogic.ejb.container.deployer.EnvironmentBuilder.addResourceEnvReferences (EnvironmentBuilder.java:639)
at weblogic.ejb.container.deployer.EJBDeployer.setupEnvironmentContext (EJBDeployer.java:247)
at weblogic.ejb.container.deployer.EJBDeployer.setupEnvironmentFor(EJBDeployer.java:1014)
at weblogic.ejb.container.deployer.EJBDeployer.setupBeanInfos(EJBDeployer.java:908)
at weblogic.ejb.container.deployer.EJBDeployer.prepare(EJBDeployer.java:1188)
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:425)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:42)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:16)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:155)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:197)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:89)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:723)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1190)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:248)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:157)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:12)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:45)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Can any one please help out.
Thanks in Advance!!!!
Try adding res-ref to the actual jndi name mapping in weblogic-ejb-jar.xml for MDBWithWorkManager
something like this,
<resource-description>
<res-ref-name>TestWorkManager</res-ref-name>
<jndi-name>jndiNameOfTestWorkManager</jndi-name>
</resource-description>
believe what you need is to define a "map"-element called <dispatch-policy> within your bean def - like:
<weblogic-enterprise-bean>
<ejb-name>MDBWithWorkManager</ejb-name>
</weblogic-enterprise-bean>
change it to:
<weblogic-enterprise-bean>
<ejb-name>MDBWithWorkManager</ejb-name>
<dispatch-policy>TestWorkManager</dispatch-policy>
</weblogic-enterprise-bean>

Resources