How to configure Wildfly 10 to send JMS messages from a Stateless Session EJB?
rsoika Aug 20, 2017 12:06 PMI try to figure out how to setup Wildfly 10 so I can send a JMS 2.0 message to a queue.
I added the messaging-activemq extention to my standalone.xml:
<extension module="org.wildfly.extension.messaging-activemq"/>
and also I added the subsystem:
.... <subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0"> <server name="default"> <security-setting name="#"> <role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/> </security-setting> <address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10"/> <http-connector name="http-connector" socket-binding="http" endpoint="http-acceptor"/> <http-connector name="http-connector-throughput" socket-binding="http" endpoint="http-acceptor-throughput"> <param name="batch-delay" value="50"/> </http-connector> <in-vm-connector name="in-vm" server-id="0"/> <http-acceptor name="http-acceptor" http-listener="default"/> <http-acceptor name="http-acceptor-throughput" http-listener="default"> <param name="batch-delay" value="50"/> <param name="direct-deliver" value="false"/> </http-acceptor> <in-vm-acceptor name="in-vm" server-id="0"/> <jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/> <jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/> <connection-factory name="InVmConnectionFactory" connectors="in-vm" entries="java:/ConnectionFactory"/> <connection-factory name="RemoteConnectionFactory" connectors="http-connector" entries="java:jboss/exported/jms/RemoteConnectionFactory"/> <pooled-connection-factory name="activemq-ra" transaction="xa" connectors="in-vm" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory"/> <jms-queue name="testQueue" entries="jms/queue/test java:jboss/exported/jms/queue/test" /> <jms-topic name="testTopic" entries="jms/topic/test java:jboss/exported/jms/topic/test" /> </server> </subsystem> .....
My EJB code looks like this:
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.jms.JMSContext;
import javax.jms.Queue;
import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.exceptions.PluginException;
@Stateless
@LocalBean
public class JMSService {
private static Logger logger = Logger.getLogger(JMSService.class.getName());
@Resource(mappedName = "java:jboss/exported/jms/queue/test")
private Queue queueExample;
@Inject
JMSContext context;
public void doArchive(String path, ItemCollection document) throws PluginException {
logger.info("sending a JMS message...");
try {
context.createProducer().send(queueExample, path);
} catch (Exception exc) {
exc.printStackTrace();
}
}
}
Deployment seems to be ok - so the queue is available - I think.
But when I call the method doArchive I got the following exception:
imixs-archive-office_1 | 15:49:04,216 INFO [org.imixs.workflow.archive.hadoop.JMSService] (default task-60) sending a JMS message... imixs-archive-office_1 | 15:49:04,227 ERROR [stderr] (default task-60) java.lang.RuntimeException: javax.naming.NameNotFoundException: DefaultJMSConnectionFactory -- service jboss.naming.context.java.comp.imixs-office-workflow."imixs-office-workflow-ejb-3.0.5-SNAPSHOT".JMSService.DefaultJMSConnectionFactory imixs-archive-office_1 | 15:49:04,228 ERROR [stderr] (default task-60) at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.lookup(InjectedJMSContext.java:134) imixs-archive-office_1 | 15:49:04,229 ERROR [stderr] (default task-60) at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.getConnectionFactory(InjectedJMSContext.java:122) imixs-archive-office_1 | 15:49:04,229 ERROR [stderr] (default task-60) at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.getDelegate(InjectedJMSContext.java:90) imixs-archive-office_1 | 15:49:04,229 ERROR [stderr] (default task-60) at org.wildfly.extension.messaging.activemq.deployment.injection.JMSContextWrapper.createProducer(JMSContextWrapper.java:66) imixs-archive-office_1 | 15:49:04,229 ERROR [stderr] (default task-60) at org.imixs.workflow.archive.hadoop.JMSService.doArchive(JMSService.java:73) ... ....... imixs-archive-office_1 | 15:49:04,355 ERROR [stderr] (default task-60) at java.lang.Thread.run(Thread.java:745) imixs-archive-office_1 | 15:49:04,356 ERROR [stderr] (default task-60) Caused by: javax.naming.NameNotFoundException: DefaultJMSConnectionFactory -- service jboss.naming.context.java.comp.imixs-office-workflow."imixs-office-workflow-ejb-3.0.5-SNAPSHOT".JMSService.DefaultJMSConnectionFactory imixs-archive-office_1 | 15:49:04,357 ERROR [stderr] (default task-60) at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106) imixs-archive-office_1 | 15:49:04,357 ERROR [stderr] (default task-60) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207) imixs-archive-office_1 | 15:49:04,357 ERROR [stderr] (default task-60) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184) imixs-archive-office_1 | 15:49:04,357 ERROR [stderr] (default task-60) at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:237) imixs-archive-office_1 | 15:49:04,357 ERROR [stderr] (default task-60) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193) imixs-archive-office_1 | 15:49:04,358 ERROR [stderr] (default task-60) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189) imixs-archive-office_1 | 15:49:04,358 ERROR [stderr] (default task-60) at javax.naming.InitialContext.lookup(InitialContext.java:417) imixs-archive-office_1 | 15:49:04,358 ERROR [stderr] (default task-60) at javax.naming.InitialContext.lookup(InitialContext.java:417) imixs-archive-office_1 | 15:49:04,358 ERROR [stderr] (default task-60) at org.wildfly.extension.messaging.activemq.deployment.injection.InjectedJMSContext.lookup(InjectedJMSContext.java:132) imixs-archive-office_1 | 15:49:04,358 ERROR [stderr] (default task-60) ... 205 more
Can anybody help to figure out what is missing here?
===
Ralph