org.exolab.jms.client.http
Class HttpJmsSessionStub

java.lang.Object
  |
  +--org.exolab.jms.client.http.HttpJmsSessionStub
All Implemented Interfaces:
JmsSessionStubIfc, org.exolab.core.ipc.NotifierIfc

public class HttpJmsSessionStub
extends java.lang.Object
implements JmsSessionStubIfc, org.exolab.core.ipc.NotifierIfc

The client side stub implementing the JmsServerSession. All session requests are passed on to the server.

Version:
$Revision: 1.16 $ $Date: 2003/08/25 03:35:45 $
Author:
Jim Mourikis
See Also:
HttpClient

Constructor Summary
HttpJmsSessionStub(org.exolab.core.ipc.IpcIfc connection, java.lang.String clientId, java.lang.String connectionId, java.lang.String sessionId)
          A new session has been established with these ids.
 
Method Summary
 void acknowledgeMessage(long clientId, java.lang.String messageId)
          Acknowledge a message
 void beforeClose()
          This method is called before the call to close, so that the stub can do some local clean up
 void close()
          Close this session.
 void commit()
          Commit the session which will send all the published messages and acknowledge all received messages
 void commit(javax.transaction.xa.Xid xid, boolean onePhase)
          Commits an XA transaction that is in progress.
 void createBrowser(JmsQueue queue, long clientId, java.lang.String selector)
          Create a queue browser for this session.
 void createPublisher(JmsTopic topic)
          Create a new topic publisher
 void createQueue(JmsQueue queue)
          Create a new queue
 void createReceiver(JmsQueue queue, long clientId, java.lang.String selector)
          Create a receiver.
 void createSender(JmsQueue queue)
          Create a queue sender
 void createSubscriber(JmsTopic topic, java.lang.String name, long clientId, java.lang.String selector, boolean noLocal)
          Create a new topic subscriber
 void createTopic(JmsTopic topic)
          Create a new topic
 void deleteBrowser(long clientId)
          Delete the queue browser associated with the specified queue from the session.
 void deleteReceiver(long clientId)
          Delete the receiver for this queue.
 void deleteSubscriber(long clientId)
          Delete the subscriber for this topic
 void disconnection(java.lang.String id)
          A client has disconnected.
 void enableAsynchronousDelivery(long clientId, java.lang.String id, boolean enable)
          Enable or disable asynchronous message delivery for a particular consumer
 void end(javax.transaction.xa.Xid xid, int flags)
          Ends the work performed on behalf of a transaction branch.
 void forget(javax.transaction.xa.Xid xid)
          Tell the resource manager to forget about a heuristically completed transaction branch.
 java.lang.String getClientId()
          Get the client Id
 java.lang.String getResourceManagerId()
          Return the identity of the associated resource manager.
 java.lang.String getSessionId()
          Get the sessionId
 int getTransactionTimeout()
          Return the transaction timeout for this instance of the resource manager.
 java.io.Serializable notify(java.lang.Object ob, java.lang.String id)
          A message has been received.
 int prepare(javax.transaction.xa.Xid xid)
          Ask the resource manager to prepare for a transaction commit of the transaction specified in xid
 javax.jms.Message receiveMessage(long clientId, long wait)
          Return the next message for the specified client.
 java.util.Vector receiveMessages(long clientId, int count)
          Return a collection of messages from the specified client upto the nominated count.
 void recover()
          Recover the session.
 javax.transaction.xa.Xid[] recover(int flag)
          Obtain a list of prepared transaction branches from a resource manager.
 void rollback()
          Rollback the session, which will not acknowledge any of the sent messages
 void rollback(javax.transaction.xa.Xid xid)
          Inform the resource manager to roll back work done on behalf of a transaction branch
 void sendMessage(javax.jms.Message message)
          Send the specified message to the server.
 void sendMessages(java.util.Vector messages)
          Send the specified messages to the server.
 void setMessageListener(JmsMessageListener listener)
          Set a message listener to be called when new Messages arrive from the server.
 boolean setTransactionTimeout(int seconds)
          Set the current transaction timeout value for this XAResource instance.
 void start(javax.transaction.xa.Xid xid, int flags)
          Start work on behalf of a transaction branch specified in xid If TMJOIN is specified, the start is for joining a transaction previously seen by the resource manager
 void startMessageDelivery()
          Start message delivery for this session.
 void stopMessageDelivery()
          Stop message delivery for this session.
 void stopReceiver()
          Stop the message receiver thread.
 void unsubscribe(java.lang.String name)
          Unsubscribe a durable subscription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpJmsSessionStub

public HttpJmsSessionStub(org.exolab.core.ipc.IpcIfc connection,
                          java.lang.String clientId,
                          java.lang.String connectionId,
                          java.lang.String sessionId)
