0

我正在尝试在 OpenEJB 上使用带有消息驱动 bean 的主题。所以我将 conf/openejb.xml 编辑为:

<?xml version="1.0" encoding="UTF-8"?>
<openejb>
    <Resource id="TrueUpdate" type="javax.jms.Topic">
        destination = TrueUpdate
        clientId = nevermind
    </Resource>
</openejb>

使用bin/openejb properties我得到:

# Resource(id=TrueUpdate)
# className: org.apache.activemq.command.ActiveMQTopic
# 
TrueUpdate = new://Resource?type=javax.jms.Topic
TrueUpdate.destination = TrueUpdate
TrueUpdate.clientId = nevermind

这看起来不错。但是,在部署我的 EAR 文件时,我得到:

Exception: class org.apache.openejb.OpenEJBException: Unable to create activation spec: Invalid settings: subscriptionDurability cannot be set to: Durable when destinationType is set to javax.jms.Queue as it is only valid when destinationType is set to javax.jms.Topic. clientId must be set since durable subscription was requested.: Unable to create activation spec: Invalid settings: subscriptionDurability cannot be set to: Durable when destinationType is set to javax.jms.Queue as it is only valid when destinationType is set to javax.jms.Topic. clientId must be set since durable subscription was requested.
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:836)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:546)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:542)
        at org.apache.openejb.assembler.DeployerEjb.deploy(DeployerEjb.java:195)
        at org.apache.openejb.assembler.DeployerEjb.deploy(DeployerEjb.java:104)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
        at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
        at org.apache.openejb.security.internal.InternalSecurityInterceptor.invoke(InternalSecurityInterceptor.java:34)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
        at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
        at org.apache.openejb.cdi.CdiInterceptor.invoke(CdiInterceptor.java:126)
        at org.apache.openejb.cdi.CdiInterceptor.access$000(CdiInterceptor.java:42)
        at org.apache.openejb.cdi.CdiInterceptor$1.call(CdiInterceptor.java:63)
        at org.apache.openejb.cdi.CdiInterceptor.aroundInvoke(CdiInterceptor.java:69)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
        at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
        at org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:176)
        at org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:95)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
        at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
        at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:138)
        at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:239)
        at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:191)
        at org.apache.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:290)
        at org.apache.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:140)
        at org.apache.openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:267)
        at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:191)
        at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:81)
        at org.apache.openejb.server.ejbd.KeepAliveServer$Session.service(KeepAliveServer.java:273)
        at org.apache.openejb.server.ejbd.KeepAliveServer$Session.access$1000(KeepAliveServer.java:192)
        at org.apache.openejb.server.ejbd.KeepAliveServer.service(KeepAliveServer.java:326)
        at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:72)
        at org.apache.openejb.server.ServerServiceFilter.service(ServerServiceFilter.java:64)
        at org.apache.openejb.server.ServerServiceFilter.service(ServerServiceFilter.java:64)
        at org.apache.openejb.server.ServiceStats.service(ServiceStats.java:54)
        at org.apache.openejb.server.ServerServiceFilter.service(ServerServiceFilter.java:64)
        at org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java:92)
        at org.apache.openejb.server.ServerServiceFilter.service(ServerServiceFilter.java:64)
        at org.apache.openejb.server.ServicePool.access$201(ServicePool.java:35)
        at org.apache.openejb.server.ServicePool$3.run(ServicePool.java:174)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)
Caused by: org.apache.openejb.OpenEJBException: Error deploying 'MessageListenerBean'.  Exception: class org.apache.openejb.OpenEJBException: Unable to create activation spec: Invalid settings: subscriptionDurability cannot be set to: Durable when destinationType is set to javax.jms.Queue as it is only valid when destinationType is set to javax.jms.Topic. clientId must be set since durable subscription was requested.: Unable to create activation spec: Invalid settings: subscriptionDurability cannot be set to: Durable when destinationType is set to javax.jms.Queue as it is only valid when destinationType is set to javax.jms.Topic. clientId must be set since durable subscription was requested.
        at org.apache.openejb.assembler.classic.Assembler.startEjbs(Assembler.java:974)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:730)
        ... 58 more
Caused by: org.apache.openejb.OpenEJBException: Unable to create activation spec: Invalid settings: subscriptionDurability cannot be set to: Durable when destinationType is set to javax.jms.Queue as it is only valid when destinationType is set to javax.jms.Topic. clientId must be set since durable subscription was requested.
        at org.apache.openejb.core.mdb.MdbContainer.createActivationSpec(MdbContainer.java:251)
        at org.apache.openejb.core.mdb.MdbContainer.deploy(MdbContainer.java:136)
        at org.apache.openejb.assembler.classic.Assembler.startEjbs(Assembler.java:961)
        ... 59 more
Caused by: javax.resource.spi.InvalidPropertyException: Invalid settings: subscriptionDurability cannot be set to: Durable when destinationType is set to javax.jms.Queue as it is only valid when destinationType is set to javax.jms.Topic. clientId must be set since durable subscription was requested.
        at org.apache.activemq.ra.ActiveMQActivationSpec.validate(ActiveMQActivationSpec.java:136)
        at org.apache.openejb.core.mdb.MdbContainer.createActivationSpec(MdbContainer.java:229)
        ... 61 more

这是我的豆子:

@MessageDriven(mappedName = "TrueUpdate",
        activationConfig = {
            @ActivationConfigProperty(propertyName = "messageSelector",
                                      propertyValue = "manager = true"),
            @ActivationConfigProperty(propertyName = "destinationType",
                                      propertyValue = "javax.jms.Topic"),
            @ActivationConfigProperty(propertyName = "destination",
                                      propertyValue = "TrueUpdate"),
            @ActivationConfigProperty(propertyName = "subscriptionDurability",
                                      propertyValue = "Durable"),
            @ActivationConfigProperty(propertyName = "subscriptionName",
                                      propertyValue = "TrueUpdate Manager"),
        })
public class MessageListenerBean implements MessageListener {
    ...
}

我在这里做错了什么?

4

2 回答 2

1

我遇到了同样的问题,我尝试了以下事情。然后它工作:

  1. 设置客户端ID

     @ActivationConfigProperty (propertyName = "clientId", propertyValue = "clientIdxxx")
    
  2. 将“destinationType”更新为“DestinationType”

于 2013-12-04T08:33:23.197 回答
0

删除 mappedName 配置,否则 openEjb 将默认为 Queue 而不是 Topic。

于 2019-03-27T10:45:24.210 回答