目前我正在編寫一個運行在Wildfly 10上的JMS示例應用程序。但是我看不到我們可以在子系統中創建JMS隊列的菜單Wildfly 10管理控制檯中的管理控制檯。請幫助我找到Wildfly 10管理控制檯中的JMS菜單。如何在Wildfly 10中配置JMS?在子系統下找不到JMS菜單
我做上面的東西,但我有一些例外,同時啓動wildfly 10 server.Below是例外:
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]"
我wildfly獨立-full.xmlconfiguration低於:
<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>
我的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();
}
}
}
我的驅動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());
}
}
下面是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>
感謝, CHANDAN
你用'standalone-full.xml'啓動服務器嗎?你使用'standalone.sh -c standalone-full.xml'嗎?你的servlet不會消費任何消息,但是從堆棧跟蹤看來,你有一個叫做「MDBBean」的MDB。它是什麼樣子的?你爲什麼用'java:comp/env/jms/testingQFactory'查找連接工廠,而不是使用你在standalone.xml中指定的條目'java:jboss/exported/jms/testingQFactory'?隊列相同 - 它應該有jms條目名稱'java:/ jms/queue/testingQ' – yntelectual
感謝您的快速回復@yntelectual。是的,我使用standalone.sh -c standalone-full.xml。 –
我有MDBBean作爲消息驅動bean。我已經在代碼中包含了這個問題。 –