A new session has been established with these ids.
Parameters:
connection - The http connection to the server.
clientId - This clients unique id.
connectionId - This objects connection identifier.
sessionId - The unique session id for this object.
Method Detail

getClientId

public java.lang.String getClientId()
Get the client Id
Specified by:
getClientId in interface JmsSessionStubIfc
Returns:
the client id

getSessionId

public java.lang.String getSessionId()
Get the sessionId
Specified by:
getSessionId in interface JmsSessionStubIfc
Returns:
the id of this session

beforeClose

public void beforeClose()
                 throws javax.jms.JMSException
Description copied from interface: JmsSessionStubIfc
This method is called before the call to close, so that the stub can do some local clean up
Specified by:
beforeClose in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Throws:
javax.jms.JMSException - for any JMS error

close

public void close()
           throws javax.jms.JMSException
Close this session.
Specified by:
close in interface JmsSessionStubIfc
Throws:
javax.jms.JMSException - if the close fails

acknowledgeMessage

public void acknowledgeMessage(long clientId,
                               java.lang.String messageId)
                        throws javax.jms.JMSException
Acknowledge a message
Specified by:
acknowledgeMessage in interface JmsSessionStubIfc
Parameters:
clientId - the identity of the client
messageId - the message identity to ack
Throws:
javax.jms.JMSException - if the message can't be acknowledged

sendMessage

public void sendMessage(javax.jms.Message message)
                 throws javax.jms.JMSException
Description copied from interface: JmsSessionStubIfc
Send the specified message to the server. If there is any problem then throw the JMSException exception
Specified by:
sendMessage in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
message - the message to send
Throws:
javax.jms.JMSException - for any JMS error

sendMessages

public void sendMessages(java.util.Vector messages)
                  throws javax.jms.JMSException
Description copied from interface: JmsSessionStubIfc
Send the specified messages to the server. If there is any problem then throw the JMSException exception
Specified by:
sendMessages in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
messages - the messages to send
Throws:
javax.jms.JMSException - for any JMS error

receiveMessage

public javax.jms.Message receiveMessage(long clientId,
                                        long wait)
                                 throws javax.jms.JMSException
Description copied from interface: JmsSessionStubIfc
Return the next message for the specified client. The client id maps to a consumer on the server side. The caller can also specify how long to wait if no messages are currently available. If the caller specifies 0 then the call will return immediately if there are no messages available. If the caller specified -1 then the call will block until a message becomes available.
Specified by:
receiveMessage in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
clientId - the client identity
wait - the number of ms to wait. -1 means wait indefinitely.
Returns:
the next message or null
Throws:
javax.jms.JMSException - for any JMS error

receiveMessages

public java.util.Vector receiveMessages(long clientId,
                                        int count)
                                 throws javax.jms.JMSException
Description copied from interface: JmsSessionStubIfc
Return a collection of messages from the specified client upto the nominated count. This method may return less than count messages but it will never return more than count messages
Specified by:
receiveMessages in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
client - the client identity
count - max messages to return
Returns:
collection of MessageImpl objects
Throws:
javax.jms.JMSException - for any JMS error

createQueue

public void createQueue(JmsQueue queue)
                 throws javax.jms.JMSException
Create a new queue
Specified by:
createQueue in interface JmsSessionStubIfc
Parameters:
topic - the queue to create
Throws:
javax.jms.JMSException - if the queue can't be created

createTopic

public void createTopic(JmsTopic topic)
                 throws javax.jms.JMSException
Create a new topic
Specified by:
createTopic in interface JmsSessionStubIfc
Parameters:
topic - the topic to create
Throws:
javax.jms.JMSException - if the topic can't be created

createReceiver

public void createReceiver(JmsQueue queue,
                           long clientId,
                           java.lang.String selector)
                    throws javax.jms.JMSException
Create a receiver. Get the IP address of the machine the consumer runs on, and the port it is listening to, and pass this to the server, so it can make a new dedicated connection for sending all messages to this client.
Specified by:
createReceiver in interface JmsSessionStubIfc
Parameters:
queue - the queue to listen to
clientId - the session allocated identifier
selector - the selector to filter messages (may be null)
Throws:
javax.jms.JMSException - if the receiver cannot be created

createSender

public void createSender(JmsQueue queue)
                  throws javax.jms.JMSException
Create a queue sender
Specified by:
createSender in interface JmsSessionStubIfc
Parameters:
queue - the queue to send messages to
Throws:
javax.jms.JMSException - if the sender cannot be created

createBrowser

public void createBrowser(JmsQueue queue,
                          long clientId,
                          java.lang.String selector)
                   throws javax.jms.JMSException
