简体   繁体   English

如何在Wildfly 10中配置JMS?在子系统下找不到JMS菜单

[英]How to configure the JMS in Wildfly 10?Can not find the JMS menu under subsystem

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. 当前,我正在编写一个在Wildfly 10上运行的JMS示例应用程序。但是我看不到在Wildfly 10的管理控制台子系统中可以创建JMS队列的菜单。请帮助我在Wildfly 10管理控制台中找到JMS菜单。 。

I did the above things but i got some exception while starting the wildfly 10 server.Below is the exception : 我做了上述事情,但是在启动wildfly 10服务器时遇到了一些异常。以下是异常:

 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: 我的wildfly standalone-full.xml配置如下:

<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: 我的产生和使用消息的Servlet代码如下:

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 : 我的消息驱动Bean如下所述:

   /*
 * 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 : 以下是ejb-jar.xml代码:

<?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 谢谢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 . 消息传递未包含在wildfly 10的默认独立配置文件中。您可以切换为standalone-fullstandalone-full-ha配置文件,也可以手动启用相应的子系统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. 在域模式下,默认情况下, fullfull-ha配置文件已启用消息传递。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM