站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 messaging API Documentation 英文版文档

Connection (JBoss Messaging API) - JBoss 4.0.1 sp1 messaging API Documentation 英文版文档


org.jboss.mq
Class Connection

java.lang.Object
  extended byorg.jboss.mq.Connection
All Implemented Interfaces:
javax.jms.Connection, Serializable
Direct Known Subclasses:
SpyConnection

public abstract class Connection
extends Object
implements Serializable, javax.jms.Connection

This class implements javax.jms.Connection.

It is also the gateway through wich all calls to the JMS server is done. To do its work it needs a ServerIL to invoke (@see org.jboss.mq.server.ServerIL).

The (new from february 2002) logic for clientID is the following: if logging in with a user and passwork a preconfigured clientID may be automatically delivered from the server.

If the client wants to set it's own clientID it must do so on a connection wich does not have a prefonfigured clientID and it must do so before it calls any other methods on the connection (even getClientID()). It is not allowable to use a clientID that either looks like JBossMQ internal one (beginning with ID) or a clientID that is allready in use by someone, or a clientID that is already preconfigured in the server.

If a preconfigured ID is not get, or a valid one is not set, the server will set an internal ID. This ID is NEVER possible to use for durable subscriptions. If a prefconfigured ID or one manually set is possible to use to create a durable subscriptions is governed by the security configuration of JBossMQ. In the default setup, only preconfigured clientID's are possible to use. If using a SecurityManager, permissions to create a surable subscriptions is * the resiult of a combination of the following:

- The clientID is not one of JBossMQ's internal.

- The user is authenticated and has a role that has create set to true in the security config of the destination.

Notes for JBossMQ developers: All calls, except close(), that is possible to do on a connection must call checkClientID()

Version:
$Revision: 1.44 $
Author:
Norbert Lataille (Norbert.Lataille@m4x.org), Hiram Chirino (Cojonudo14@hotmail.com), Peter Antman, Adrian Brock
See Also:
Serialized Form

Field Summary
protected  String clientID
          This is the clientID
protected  ClientILService clientILService
          The object that sets up the client IL
protected static EDU.oswego.cs.dl.util.concurrent.ClockDaemon clockDaemon
          Manages the thread that pings the connection to see if it is 'alive'
protected  boolean closing
          Set a soon as close() is called on the connection.
protected  ConnectionToken connectionToken
          The connection token is used to identify our connection to the server.
 HashMap destinationSubscriptions
          Maps a destination to a LinkedList of Subscriptions
 boolean modeStop
          Is the connection stopped ?
protected  long pingPeriod
          How often to ping the connection
protected  boolean ponged
          This feild is reset when a ping is sent, set when ponged.
protected  ServerIL serverIL
          This is our connection to the JMS server
 HashMap subscriptions
          Maps a a subsction id to a Subscription
 
Method Summary
protected  void askForAnID()
          Ask the server for an id
protected  void askForAnID(String userName, String password)
          Ask the server for an id
 void asynchClose()
          Notification from the server that the connection is closed
 void asynchDeleteTemporaryDestination(SpyDestination dest)
          Called by a TemporaryDestination which is going to be deleted()
 void asynchDeliver(ReceiveRequest[] requests)
          Gets the first consumer that is listening to a destination.
 void asynchFailure(String reason, Exception e)
          Notification of a failure on this connection
 void asynchPong(long serverTime)
          Invoked when the server pong us
protected  void authenticate(String userName, String password)
          Authenticate a user
protected  void checkClientID()
          Check that a clientID exists.
 void close()
           
 void deleteTemporaryDestination(SpyDestination dest)
          Called by a TemporaryDestination which is going to be deleted
 void doStop()
          Stop delivery
 String getClientID()
           
 javax.jms.ExceptionListener getExceptionListener()
           
 javax.jms.ConnectionMetaData getMetaData()
           
 ServerIL getServerIL()
          Gets the ServerIL attribute of the Connection object
static ThreadGroup getThreadGroup()
           
protected  void send(AcknowledgementRequest item)
          Acknowledge/Nack a message
protected  void send(TransactionRequest transaction)
          Commit/rollback
 void setClientID(String cID)
           
 void setExceptionListener(javax.jms.ExceptionListener listener)
           
 void start()
           
protected  void startILService()
          Start the il
 void stop()
           
protected  void stopILService()
          Stop the il
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.jms.Connection
createConnectionConsumer, createDurableConnectionConsumer, createSession
 

Field Detail

clockDaemon

protected static EDU.oswego.cs.dl.util.concurrent.ClockDaemon clockDaemon
Manages the thread that pings the connection to see if it is 'alive'


destinationSubscriptions

public HashMap destinationSubscriptions
Maps a destination to a LinkedList of Subscriptions


subscriptions

public HashMap subscriptions
Maps a a subsction id to a Subscription


modeStop