Create a queue browser for this session. This allows clients to browse a queue without removing any messages.
Specified by:
createBrowser in interface JmsSessionStubIfc
Parameters:
queue - the queue to browse
clientId - the identity of the client
selector - the message selector. May be null
Throws:
javax.jms.JMSException - if the browser can't be created

deleteReceiver

public void deleteReceiver(long clientId)
                    throws javax.jms.JMSException
Delete the receiver for this queue.
Specified by:
deleteReceiver in interface JmsSessionStubIfc
Parameters:
clientId - the id of the client to delete
Throws:
javax.jms.JMSException - if the receiver cannot be deleted

deleteBrowser

public void deleteBrowser(long clientId)
                   throws javax.jms.JMSException
Delete the queue browser associated with the specified queue from the session.
Specified by:
deleteBrowser in interface JmsSessionStubIfc
Parameters:
clientId - the identity of the browser
Throws:
javax.jms.JMSException - if the browser cannot be deleted

createSubscriber

public void createSubscriber(JmsTopic topic,
                             java.lang.String name,
                             long clientId,
                             java.lang.String selector,
                             boolean noLocal)
                      throws javax.jms.JMSException
Create a new topic subscriber
Specified by:
createSubscriber in interface JmsSessionStubIfc
Parameters:
topic - the topic to subscribe to
name - the subscribers name
client - the client identity
selector - the selector to filter messages (may be null)
Throws:
javax.jms.JMSException - if the topic subscriber can't be created

createPublisher

public void createPublisher(JmsTopic topic)
                     throws javax.jms.JMSException
Create a new topic publisher
Specified by:
createPublisher in interface JmsSessionStubIfc
Parameters:
topic - the topic to publish to
Throws:
javax.jms.JMSException - if the publisher can't be created

unsubscribe

public void unsubscribe(java.lang.String name)
                 throws javax.jms.JMSException
Unsubscribe a durable subscription
Specified by:
unsubscribe in interface JmsSessionStubIfc
Parameters:
name - the name used to identify the subscription
Throws:
javax.jms.JMSException - if the subscription cannot be removed

deleteSubscriber

public void deleteSubscriber(long clientId)
                      throws javax.jms.JMSException
Delete the subscriber for this topic
Specified by:
deleteSubscriber in interface JmsSessionStubIfc
Parameters:
clientId - the client identity
Throws:
javax.jms.JMSException - for any error

stopMessageDelivery

public void stopMessageDelivery()
                         throws javax.jms.JMSException
Stop message delivery for this session.
Specified by:
stopMessageDelivery in interface JmsSessionStubIfc
Throws:
javax.jms.JMSException - for any error

startMessageDelivery

public void startMessageDelivery()
                          throws javax.jms.JMSException
Start message delivery for this session.
Specified by:
startMessageDelivery in interface JmsSessionStubIfc
Throws:
javax.jms.JMSException - for any error

recover

public void recover()
             throws javax.jms.JMSException
Description copied from interface: JmsSessionStubIfc
Recover the session. This means all unacknowledged messages are resent with the redelivery flag set
Specified by:
recover in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Throws:
javax.jms.JMSException - if the session cannot be recovered

commit

public void commit()
            throws javax.jms.JMSException
Description copied from interface: JmsSessionStubIfc
Commit the session which will send all the published messages and acknowledge all received messages
Specified by:
commit in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Throws:
javax.jms.JMSException - if the session cannot be committed

rollback

public void rollback()
              throws javax.jms.JMSException
Description copied from interface: JmsSessionStubIfc
Rollback the session, which will not acknowledge any of the sent messages
Specified by:
rollback in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Throws:
javax.jms.JMSException - if the session cannot be rolled back

commit

public void commit(javax.transaction.xa.Xid xid,
                   boolean onePhase)
            throws javax.transaction.xa.XAException
Description copied from interface: JmsSessionStubIfc
Commits an XA transaction that is in progress.
Specified by:
commit in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
xid - the xa transaction identity
onePhase - true if it is a one phase commit
Throws:
javax.transaction.xa.XAException - if there is a problem completing the call

end

public void end(javax.transaction.xa.Xid xid,
                int flags)
         throws javax.transaction.xa.XAException
Description copied from interface: JmsSessionStubIfc
Ends the work performed on behalf of a transaction branch. The resource manager disassociates the XA resource from the transaction branch specified and let the transaction be completedCommits an XA transaction that is in progress.
Specified by:
end in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
xid - the xa transaction identity
flags - one of TMSUCCESS, TMFAIL, or TMSUSPEND
Throws:
javax.transaction.xa.XAException - if there is a problem completing the call

forget

public void forget(javax.transaction.xa.Xid xid)
            throws javax.transaction.xa.XAException
