23.07.2013 Views

O'Reilly - Java Message Service

O'Reilly - Java Message Service

O'Reilly - Java Message Service

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A.1.8 JMSException<br />

<strong>Java</strong> <strong>Message</strong> <strong>Service</strong><br />

The JMSException is the base exception type for all exceptions thrown by the JMS API. It<br />

may provide an error message describing the cause of the exception, a provider-specific<br />

error code, and possibly a reference to the exception that caused the JMS exception:<br />

public class JMSException extends java.lang.Exception {<br />

public JMSException(java.lang.String reason) { .. }<br />

public JMSException(java.lang.String reason,<br />

java.lang.String errorCode) { .. }<br />

public String getErrorCode( ) { .. }<br />

public Exception getLinkedException( ) { .. }<br />

public void setLinkedException(java.lang.Exception ex) { .. }<br />

}<br />

While the JMSException is usually declared as the exception type thrown from methods in<br />

the JMS API, the actual exception thrown may be one of a dozen subtypes, which are<br />

enumerated below. The descriptions of these exception types are derived from Sun<br />

Microsystems' JMS API documentation and they implement the methods defined by the<br />

JMSException super type:<br />

IllegalStateException<br />

Thrown when a method is invoked illegally or inappropriately, or if the provider is<br />

not in an appropriate state when the method is called. For example, this exception<br />

should be thrown if Session.commit( ) is called on a non-transacted session.<br />

InvalidClientIDException<br />

Thrown when a client attempts to set a connection's client ID to a value that the<br />

provider rejects.<br />

InvalidDestinationException<br />

Thrown when the provider doesn't understand the destination, or the destination is no<br />

longer valid.<br />

InvalidSelectorException<br />

Thrown when the syntax of a message selector is invalid.<br />

JMSSecurityException<br />

Thrown when a provider rejects a username/password. Also thrown when a security<br />

restriction prevents a method from completing.<br />

<strong>Message</strong>EOFException<br />

Thrown if a stream ends unexpectedly when a Stream<strong>Message</strong> or Bytes<strong>Message</strong> is<br />

being read.<br />

144

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!