JMS - Exceptions

The JMSException

JMS defines JMSException as the root class for exceptions thrown by JMS methods. JMSException is a checked exception and catching it provides a generic way of handling all JMS related exceptions. JMSException provides the following information:

  • A provider-specific string describing the error - This string is the standard Java exception message, and is available via getMessage() .
  • A provider-specific string error code
  • A reference to another exception - Often a JMS exception will be the result of a lower level problem. If appropriate, this lower level exception can be linked to the JMS exception.

JMS methods include only JMSException in their signatures. JMS methods can throw any JMS standard exception as well as any JMS provider-specific exception. The javadoc for JMS methods documents only the mandatory exception cases.

Standard Exceptions

In addition to JMSException, JMS defines several additional exceptions that standardize the reporting of basic error conditions. There are only a few cases where JMS mandates that a specific JMS exception must be thrown. These cases are indicated by the words must be in the exception description. These cases are the only ones on which client logic should depend on a specific problem resulting in a specific JMS exception being thrown.

In the remainder of cases, it is strongly suggested that JMS providers use one of the standard exceptions where possible. JMS providers may also derive provider-specific exceptions from these if needed.

JMS defines the following standard exceptions:

  • IllegalStateException: This exception is thrown when a method is invoked at an illegal or inappropriate time or if the provider is not in an appropriate state for the requested operation. For example, this exception must be thrown if Session.commit()  is called on a non-transacted session. This exception is also must be called when domain inappropriate method is called, such as calling TopicSession.CreateQueueBrowser() .
  • JMSSecurityException: This exception must be thrown when a provider rejects a user name/password submitted by a client. It may also be thrown for any case where a security restriction prevents a method from completing.
  • InvalidClientIDException: This exception must be thrown when a client attempts to set a connection’s client identifier to a value that is rejected by a provider.
  • InvalidDestinationException: This exception must be thrown when a destination is either not understood by a provider or is no longer valid.
  • InvalidSelectorException: This exception must be thrown when a JMS client attempts to give a provider a message selector with invalid syntax.
  • MessageEOFException: This exception must be thrown when an unexpected end of stream has been reached when a StreamMessage or BytesMessage is being read.
  • MessageFormatException: This exception must be thrown when a JMS client attempts to use a data type not supported by a message or attempts to read data in a message as the wrong type. It must also be thrown when equivalent type errors are made with message property values. For example, this exception must be thrown if StreamMessage.writeObject() is given an unsupported class or if StreamMessage.readShort() is used to read a boolean value. This exception also must be thrown if a provider is given a type of
    message it cannot accept. Note that the special case of a failure caused by attempting to read improperly formatted String data as numeric values must throw the java.lang.NumberFormatException.
  • MessageNotReadableException: This exception must be thrown when a JMS client attempts to read a write-only message.
  • MessageNotWriteableException: This exception must be thrown when a JMS client attempts to write to a read-only message.
  • ResourceAllocationException: This exception is thrown when a provider is unable to allocate the resources required by a method. For example, this exception should be thrown when a call to createTopicConnection fails due to lack of JMS provider resources.
  • TransactionInProgressException: This exception is thrown when an operation is invalid because a transaction is in progress. For instance, attempting to call Session.commit()  when a session is part of a distributed transaction should throw a TransactionInProgressException.
  • TransactionRolledBackException: This exception must be thrown when a call to Session.commit results in a rollback of the current transaction.
时间: 2024-10-09 23:15:21

JMS - Exceptions的相关文章

SpringFramework4系列之SpringJMS:(五)Jms namespace的使用

Spring jms 的命名空间 xmlns:jms="  xsi:schemaLocation=" http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd" Spring jms 的命名空间元素 SpringJMS 提供了 三种 命名空间元素 <jms:annotation-drive> <jms:listener-

Table of Contents - JMS

JMS Specification v1.1 JMS 基本概念 Message QueueBrowser 消息选择器 消息确认 ConnectionMetaData ExceptionListener 事务性消息 Temporary Destination Exceptions

Catch Application Exceptions in a Windows Forms Application

You need to handle the System.Windows.Forms.Application.ThreadException event for Windows Forms. This article really helped me: http://bytes.com/forum/thread236199.html. Application.ThreadException += new ThreadExceptionEventHandler(MyCommonException

jms入门

一.所需jar(maven) <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-all</artifactId> <version>5.14.3</version> </dependency> 二.创建生产者 import org.apache.activemq.ActiveMQConnectionFactory;

JMS开发步骤和持久化/非持久化Topic消息

------------------------------------------------ 开发一个JMS的基本步骤如下: 1.创建一个JMS connection factory 2.通过connection factory来创建JMS connection 3.启动JMS connection 4.通过connection创建JMS session 5.创建JMS destination 6.创建JMS producer 或者创建JMS message,并设置destination 7

log4j的1.2.15版本,在pom.xml中的顶层project报错错误: Failure to transfer javax.jms:jms:jar:1.1 from https://maven-repository.dev.java.net/nonav/repository......

在动态网站工程中,添加了Pom依赖,当添加log4j的1.2.15版本依赖时,在pom.xml中的顶层project报错错误: Failure to transfer javax.jms:jms:jar:1.1 from https://maven-repository.dev.java.net/nonav/repository......,如下图 这是因为 https://maven-repository.dev.java.net/nonav/repository 这个域名已经无法解析了. 而

JMS的作用

JMS就是生产者与消费者模式.消费者负责消费生产者产生的消息.通过JMS可以做后台的异步操作,应用到具体工作中的话,有用它来发内部消息的.发邮件的.发短信的,做大操作时在后台做异步操作的. Java 消息服务(Java Message Service,JMS)应用程序接口是一个Java 平台中关于面向消息中间件(MOM)的API,用于在两个应用程序之间,或分布式系统中发送消息,进行异步通信.Java 消息服务是一个与具体平台无关的 API,绝大多数 MOM 提供商都对 JMS 提供支持. Jav

django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configur

django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. import xadmin时出了这个问

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxError Exception

1.错误描述 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxError Exception:You have an error in your SQL syntax check the manual that corresponds to your MySQL server version for the right syntax to use near 'notnull,user_name varchar(255) )' at line 1 2.错误原因