Description copied from interface: JmsSessionStubIfc
Tell the resource manager to forget about a heuristically completed transaction branch.
Specified by:
forget in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
xid - the xa transaction identity
Throws:
javax.transaction.xa.XAException - if there is a problem completing the call

getTransactionTimeout

public int getTransactionTimeout()
                          throws javax.transaction.xa.XAException
Description copied from interface: JmsSessionStubIfc
Return the transaction timeout for this instance of the resource manager.
Specified by:
getTransactionTimeout in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Returns:
the timeout in seconds
Throws:
javax.transaction.xa.XAException - if there is a problem completing the call

prepare

public int prepare(javax.transaction.xa.Xid xid)
            throws javax.transaction.xa.XAException
Description copied from interface: JmsSessionStubIfc
Ask the resource manager to prepare for a transaction commit of the transaction specified in xid
Specified by:
prepare in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
xid - the xa transaction identity
Returns:
XA_RDONLY or XA_OK
Throws:
javax.transaction.xa.XAException - if there is a problem completing the call

recover

public javax.transaction.xa.Xid[] recover(int flag)
                                   throws javax.transaction.xa.XAException
Description copied from interface: JmsSessionStubIfc
Obtain a list of prepared transaction branches from a resource manager. The transaction manager calls this method during recovery to obtain the list of transaction branches that are currently in prepared or heuristically completed states.
Specified by:
recover in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
flag - One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS
Returns:
the set of Xids to recover
Throws:
javax.transaction.xa.XAException - - if there is a problem completing the call

rollback

public void rollback(javax.transaction.xa.Xid xid)
              throws javax.transaction.xa.XAException
Description copied from interface: JmsSessionStubIfc
Inform the resource manager to roll back work done on behalf of a transaction branch
Specified by:
rollback in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
xid - the xa transaction identity
Throws:
javax.transaction.xa.XAException - if there is a problem completing the call

setTransactionTimeout

public boolean setTransactionTimeout(int seconds)
                              throws javax.transaction.xa.XAException
Description copied from interface: JmsSessionStubIfc
Set the current transaction timeout value for this XAResource instance.
Specified by:
setTransactionTimeout in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
seconds - timeout in seconds
Returns:
if the new transaction timeout was accepted
Throws:
javax.transaction.xa.XAException - if there is a problem completing the call

start

public void start(javax.transaction.xa.Xid xid,
                  int flags)
           throws javax.transaction.xa.XAException
Description copied from interface: JmsSessionStubIfc
Start work on behalf of a transaction branch specified in xid If TMJOIN is specified, the start is for joining a transaction previously seen by the resource manager
Specified by:
start in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
xid - the xa transaction identity
flags - One of TMNOFLAGS, TMJOIN, or TMRESUME
Throws:
javax.transaction.xa.XAException - if there is a problem completing the call

getResourceManagerId

public java.lang.String getResourceManagerId()
                                      throws javax.transaction.xa.XAException
Description copied from interface: JmsSessionStubIfc
Return the identity of the associated resource manager.
Specified by:
getResourceManagerId in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Returns:
the identity of the resource manager
Throws:
javax.transaction.xa.XAException - if there is a problem completing the call

setMessageListener

public void setMessageListener(JmsMessageListener listener)
Set a message listener to be called when new Messages arrive from the server.
Specified by:
setMessageListener in interface JmsSessionStubIfc
Parameters:
listener - A reference to the client listener.

enableAsynchronousDelivery

public void enableAsynchronousDelivery(long clientId,
                                       java.lang.String id,
                                       boolean enable)
                                throws javax.jms.JMSException
Description copied from interface: JmsSessionStubIfc
Enable or disable asynchronous message delivery for a particular consumer
Specified by:
enableAsynchronousDelivery in interface JmsSessionStubIfc
Following copied from interface: org.exolab.jms.client.JmsSessionStubIfc
Parameters:
clientId - the id of the client to check
id - the message id of the last delivered message
enable - true to enable; false to disable
Throws:
javax.jms.JMSException - for any JMS error

stopReceiver

public void stopReceiver()
Stop the message receiver thread.

notify

public java.io.Serializable notify(java.lang.Object ob,
                                   java.lang.String id)
A message has been received.
Specified by:
notify in interface org.exolab.core.ipc.NotifierIfc
Parameters:
ob - The data received,
id - The connection id this data is received from
Returns:
any requested result, or null, nothing is sent back to the client

disconnection

public void disconnection(java.lang.String id)
A client has disconnected. Notify the caller.
Specified by:
disconnection in interface org.exolab.core.ipc.NotifierIfc
Parameters:
The - unique identifier of this connection.


Copyright © 1999-2004 The OpenJMS Group. All Rights Reserved.