Currently I am writing a JMS sample application which runs on Wildfly 10. But I can not see the menu under which we can create JMS Queue in Subsystem of Admin console in wildfly 10. Please help me to locate the JMS menu in Wildfly 10 admin console.
I did the above things but i got some exception while starting the wildfly 10 server.Below is the exception :
Failed to process phase INSTALL of subdeployment "JMS1-war.war" of deployment "dfc.ear"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0092: No message destination with name JMS1-ejb.jar#jms/testingQ for binding java:module/env/jms/testingQ"},
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.deployment.unit."dfc.ear".deploymentCompleteService is missing [jboss.deployment.subunit."dfc.ear"."JMS1-ejb.jar".deploymentCompleteService, jboss.deployment.subunit."dfc.ear"."JMS1-war.war".deploymentCompleteService]",
"jboss.naming.context.java.comp.dfc.JMS1-ejb.MDBBean.HandleDelegate is missing [jboss.naming.context.java.comp.dfc.JMS1-ejb.MDBBean]",
"jboss.naming.context.java.comp.dfc.JMS1-ejb.MDBBean.ValidatorFactory is missing [jboss.naming.context.java.comp.dfc.JMS1-ejb.MDBBean]",
"jboss.naming.context.java.comp.dfc.JMS1-ejb.MDBBean.InstanceName is missing [jboss.naming.context.java.comp.dfc.JMS1-ejb.MDBBean]",
"jboss.deployment.subunit."dfc.ear"."JMS1-ejb.jar".INSTALL is missing [jboss.deployment.subunit."dfc.ear"."JMS1-war.war".deploymentCompleteService]",
"jboss.naming.context.java.comp.dfc.JMS1-ejb.MDBBean.InAppClientContainer is missing [jboss.naming.context.java.comp.dfc.JMS1-ejb.MDBBean]",
"jboss.naming.context.java.comp.dfc.JMS1-ejb.MDBBean.ORB is missing [jboss.naming.context.java.comp.dfc.JMS1-ejb.MDBBean]",
"jboss.naming.context.java.comp.dfc.JMS1-ejb.MDBBean.Validator is missing [jboss.naming.context.java.comp.dfc.JMS1-ejb.MDBBean]"
My wildfly standalone-full.xmlconfiguration is below:
<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"/>
<jms-queue name="testingQ">
<entry name="jms/testingQ"/>
<entry name="java:jboss/exported/jms/testingQ"/>
</jms-queue>
<connection-factory name="InVmConnectionFactory" connectors="in-vm" entries="java:/ConnectionFactory"/>
<connection-factory name="RemoteConnectionFactory" connectors="http-connector" entries="java:jboss/exported/jms/RemoteConnectionFactory"/>
<connection-factory name="testingQFactory" connectors="http-connector" entries="java:jboss/exported/jms/testingQFactory"/>
<pooled-connection-factory name="activemq-ra" transaction="xa" connectors="in-vm" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory"/>
</server>
</subsystem>
My Servlet code which produces and consumes the message is below:
private Message createJMSMessageForjmsTestingQ(Session session, Object
messageData) throws JMSException {
// TODO create and populate message to send
TextMessage tm = session.createTextMessage();
tm.setText(messageData.toString());
return tm;
}
private void sendJMSMessageToTestingQ(Object messageData) throws
NamingException, JMSException {
Context c = new InitialContext();
ConnectionFactory cf = (ConnectionFactory)
c.lookup("java:comp/env/jms/testingQFactory");
Connection conn = null;
Session s = null;
try {
conn = cf.createConnection();
s = conn.createSession(false, s.AUTO_ACKNOWLEDGE);
Destination destination = (Destination)
c.lookup("java:comp/env/jms/testingQ");
MessageProducer mp = s.createProducer(destination);
mp.send(createJMSMessageForjmsTestingQ(s, messageData));
} finally {
if (s != null) {
try {
s.close();
} catch (JMSException e) {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot close
session", e);
}
}
if (conn != null) {
conn.close();
}
}
}
My Message Driven Bean is mentioned below :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package dfc.jms;
import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.jms.Message;
import javax.jms.MessageListener;
/**
*
* @author croushan
*/
public class MDBBean implements MessageDrivenBean, MessageListener {
private MessageDrivenContext context;
// <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click on the + sign on the left to edit the code.">
/**
* @see javax.ejb.MessageDrivenBean#setMessageDrivenContext(javax.ejb.MessageDrivenContext)
*/
public void setMessageDrivenContext(MessageDrivenContext aContext) {
context = aContext;
}
/**
* See section 15.4.4 of the EJB 2.0 specification
* See section 15.7.3 of the EJB 2.1 specification
*/
public void ejbCreate() {
// TODO Add code to acquire and use other enterprise resources (DataSource, JMS, enterprise bean, Web services)
}
/**
* @see javax.ejb.MessageDrivenBean#ejbRemove()
*/
public void ejbRemove() {
// TODO release any resource acquired in ejbCreate.
// The code here should handle the possibility of not getting invoked
// See section 15.7.3 of the EJB 2.1 specification
}
// </editor-fold>
public void onMessage(Message aMessage) {
System.out.println("Message is :"+aMessage.toString());
}
}
Below is the ejb-jar.xml code :
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<enterprise-beans>
<message-driven>
<display-name>MDBBeanMDB</display-name>
<ejb-name>MDBBean</ejb-name>
<ejb-class>dfc.jms.MDBBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
<message-destination-link>jms/testingQ</message-destination-link>
<activation-config>
<activation-config-property>
<activation-config-property-name>acknowledgeMode</activation-config-property-name>
<activation-config-property-value>Auto-acknowledge</activation-config-property-value>
</activation-config-property>
<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>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>MDBBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<message-destination>
<display-name>Destination for MDBBeanMDB</display-name>
<message-destination-name>jms/testingQ</message-destination-name>
</message-destination>
</assembly-descriptor>
</ejb-jar>
Thanks, Chandan
Messaging is not included in the default standalone profile of wildfly 10. You can either switch to either standalone-full
or standalone-full-ha
profile or manually enable the corresponding subsystem messaging-activemq
. For that you need to add extension:
<extension module="org.wildfly.extension.messaging-activemq"/>
and then the sub module config:
<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" entries="java:/ConnectionFactory" connectors="in-vm"/>
<connection-factory name="RemoteConnectionFactory" connectors="http-connector" entries="java:jboss/exported/jms/RemoteConnectionFactory"/>
<pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm" transaction="xa"/>
</server>
</subsystem>
In domain mode, the profiles full
and full-ha
have messaging enabled by default.