Java Doc for Connection.java in  » EJB-Server-JBoss-4.2.1 » j2ee » javax » jms » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server JBoss 4.2.1 » j2ee » javax.jms 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.jms.Connection

Connection
public interface Connection (Code)
A Connection object is a client's active connection to its JMS provider. It typically allocates provider resources outside the Java virtual machine (JVM).

Connections support concurrent use.

A connection serves several purposes:

  • It encapsulates an open connection with a JMS provider. It typically represents an open TCP/IP socket between a client and the service provider software.
  • Its creation is where client authentication takes place.
  • It can specify a unique client identifier.
  • It provides a ConnectionMetaData object.
  • It supports an optional ExceptionListener object.

Because the creation of a connection involves setting up authentication and communication, a connection is a relatively heavyweight object. Most clients will do all their messaging with a single connection. Other more advanced applications may use several connections. The JMS API does not architect a reason for using multiple connections; however, there may be operational reasons for doing so.

A JMS client typically creates a connection, one or more sessions, and a number of message producers and consumers. When a connection is created, it is in stopped mode. That means that no messages are being delivered.

It is typical to leave the connection in stopped mode until setup is complete (that is, until all message consumers have been created). At that point, the client calls the connection's start method, and messages begin arriving at the connection's consumers. This setup convention minimizes any client confusion that may result from asynchronous message delivery while the client is still in the process of setting itself up.

A connection can be started immediately, and the setup can be done afterwards. Clients that do this must be prepared to handle asynchronous message delivery while they are still in the process of setting up.

A message producer can send messages while a connection is stopped.
See Also:   javax.jms.ConnectionFactory
See Also:   javax.jms.QueueConnection
See Also:   javax.jms.TopicConnection





Method Summary
public  voidclose()
     Closes the connection.

Since a provider typically allocates significant resources outside the JVM on behalf of a connection, clients should close these resources when they are not needed.

public  ConnectionConsumercreateConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool sessionPool, int maxMessages)
     Creates a connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.
Parameters:
  destination - the destination to access
Parameters:
  messageSelector - only messages with properties matching themessage selector expression are delivered.
public  ConnectionConsumercreateDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages)
     Create a durable connection consumer for this connection (optional operation).
public  SessioncreateSession(boolean transacted, int acknowledgeMode)
     Creates a Session object.
Parameters:
  transacted - indicates whether the session is transacted
Parameters:
  acknowledgeMode - indicates whether the consumer or theclient will acknowledge any messages it receives; ignored if the sessionis transacted.
public  StringgetClientID()
     Gets the client identifier for this connection.

This value is specific to the JMS provider.

public  ExceptionListenergetExceptionListener()
     Gets the ExceptionListener object for this connection.
public  ConnectionMetaDatagetMetaData()
     Gets the metadata for this connection.
public  voidsetClientID(String clientID)
     Sets the client identifier for this connection.

The preferred way to assign a JMS client's client identifier is for it to be configured in a client-specific ConnectionFactory object and transparently assigned to the Connection object it creates.

Alternatively, a client can set a connection's client identifier using a provider-specific value.

public  voidsetExceptionListener(ExceptionListener listener)
     Sets an exception listener for this connection.

If a JMS provider detects a serious problem with a connection, it informs the connection's ExceptionListener, if one has been registered.

public  voidstart()
     Starts (or restarts) a connection's delivery of incoming messages.
public  voidstop()
     Temporarily stops a connection's delivery of incoming messages. Delivery can be restarted using the connection's start method.



Method Detail
close
public void close() throws JMSException(Code)
Closes the connection.

Since a provider typically allocates significant resources outside the JVM on behalf of a connection, clients should close these resources when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.

There is no need to close the sessions, producers, and consumers of a closed connection.

Closing a connection causes all temporary destinations to be deleted.

