message-driven-destination in ejb-jar.xml for JBoss7
-
27-10-2019 - |
سؤال
So I am working on migration to JBoss7 ... Know I am encountering bunch of problems related to my XML (as expected). First was the
<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
which was resolved from this thread
Now I am getting:
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[39,10]
Message: Unexpected element 'message-driven-destination' encountered
at org.jboss.metadat a.parser.util.MetaDataElementParser.unexpectedElement(MetaDataElementParser.java:109)
This is due to my xml containing:
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
But I cant figure out how should I properly set up the destination-type.
The full ejb-jar.xml that I have as follow:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar >
<description><![CDATA[Message Driven Bean for processing subscription.]]></description>
<display-name>EJB Bean</display-name>
<enterprise-beans>
<!-- Message Driven Beans -->
<message-driven >
<description><![CDATA[Bean for processing subscription.]]></description>
<display-name>EJB Subscription Bean</display-name>
<ejb-name>EJBSubscriptionBean</ejb-name>
<ejb-class>com.package.bean.EJBSubscriptionBean</ejb-class>
<transaction-type>Container</transaction-type>
<!-- To work with JBoss7 -->
<!-- <acknowledge-mode>Auto-acknowledge</acknowledge-mode> -->
<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>
<!-- -->
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
</message-driven>
<message-driven >
<description><![CDATA[Bean for processing refunds.]]></description>
<display-name>E Refund Bean</display-name>
<ejb-name>EJBRefundBean</ejb-name>
<ejb-class>com.package.bean.EJBRefundBean</ejb-class>
<transaction-type>Container</transaction-type>
<!-- To work with JBoss7 -->
<!-- <acknowledge-mode>Auto-acknowledge</acknowledge-mode> -->
<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>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
</enterprise-beans>
</ejb-jar>
Thanks for your help in advance.
المحلول
I've changed the ejb-jar.xml entirely to just:
<!--?xml version="1.0"?-->
<ejb-jar version="3.0" 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_0.xsd">
<interceptors>
<interceptor>
<interceptor-class>com.package.bean.EJBSubscriptionBean</interceptor-class>
</interceptor>
<interceptor>
<interceptor-class>com.package.bean.EJBRefundBean</interceptor-class>
</interceptor>
</interceptors>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>EJBSubscriptionBean</ejb-name>
<interceptor-class>com.package.bean.EJBSubscriptionBean</interceptor-class>
</interceptor-binding>
<interceptor-binding>
<ejb-name>EJBRefundBean</ejb-name>
<interceptor-class>com.package.bean.EJBRefundBean</interceptor-class>
</interceptor-binding>
</assembly-descriptor>
</ejb-jar>
and add the settings through Annotations on the Beans themselves:
//JBoss 7 / JDK 6 / EJB3 Annotations
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
// @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/TEST_QUEUE"),
@ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable") })
نصائح أخرى
'message-driven-destination' is not supported in EJB 2.1 or above. This issue will be resolved by replacing tag by
<message-destination-type>javax.jms.Queue</message-destination-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>java:/queue/CacheQueue</activation-config-property-value>
</activation-config-property>
</activation-config>
لا تنتمي إلى StackOverflow