1
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これらの例外を処理し、カスタム エラー メッセージに置き換える方法。同様に(キュー構成エラーを確認してください)など。

4

0 に答える 0