When this method is invoked, it should not return until message processing has been shut down in an orderly fashion. This means that all message listeners that may have been running have returned, and that all pending receives have returned. A close terminates all pending message receives on the connection's sessions' consumers. The receives may return with a message or with null, depending on whether there was a message available at the time of the close. If one or more of the connection's sessions' message listeners is processing a message at the time when connection close is invoked, all the facilities of the connection and its sessions must remain available to those listeners until they return control to the JMS provider.

Closing a connection causes any of its sessions' transactions in progress to be rolled back. In the case where a session's work is coordinated by an external transaction manager, a session's commit and rollback methods are not used and the result of a closed session's work is determined later by the transaction manager. Closing a connection does NOT force an acknowledgment of client-acknowledged sessions.

Invoking the acknowledge method of a received message from a closed connection's session must throw an IllegalStateException. Closing a closed connection must NOT throw an exception.
exception:
  JMSException - if the JMS provider fails to close theconnection due to some internal error. For example, a failure to release resourcesor to close a socket connection can causethis exception to be thrown.




createConnectionConsumer
public ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException(Code)
Creates a connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.
Parameters:
  destination - the destination to access
Parameters:
  messageSelector - only messages with properties matching themessage selector expression are delivered. A value of null oran empty string indicates that there is no message selector for the message consumer.
Parameters:
  sessionPool - the server session pool to associate with this connection consumer
Parameters:
  maxMessages - the maximum number of messages that can beassigned to a server session at one time the connection consumer
exception:
  JMSException - if the Connection object failsto create a connection consumer due to someinternal error or invalid arguments for sessionPool and messageSelector.
exception:
  InvalidDestinationException - if an invalid destination is specified.
exception:
  InvalidSelectorException - if the message selector is invalid.
since:
   1.1
See Also:   javax.jms.ConnectionConsumer



createDurableConnectionConsumer
public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException(Code)
Create a durable connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.
Parameters:
  topic - topic to access
Parameters:
  subscriptionName - durable subscription name
Parameters:
  messageSelector - only messages with properties matching themessage selector expression are delivered. A value of null oran empty string indicates that there is no message selector for the message consumer.
Parameters:
  sessionPool - the server session pool to associate with this durable connection consumer
Parameters:
  maxMessages - the maximum number of messages that can beassigned to a server session at one time the durable connection consumer
exception:
  JMSException - if the Connection object failsto create a connection consumer due to someinternal error or invalid arguments for sessionPool and messageSelector.
exception:
  InvalidDestinationException - if an invalid destinationis specified.
exception:
  InvalidSelectorException - if the message selector is invalid.
since:
   1.1
See Also:   javax.jms.ConnectionConsumer



createSession
public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException(Code)
Creates a Session object.
Parameters:
  transacted - indicates whether the session is transacted
Parameters:
  acknowledgeMode - indicates whether the consumer or theclient will acknowledge any messages it receives; ignored if the sessionis transacted. Legal values are Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, and Session.DUPS_OK_ACKNOWLEDGE. a newly created session
exception:
  JMSException - if the Connection object failsto create a session due to some internal error orlack of support for the specific transactionand acknowledgement mode.
since:
   1.1
See Also:   Session.AUTO_ACKNOWLEDGE
See Also:   
See Also:   Session.CLIENT_ACKNOWLEDGE
See Also:   
See Also:   Session.DUPS_OK_ACKNOWLEDGE
See Also:   



getClientID
public String getClientID() throws JMSException(Code)
Gets the client identifier for this connection.

This value is specific to the JMS provider. It is either preconfigured by an administrator in a ConnectionFactory object or assigned dynamically by the application by calling the setClientID method. the unique client identifier
exception:
  JMSException - if the JMS provider fails to returnthe client ID for this connection dueto some internal error.




