I was written a simple MessageListener(MDB) it is working fine.How to handle runtime exceptions in this.
[例如:如果尝试使用错误的队列名称(例如“XXXX”)而不是正确的队列名称部署此侦听器,那么它显示例外情况,此外还会出现部署失败。]
那么如何避免这种类型的例外是否有任何注释可用。
我试图在下面Class(ORANGE_QUEUE_MDB)
内部处理。但控制权并没有进入内部。
请帮我解决这类错误。
@MessageDriven(name="WEBSPHERE_MDB",
activationConfig = {
@ActivationConfigProperty(propertyName="messagingType",propertyValue="javax.jms.MessageListener"),
@ActivationConfigProperty(propertyName = "destinationType",propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "ORANGE.QUEUE"),
@ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
@ActivationConfigProperty(propertyName = "channel", propertyValue = "SYSTEM.DEF.CONN"),
@ActivationConfigProperty(propertyName = "hostName", propertyValue = "192.168.22.29"),
@ActivationConfigProperty(propertyName = "queueManager", propertyValue = "manager"),
@ActivationConfigProperty(propertyName = "port", propertyValue = "1414"),
@ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT"),
@ActivationConfigProperty(propertyName = "username", propertyValue = "mqm"),
@ActivationConfigProperty(propertyName = "password", propertyValue = "password")
},
mappedName = "ORANGE.QUEUE",
messageListenerInterface = MessageListener.class)
@ResourceAdapter(value = "wmq.jmsra.rar")
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@ApplicationException(rollback = true)
public class ORANGE_QUEUE_MDB extends RuntimeException implements MessageListener
{
public void onMessage(Message message) {
try{
TextMessage textMessage=(TextMessage) message;
}
catch(Exception e)
{
e.printStackTrace();
}
当我在Jboss中部署上面的监听器(具有错误的队列名称)时,它显示在下面的异常 例外情况如下:
11:17:14,630 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.deployment.unit."WEBSPHERE_MDB.jar".component.WEBSPHERE_MDB.START:
org.jboss.msc.service.StartException in service jboss.deployment.unit."WEBSPHERE_MDB.jar".component.WEBSPHERE_MDB.START: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_25]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_25]
Caused by: java.lang.RuntimeException: com.ibm.mq.connector.DetailedResourceException: MQJCA0001: An exception occurred in the JMS layer.
See the linked exception for details., error code: MQJCA0001 A call to WebSphere MQ classes for JMS caused an exception to be thrown.
See the linked exception for details of the failure.
at org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponent.start(MessageDrivenComponent.java:171)
at org.jboss.as.ee.component.ComponentStartService.start(ComponentStartService.java:44)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
... 3 more
**Caused by: com.ibm.mq.connector.DetailedResourceException:** MQJCA0001: An exception occurred in the JMS layer. See the linked exception for details.,
error code: MQJCA0001 A call to WebSphere MQ classes for JMS caused an exception to be thrown. See the linked exception for details of the failure.
at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:124)
at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:100)
at com.ibm.mq.connector.inbound.MessageEndpointDeployment.start(MessageEndpointDeployment.java:351)
at com.ibm.mq.connector.inbound.MessageEndpointDeployment.<init>(MessageEndpointDeployment.java:301)
at com.ibm.mq.connector.ResourceAdapterImpl.endpointActivation(ResourceAdapterImpl.java:463)
at org.jboss.jca.core.rar.EndpointImpl.activate(EndpointImpl.java:164)
at org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponent.start(MessageDrivenComponent.java:169)
... 6 more
**Caused by: com.ibm.msg.client.jms.DetailedInvalidDestinationException: JMSWMQ2008: Failed to open MQ queue 'OORANGE.QUEUE'.**
JMS attempted to perform an MQOPEN, but WebSphere MQ reported an error. Use the linked exception to determine the cause of this error.
Check that the specified queue and queue manager are defined correctly.
at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:520)
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:236)
at com.ibm.msg.client.wmq.internal.WMQMessageConsumer.checkJmqiCallSuccess(WMQMessageConsumer.java:128)
at com.ibm.msg.client.wmq.internal.WMQConsumerShadow.initialize(WMQConsumerShadow.java:856)
at com.ibm.msg.client.wmq.internal.WMQAsyncConsumerShadow.initialize(WMQAsyncConsumerShadow.java:724)
at com.ibm.msg.client.wmq.internal.WMQConnectionBrowser.<init>(WMQConnectionBrowser.java:1230)
at com.ibm.msg.client.wmq.internal.WMQConnection.createConnectionBrowser(WMQConnection.java:872)
at com.ibm.msg.client.jms.internal.JmsConnectionImpl.createConnectionBrowser(JmsConnectionImpl.java:922)
at com.ibm.msg.client.jms.internal.JmsConnectionConsumerImpl.createConnectionBrowser(JmsConnectionConsumerImpl.java:238)
at com.ibm.msg.client.jms.internal.JmsConnectionConsumerImpl.<init>(JmsConnectionConsumerImpl.java:166)
at com.ibm.msg.client.jms.internal.JmsConnectionConsumerImpl.<init>(JmsConnectionConsumerImpl.java:116)
at com.ibm.msg.client.jms.internal.JmsConnectionImpl.createConnectionConsumer(JmsConnectionImpl.java:415)
at com.ibm.mq.jms.MQConnection.createConnectionConsumer(MQConnection.java:215)
at com.ibm.mq.connector.inbound.MessageEndpointDeployment.createConnectionConsumer(MessageEndpointDeployment.java:486)
at com.ibm.mq.connector.inbound.MessageEndpointDeployment.start(MessageEndpointDeployment.java:331)
... 10 more
**Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2085' ('MQRC_UNKNOWN_OBJECT_NAME').**
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:223)
... 23 more
如何处理这些异常并替换为Userdefind
自定义错误消息。喜欢(队列配置错误,请检查)等。