public boolean modeStop
Is the connection stopped ?


serverIL

protected ServerIL serverIL
This is our connection to the JMS server


clientID

protected String clientID
This is the clientID


connectionToken

protected ConnectionToken connectionToken
The connection token is used to identify our connection to the server.


clientILService

protected ClientILService clientILService
The object that sets up the client IL


pingPeriod

protected long pingPeriod
How often to ping the connection


ponged

protected boolean ponged
This feild is reset when a ping is sent, set when ponged.


closing

protected volatile boolean closing
Set a soon as close() is called on the connection.

Method Detail

getThreadGroup

public static ThreadGroup getThreadGroup()

getServerIL

public ServerIL getServerIL()
Gets the ServerIL attribute of the Connection object

Returns:
The ServerIL value

asynchClose

public void asynchClose()
Notification from the server that the connection is closed


asynchDeleteTemporaryDestination

public void asynchDeleteTemporaryDestination(SpyDestination dest)
Called by a TemporaryDestination which is going to be deleted()

Parameters:
dest - the temporary destination

asynchDeliver

public void asynchDeliver(ReceiveRequest[] requests)
Gets the first consumer that is listening to a destination.

Parameters:
requests - the receive requests

asynchFailure

public void asynchFailure(String reason,
                          Exception e)
Notification of a failure on this connection

Parameters:
reason - the reason for the failure
e - the exception

asynchPong

public void asynchPong(long serverTime)
Invoked when the server pong us

Parameters:
serverTime - the server time

deleteTemporaryDestination

public void deleteTemporaryDestination(SpyDestination dest)
                                throws javax.jms.JMSException
Called by a TemporaryDestination which is going to be deleted

Parameters:
dest - the temporary destination
Throws:
javax.jms.JMSException - for any error

setClientID

public void setClientID(String cID)
                 throws javax.jms.JMSException
Specified by:
setClientID in interface javax.jms.Connection
Throws:
javax.jms.JMSException

getClientID

public String getClientID()
                   throws javax.jms.JMSException
Specified by:
getClientID in interface javax.jms.Connection
Throws:
javax.jms.JMSException

getExceptionListener

public javax.jms.ExceptionListener getExceptionListener()
                                                 throws javax.jms.JMSException
Specified by:
getExceptionListener in interface javax.jms.Connection
Throws:
javax.jms.JMSException

setExceptionListener

public void setExceptionListener(javax.jms.ExceptionListener listener)
                          throws javax.jms.JMSException
Specified by:
setExceptionListener in interface javax.jms.Connection
Throws:
javax.jms.JMSException

getMetaData

public javax.jms.ConnectionMetaData getMetaData()
                                         throws javax.jms.JMSException
Specified by:
getMetaData in interface javax.jms.Connection
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Specified by:
close in interface javax.jms.Connection
Throws:
javax.jms.JMSException

start

public void start()
           throws javax.jms.JMSException
Specified by:
start in interface javax.jms.Connection
Throws:
javax.jms.JMSException

stop

public void stop()
          throws javax.jms.JMSException
Specified by:
stop in interface javax.jms.Connection
Throws:
javax.jms.JMSException

toString

public String toString()

checkClientID

protected void checkClientID()
                      throws javax.jms.JMSException
Check that a clientID exists. If not get one from server. Also sets the setClientIdAllowed to false. Check clientId, must be called by all public methods on the jacax.jmx.Connection interface and its children.

Throws:
javax.jms.JMSException - if clientID is null as post condition

askForAnID

protected void askForAnID()
                   throws javax.jms.JMSException
Ask the server for an id

Throws:
javax.jms.JMSException - for any error

askForAnID

protected void askForAnID(String userName,
                          String password)
                   throws javax.jms.JMSException
Ask the server for an id

Parameters:
userName - the user
password - the password
Throws:
javax.jms.JMSException - for any error

authenticate

protected void authenticate(String userName,
                            String password)
                     throws javax.jms.JMSException
Authenticate a user

Parameters:
userName - the user
password - the password
Throws:
javax.jms.JMSException - for any error

send

protected void send(AcknowledgementRequest item)
             throws javax.jms.JMSException
Acknowledge/Nack a message

Parameters:
item - the acknowledgement
Throws:
javax.jms.JMSException - for any error

send

protected void send(TransactionRequest transaction)
             throws javax.jms.JMSException
Commit/rollback

Parameters:
transaction - the transaction request
Throws:
javax.jms.JMSException - for any error

startILService

protected void startILService()
                       throws javax.jms.JMSException
Start the il

Throws:
javax.jms.JMSException - for any error

stopILService

protected void stopILService()
                      throws javax.jms.JMSException
Stop the il

Throws:
javax.jms.JMSException - for any error

doStop

public void doStop()
            throws javax.jms.JMSException
Stop delivery

Throws:
javax.jms.JMSException


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.