getExceptionListener
public ExceptionListener getExceptionListener() throws JMSException(Code)
Gets the ExceptionListener object for this connection. Not every Connection has an ExceptionListener associated with it. the ExceptionListener for this connection, or null. if no ExceptionListener is associatedwith this connection.
exception:
  JMSException - if the JMS provider fails toget the ExceptionListener for this connection.
See Also:   javax.jms.Connection.setExceptionListener



getMetaData
public ConnectionMetaData getMetaData() throws JMSException(Code)
Gets the metadata for this connection. the connection metadata
exception:
  JMSException - if the JMS provider fails toget the connection metadata for this connection.
See Also:   javax.jms.ConnectionMetaData



setClientID
public void setClientID(String clientID) throws JMSException(Code)
Sets the client identifier for this connection.

The preferred way to assign a JMS client's client identifier is for it to be configured in a client-specific ConnectionFactory object and transparently assigned to the Connection object it creates.

Alternatively, a client can set a connection's client identifier using a provider-specific value. The facility to set a connection's client identifier explicitly is not a mechanism for overriding the identifier that has been administratively configured. It is provided for the case where no administratively specified identifier exists. If one does exist, an attempt to change it by setting it must throw an IllegalStateException. If a client sets the client identifier explicitly, it must do so immediately after it creates the connection and before any other action on the connection is taken. After this point, setting the client identifier is a programming error that should throw an IllegalStateException.

The purpose of the client identifier is to associate a connection and its objects with a state maintained on behalf of the client by a provider. The only such state identified by the JMS API is that required to support durable subscriptions.

If another connection with the same clientID is already running when this method is called, the JMS provider should detect the duplicate ID and throw an InvalidClientIDException.
Parameters:
  clientID - the unique client identifier
exception:
  JMSException - if the JMS provider fails toset the client ID for this connection dueto some internal error.
exception:
  InvalidClientIDException - if the JMS client specifies aninvalid or duplicate client ID.
exception:
  IllegalStateException - if the JMS client attempts to seta connection's client ID at the wrong time orwhen it has been administratively configured.




setExceptionListener
public void setExceptionListener(ExceptionListener listener) throws JMSException(Code)
Sets an exception listener for this connection.

If a JMS provider detects a serious problem with a connection, it informs the connection's ExceptionListener, if one has been registered. It does this by calling the listener's onException method, passing it a JMSException object describing the problem.

An exception listener allows a client to be notified of a problem asynchronously. Some connections only consume messages, so they would have no other way to learn their connection has failed.

A connection serializes execution of its ExceptionListener.

A JMS provider should attempt to resolve connection problems itself before it notifies the client of them.
Parameters:
  listener - the exception listener
exception:
  JMSException - if the JMS provider fails toset the exception listener for this connection.




start
public void start() throws JMSException(Code)
Starts (or restarts) a connection's delivery of incoming messages. A call to start on a connection that has already been started is ignored.
exception:
  JMSException - if the JMS provider fails to startmessage delivery due to some internal error.
See Also:   javax.jms.Connection.stop



stop
public void stop() throws JMSException(Code)
Temporarily stops a connection's delivery of incoming messages. Delivery can be restarted using the connection's start method. When the connection is stopped, delivery to all the connection's message consumers is inhibited: synchronous receives block, and messages are not delivered to message listeners.

This call blocks until receives and/or message listeners in progress have completed.

Stopping a connection has no effect on its ability to send messages. A call to stop on a connection that has already been stopped is ignored.

A call to stop must not return until delivery of messages has paused. This means that a client can rely on the fact that none of its message listeners will be called and that all threads of control waiting for receive calls to return will not return with a message until the connection is restarted. The receive timers for a stopped connection continue to advance, so receives may time out while the connection is stopped.

If message listeners are running when stop is invoked, the stop call must wait until all of them have returned before it may return. While these message listeners are completing, they must have the full services of the connection available to them.
exception:
  JMSException - if the JMS provider fails to stopmessage delivery due to some internal error.
See Also:   javax.jms.Connection.start




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.