[jboss-cvs] JBoss Messaging SVN: r3674 - in trunk: src/etc/server/default/deploy and 39 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 7 13:21:27 EST 2008


Author: timfox
Date: 2008-02-07 13:21:26 -0500 (Thu, 07 Feb 2008)
New Revision: 3674

Added:
   trunk/src/main/org/jboss/jms/client/api/FailureListener.java
   trunk/src/main/org/jboss/jms/client/impl/ClientConnectionInternal.java
   trunk/src/main/org/jboss/jms/client/impl/ClientConsumerInternal.java
   trunk/src/main/org/jboss/jms/client/impl/ClientSessionInternal.java
   trunk/src/main/org/jboss/jms/exception/JMSExceptionHelper.java
   trunk/src/main/org/jboss/jms/server/endpoint/MessagingServerPacketHandler.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerPacketHandlerSupport.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionCreateSessionMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionCreateSessionResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConnectionMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConnectionResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionAddAddressMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBindingQueryMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBindingQueryResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserHasNextMessageResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserNextMessageBlockMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserNextMessageBlockResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserNextMessageResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateBrowserMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateBrowserResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateConsumerMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateConsumerResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateQueueMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionDeleteQueueMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionQueueQueryMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionQueueQueryResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionRemoveAddressMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionSetIDMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetInDoubtXidsResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetTimeoutResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionCreateSessionMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionCreateSessionResponseMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionStartMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionStopMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/MessagingExceptionMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionAddAddressMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBindingQueryMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBindingQueryResponseMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserHasNextMessageMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserHasNextMessageResponseMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageBlockMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageBlockResponseMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageResponseMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserResetMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateBrowserMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateBrowserResponseMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateConsumerMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateConsumerResponseMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateQueueMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionDeleteQueueMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionQueueQueryMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionQueueQueryResponseMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionRemoveAddressMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionSetIDMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsResponseMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutResponseMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResponseMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutResponseMessage.java
   trunk/src/main/org/jboss/messaging/util/MessagingException.java
Removed:
   trunk/src/main/org/jboss/jms/client/remoting/ConsolidatedRemotingConnectionListener.java
   trunk/src/main/org/jboss/jms/destination/JBossTemporaryQueue.java
   trunk/src/main/org/jboss/jms/destination/JBossTemporaryTopic.java
   trunk/src/main/org/jboss/jms/exception/MessagingJMSException.java
   trunk/src/main/org/jboss/jms/exception/MessagingNetworkFailureException.java
   trunk/src/main/org/jboss/jms/exception/MessagingShutdownException.java
   trunk/src/main/org/jboss/jms/exception/MessagingTransactionRolledBackException.java
   trunk/src/main/org/jboss/jms/exception/MessagingXAException.java
   trunk/src/main/org/jboss/jms/server/TransactionRepository.java
   trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryAdvisedPacketHandler.java
   trunk/src/main/org/jboss/messaging/core/Condition.java
   trunk/src/main/org/jboss/messaging/core/Destination.java
   trunk/src/main/org/jboss/messaging/core/impl/ConditionImpl.java
   trunk/src/main/org/jboss/messaging/core/impl/DestinationImpl.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/AddTemporaryDestinationMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserHasNextMessageResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockRequestCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionFactoryCreateConnectionRequestCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionFactoryCreateConnectionResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateBrowserRequestCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateBrowserResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConsumerRequestCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConsumerResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateDestinationRequestCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateDestinationResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateSessionRequestCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateSessionResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/DeleteTemporaryDestinationMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/GetClientIDResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/JMSExceptionMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetInDoubtXidsResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetTimeoutResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutResponseCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SetClientIDMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SetSessionIDMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/UnsubscribeMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/AddTemporaryDestinationMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserHasNextMessageRequest.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserHasNextMessageResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageRequest.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserResetMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ClosingMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateBrowserRequest.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateBrowserResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConsumerRequest.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConsumerResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateDestinationRequest.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateDestinationResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateSessionRequest.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateSessionResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/DeleteTemporaryDestinationMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientIDRequest.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientIDResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/JMSExceptionMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsRequest.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SetClientIDMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SetSessionIDMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/StartConnectionMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/StopConnectionMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/UnsubscribeMessage.java
Modified:
   trunk/docs/examples/common/src/org/jboss/example/jms/common/ExampleSupport.java
   trunk/src/etc/server/default/deploy/jbm-configuration.xml
   trunk/src/main/org/jboss/jms/client/JBossConnection.java
   trunk/src/main/org/jboss/jms/client/JBossConnectionConsumer.java
   trunk/src/main/org/jboss/jms/client/JBossConnectionFactory.java
   trunk/src/main/org/jboss/jms/client/JBossMessageConsumer.java
   trunk/src/main/org/jboss/jms/client/JBossMessageProducer.java
   trunk/src/main/org/jboss/jms/client/JBossQueueBrowser.java
   trunk/src/main/org/jboss/jms/client/JBossSession.java
   trunk/src/main/org/jboss/jms/client/JMSMessageListenerWrapper.java
   trunk/src/main/org/jboss/jms/client/api/ClientBrowser.java
   trunk/src/main/org/jboss/jms/client/api/ClientConnection.java
   trunk/src/main/org/jboss/jms/client/api/ClientConnectionFactory.java
   trunk/src/main/org/jboss/jms/client/api/ClientConsumer.java
   trunk/src/main/org/jboss/jms/client/api/ClientProducer.java
   trunk/src/main/org/jboss/jms/client/api/ClientSession.java
   trunk/src/main/org/jboss/jms/client/impl/ClientBrowserImpl.java
   trunk/src/main/org/jboss/jms/client/impl/ClientConnectionFactoryImpl.java
   trunk/src/main/org/jboss/jms/client/impl/ClientConnectionImpl.java
   trunk/src/main/org/jboss/jms/client/impl/ClientConsumerImpl.java
   trunk/src/main/org/jboss/jms/client/impl/ClientConsumerPacketHandler.java
   trunk/src/main/org/jboss/jms/client/impl/ClientProducerImpl.java
   trunk/src/main/org/jboss/jms/client/impl/ClientSessionImpl.java
   trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java
   trunk/src/main/org/jboss/jms/client/remoting/MessagingRemotingConnection.java
   trunk/src/main/org/jboss/jms/destination/JBossDestination.java
   trunk/src/main/org/jboss/jms/destination/JBossQueue.java
   trunk/src/main/org/jboss/jms/destination/JBossTopic.java
   trunk/src/main/org/jboss/jms/jndi/JNDIObjectDeployer.java
   trunk/src/main/org/jboss/jms/message/JBossBytesMessage.java
   trunk/src/main/org/jboss/jms/message/JBossMessage.java
   trunk/src/main/org/jboss/jms/server/SecurityStore.java
   trunk/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java
   trunk/src/main/org/jboss/jms/server/container/SecurityAspect.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
   trunk/src/main/org/jboss/jms/server/recovery/MessagingXAResourceWrapper.java
   trunk/src/main/org/jboss/jms/server/security/SecurityMetadataStore.java
   trunk/src/main/org/jboss/messaging/core/Binding.java
   trunk/src/main/org/jboss/messaging/core/Configuration.java
   trunk/src/main/org/jboss/messaging/core/Delivery.java
   trunk/src/main/org/jboss/messaging/core/FileConfiguration.java
   trunk/src/main/org/jboss/messaging/core/Message.java
   trunk/src/main/org/jboss/messaging/core/MessagingServer.java
   trunk/src/main/org/jboss/messaging/core/MessagingServerManagement.java
   trunk/src/main/org/jboss/messaging/core/PostOffice.java
   trunk/src/main/org/jboss/messaging/core/Queue.java
   trunk/src/main/org/jboss/messaging/core/impl/BindingImpl.java
   trunk/src/main/org/jboss/messaging/core/impl/DeliveryImpl.java
   trunk/src/main/org/jboss/messaging/core/impl/MessageReferenceImpl.java
   trunk/src/main/org/jboss/messaging/core/impl/PriorityLinkedListImpl.java
   trunk/src/main/org/jboss/messaging/core/impl/QueueImpl.java
   trunk/src/main/org/jboss/messaging/core/impl/TransactionImpl.java
   trunk/src/main/org/jboss/messaging/core/impl/bdbje/BDBJEPersistenceManager.java
   trunk/src/main/org/jboss/messaging/core/impl/filter/FilterImpl.java
   trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessageRequest.java
   trunk/src/main/org/jboss/messaging/core/impl/postoffice/PostOfficeImpl.java
   trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java
   trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerManagementImpl.java
   trunk/src/main/org/jboss/messaging/core/remoting/Client.java
   trunk/src/main/org/jboss/messaging/core/remoting/Interceptor.java
   trunk/src/main/org/jboss/messaging/core/remoting/NIOConnector.java
   trunk/src/main/org/jboss/messaging/core/remoting/NIOSession.java
   trunk/src/main/org/jboss/messaging/core/remoting/PacketDispatcher.java
   trunk/src/main/org/jboss/messaging/core/remoting/PacketSender.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/ConsumerChangeRateMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/DeliverMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionAcknowledgeMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCancelMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionSendMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXACommitMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAEndMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAForgetMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAJoinMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAPrepareMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResumeMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXARollbackMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAStartMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/ClientImpl.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/INVMConnector.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/INVMSession.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaSession.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CloseMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConsumerChangeRateMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConnectionRequest.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConnectionResponse.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/DeliverMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionAcknowledgeMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCancelMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCommitMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionRecoverMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionRollbackMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionSendMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXACommitMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAEndMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAForgetMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAJoinMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAPrepareMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResumeMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXARollbackMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAStartMessage.java
   trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASuspendMessage.java
   trunk/src/main/org/jboss/messaging/util/ExceptionUtil.java
   trunk/tests/src/org/jboss/jms/server/test/unit/ConfigurationTest.java
   trunk/tests/src/org/jboss/messaging/core/impl/bdbje/test/unit/BDBJEPersistenceManagerTest.java
   trunk/tests/src/org/jboss/messaging/core/impl/filter/test/unit/FilterTest.java
   trunk/tests/src/org/jboss/messaging/core/impl/postoffice/test/unit/PostOfficeTest.java
   trunk/tests/src/org/jboss/messaging/core/impl/test/unit/QueueTest.java
   trunk/tests/src/org/jboss/messaging/core/remoting/impl/mina/integration/test/ReversePacketHandler.java
   trunk/tests/src/org/jboss/messaging/core/remoting/test/unit/ClientTest.java
   trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/PacketTypeTest.java
   trunk/tests/src/org/jboss/test/messaging/JBMBaseTestCase.java
   trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java
   trunk/tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/DLQTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/TopicTest.java
   trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
   trunk/tests/src/org/jboss/test/messaging/tools/container/MBeanServerBuilder.java
   trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
   trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java
Log:
Core refactoring


Modified: trunk/docs/examples/common/src/org/jboss/example/jms/common/ExampleSupport.java
===================================================================
--- trunk/docs/examples/common/src/org/jboss/example/jms/common/ExampleSupport.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/docs/examples/common/src/org/jboss/example/jms/common/ExampleSupport.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -39,7 +39,7 @@
       
       JBossConnection jbconn = (JBossConnection)conn;
       
-      ClientConnection del = jbconn.getDelegate();
+      ClientConnection del = jbconn.getConnection();
       
       return del.getServerID();
    }

Modified: trunk/src/etc/server/default/deploy/jbm-configuration.xml
===================================================================
--- trunk/src/etc/server/default/deploy/jbm-configuration.xml	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/etc/server/default/deploy/jbm-configuration.xml	2008-02-07 18:21:26 UTC (rev 3674)
@@ -32,7 +32,7 @@
            THIS SHOULD ALWAYS BE CHANGED AT INSTALL TIME TO SECURE SYSTEM
       <sucker-password></sucker-password>
       -->
-      <strict-tck>false</strict-tck>
+      <strict-tck>true</strict-tck>
       <post-office-name>JMS post office</post-office-name>
 
       <clustered>false</clustered>

Modified: trunk/src/main/org/jboss/jms/client/JBossConnection.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossConnection.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/JBossConnection.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -26,6 +26,7 @@
 import javax.jms.ConnectionMetaData;
 import javax.jms.Destination;
 import javax.jms.ExceptionListener;
+import javax.jms.IllegalStateException;
 import javax.jms.JMSException;
 import javax.jms.Queue;
 import javax.jms.QueueConnection;
@@ -44,6 +45,12 @@
 
 import org.jboss.jms.client.api.ClientConnection;
 import org.jboss.jms.client.api.ClientSession;
+import org.jboss.jms.client.api.FailureListener;
+import org.jboss.jms.client.impl.ClientConnectionInternal;
+import org.jboss.jms.exception.JMSExceptionHelper;
+import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
+import org.jboss.messaging.util.Version;
 
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -58,24 +65,50 @@
 {
 
    // Constants ------------------------------------------------------------------------------------
+   
+   private static final Logger log = Logger.getLogger(JBossConnection.class);
 
+
    static final int TYPE_GENERIC_CONNECTION = 0;
+   
    static final int TYPE_QUEUE_CONNECTION = 1;
+   
    static final int TYPE_TOPIC_CONNECTION = 2;
-
+   
    // Static ---------------------------------------------------------------------------------------
 
    // Attributes -----------------------------------------------------------------------------------
 
    protected ClientConnection connection;
+   
    private int connectionType;
-
+   
+   private String clientID;
+   
+   private boolean justCreated = true;      
+   
+   private ConnectionMetaData metaData;
+   
+   private Version version;
+   
+   private ExceptionListener exceptionListener;
+   
+   private int dupsOKBatchSize;
+     
    // Constructors ---------------------------------------------------------------------------------
 
-   public JBossConnection(ClientConnection delegate, int connectionType)
+   public JBossConnection(ClientConnection connection, int connectionType, Version version,
+                          String clientID, int dupsOKBatchSize)
    {
-      this.connection = delegate;
+      this.connection = connection;
+      
       this.connectionType = connectionType;
+      
+      this.version = version;
+      
+      this.clientID = clientID;
+      
+      this.dupsOKBatchSize = dupsOKBatchSize;
    }
 
    // Connection implementation --------------------------------------------------------------------
@@ -87,50 +120,114 @@
 
    public String getClientID() throws JMSException
    {
-      return connection.getClientID();
+      checkClosed();
+            
+      justCreated = false;
+      
+      return clientID;
    }
 
    public void setClientID(String clientID) throws JMSException
    {
-      connection.setClientID(clientID);
+      checkClosed();
+      
+      if (this.clientID != null)
+      {
+         throw new IllegalStateException("Client id has already been set");
+      }
+      
+      if (!justCreated)
+      {
+         throw new IllegalStateException("setClientID can only be called directly after the connection is created");
+      }
+
+      this.clientID = clientID;
+
+      justCreated = false;
    }
-
+   
    public ConnectionMetaData getMetaData() throws JMSException
    {
-      return connection.getConnectionMetaData();
+      checkClosed();
+    
+      justCreated = false;
+
+      if (metaData == null)
+      {
+         metaData = new JBossConnectionMetaData(version);
+      }
+
+      return metaData;
    }
-
+      
    public ExceptionListener getExceptionListener() throws JMSException
    {
-      return connection.getExceptionListener();
+      justCreated = false;
+      
+      return exceptionListener;
    }
 
    public void setExceptionListener(ExceptionListener listener) throws JMSException
    {
-      connection.setExceptionListener(listener);
+      try
+      {
+         if (listener == null)
+         {
+            connection.setFailureListener(null);                 
+         }
+         else
+         {
+            connection.setFailureListener(new JMSFailureListener());
+         }
+         
+         exceptionListener = listener;
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
+      
+      justCreated = false;
    }
 
    public void start() throws JMSException
    {
-      connection.start();
+      try
+      {
+         connection.start();
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
+      
+      justCreated = false;
    }
 
    public void stop() throws JMSException
    {
-      connection.stop();
+      try
+      {
+         connection.stop();
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
+      
+      justCreated = false;
    }
 
    public void close() throws JMSException
    {
+
       try
       {
-         connection.closing();
          connection.close();
-      } finally
+      }
+      catch (MessagingException e)
       {
-         // FIXME regardless of the pb when closing/close the connection, we must ensure
-         // the remoting connection is properly stopped
-         connection.getRemotingConnection().stop();
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
       }
    }
 
@@ -139,8 +236,8 @@
                                                       ServerSessionPool sessionPool,
                                                       int maxMessages) throws JMSException
    {
-      return connection.
-         createConnectionConsumer(destination, null, messageSelector, sessionPool, maxMessages);
+      //TODO
+      return null;
    }
 
    public ConnectionConsumer createDurableConnectionConsumer(Topic topic,
@@ -155,8 +252,9 @@
          String msg = "Cannot create a durable connection consumer on a QueueConnection";
          throw new javax.jms.IllegalStateException(msg);
       }
-      return connection.createConnectionConsumer(topic, subscriptionName, messageSelector,
-                                               sessionPool, maxMessages);
+     
+      //TODO
+      return null;
    }
 
    // QueueConnection implementation ---------------------------------------------------------------
@@ -171,10 +269,11 @@
    public ConnectionConsumer createConnectionConsumer(Queue queue, String messageSelector,
                                                       ServerSessionPool sessionPool,
                                                       int maxMessages) throws JMSException
-    {
-      return connection.
-         createConnectionConsumer(queue, null, messageSelector, sessionPool, maxMessages);
-    }
+   {
+      //TODO
+      
+      return null;
+   }
 
    // TopicConnection implementation ---------------------------------------------------------------
 
@@ -189,8 +288,9 @@
                                                       ServerSessionPool sessionPool,
                                                       int maxMessages) throws JMSException
    {
-      return connection.
-         createConnectionConsumer(topic, null, messageSelector, sessionPool, maxMessages);
+      //TODO
+      
+      return null;
    }
 
    // XAConnection implementation ------------------------------------------------------------------
@@ -221,29 +321,25 @@
 
    // Public ---------------------------------------------------------------------------------------
 
-   /* For testing only */
-   public String getRemotingClientSessionID()
+   public ClientConnection getConnection()
    {
-      return connection.getRemotingConnection().getSessionID();
+      return connection;
    }
 
-   public ClientConnection getDelegate()
+   public String toString()
    {
-      return connection;
+      return "JBossConnection->" + connection;
    }
-
-   /**
-    * Convenience method.
-    */
+   
+   //For testing only
    public int getServerID()
    {
-      
-      return connection.getServerID(); 
+      return ((ClientConnectionInternal)connection).getServerID();
    }
-
-   public String toString()
+   
+   public String getRemotingClientSessionID()
    {
-      return "JBossConnection->" + connection;
+      return ((ClientConnectionInternal)connection).getRemotingConnection().getSessionID();
    }
 
    // Package protected ----------------------------------------------------------------------------
@@ -257,13 +353,79 @@
       {
          acknowledgeMode = Session.SESSION_TRANSACTED;
       }
+      
+      try
+      {
+         int ackBatchSize;
+         
+         if (transacted || acknowledgeMode == Session.CLIENT_ACKNOWLEDGE)
+         {
+            ackBatchSize = -1; //Infinite
+         }
+         else if (acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE)
+         {
+            ackBatchSize = dupsOKBatchSize;
+         }
+         else
+         {
+            //Auto ack
+            ackBatchSize = 1;
+         }
 
-      ClientSession session =  connection.createClientSession(transacted, acknowledgeMode, isXA);
-      
-      return new JBossSession(transacted, acknowledgeMode, session, type);
+         boolean autoCommitSends = false;
+
+         boolean autoCommitAcks = false;
+
+         if (!transacted)
+         {
+            if (acknowledgeMode == Session.AUTO_ACKNOWLEDGE || acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE)
+            {
+               autoCommitSends = true;
+
+               autoCommitAcks = true;
+            }
+            else if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE)
+            {
+               autoCommitSends = true;
+
+               autoCommitAcks = false;
+            }
+         }
+
+         ClientSession session =  connection.createClientSession(isXA, autoCommitSends, autoCommitAcks, ackBatchSize);
+
+         justCreated = false;
+         
+         return new JBossSession(this, transacted, isXA, acknowledgeMode, session, type);
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }            
    }
 
    // Private --------------------------------------------------------------------------------------
+   
+   private void checkClosed() throws JMSException
+   {
+      if (connection.isClosed())
+      {
+         throw new IllegalStateException("Connection is closed");
+      }
+   }
 
    // Inner classes --------------------------------------------------------------------------------
+   
+   private class JMSFailureListener implements FailureListener
+   {
+      public void onFailure(MessagingException me)
+      {
+         JMSException je = new JMSException(me.toString());
+         
+         je.initCause(me);
+         
+         exceptionListener.onException(je);
+      }
+      
+   }
 }

Modified: trunk/src/main/org/jboss/jms/client/JBossConnectionConsumer.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossConnectionConsumer.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/JBossConnectionConsumer.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,21 +21,12 @@
   */
 package org.jboss.jms.client;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import javax.jms.ConnectionConsumer;
 import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.ServerSession;
 import javax.jms.ServerSessionPool;
-import javax.jms.Session;
 
 import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.message.JBossMessage;
 import org.jboss.messaging.util.Logger;
-import org.jboss.messaging.util.MessageQueueNameHelper;
 
 import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
 
@@ -103,38 +94,38 @@
                                   String subName, String messageSelector,
                                   ServerSessionPool sessPool, int maxMessages) throws JMSException
    {
-      this.serverSessionPool = sessPool;
-      this.maxMessages = maxMessages;
-
-      if (this.maxMessages < 1)
-      {
-         this.maxMessages = 1;
-      }
-
-      // Create a consumer. The ClientConsumer knows we are a connection consumer so will
-      // not call pre or postDeliver so messages won't be acked, or stored in session/tx.
-      sess = conn.createClientSession(false, Session.CLIENT_ACKNOWLEDGE, false);
-          
-      cons = sess.createClientConsumer(dest.toCoreDestination(), messageSelector, false, subName);
-
-      this.consumerID = cons.getID();      
-        
-      //this.maxDeliveries = cons.getMaxDeliveries();
-         
-      if (subName != null)
-      {
-         queueName = MessageQueueNameHelper.createSubscriptionName(conn.getClientID(), subName);
-      }
-      else
-      {
-         queueName = dest.getName();
-      }
-
-      id = threadId.increment();
-      internalThread = new Thread(this, "Connection ClientConsumer for dest " + dest + " id=" + id);
-      internalThread.start();
-
-      if (trace) { log.trace(this + " created"); }
+//      this.serverSessionPool = sessPool;
+//      this.maxMessages = maxMessages;
+//
+//      if (this.maxMessages < 1)
+//      {
+//         this.maxMessages = 1;
+//      }
+//
+//      // Create a consumer. The ClientConsumer knows we are a connection consumer so will
+//      // not call pre or postDeliver so messages won't be acked, or stored in session/tx.
+//      sess = conn.createClientSession(false, Session.CLIENT_ACKNOWLEDGE, false);
+//          
+//      //cons = sess.createClientConsumer(dest.toCoreDestination(), messageSelector, false, subName);
+//
+//      this.consumerID = cons.getID();      
+//        
+//      //this.maxDeliveries = cons.getMaxDeliveries();
+//         
+//      if (subName != null)
+//      {
+//         queueName = MessageQueueNameHelper.createSubscriptionName(conn.getClientID(), subName);
+//      }
+//      else
+//      {
+//         queueName = dest.getName();
+//      }
+//
+//      id = threadId.increment();
+//      internalThread = new Thread(this, "Connection ClientConsumer for dest " + dest + " id=" + id);
+//      internalThread.start();
+//
+//      if (trace) { log.trace(this + " created"); }
    }
    
    // ConnectionConsumer implementation -----------------------------
@@ -311,15 +302,15 @@
    
    protected synchronized void doClose() throws JMSException
    {
-      if (closed)
-      {
-         return;
-      }
-      
-      closed = true;            
-      
-      sess.closing();
-      sess.close();
+//      if (closed)
+//      {
+//         return;
+//      }
+//      
+//      closed = true;            
+//      
+//      sess.closing();
+//      sess.close();
 
       if (trace) { log.trace(this + "Closed message handler"); }
    }

Modified: trunk/src/main/org/jboss/jms/client/JBossConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossConnectionFactory.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/JBossConnectionFactory.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -41,8 +41,10 @@
 
 import org.jboss.jms.client.api.ClientConnection;
 import org.jboss.jms.client.api.ClientConnectionFactory;
+import org.jboss.jms.exception.JMSExceptionHelper;
 import org.jboss.jms.referenceable.SerializableObjectRefAddr;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -66,13 +68,21 @@
    
    // Attributes -----------------------------------------------------------------------------------
    
-   protected ClientConnectionFactory delegate;
+   private ClientConnectionFactory connectionFactory;
+   
+   private String clientID;
+   
+   private int dupsOKBatchSize;
 
    // Constructors ---------------------------------------------------------------------------------
    
-   public JBossConnectionFactory(ClientConnectionFactory delegate)
+   public JBossConnectionFactory(ClientConnectionFactory connectionFactory, String clientID, int dupsOKBatchSize)
    {
-      this.delegate = delegate;      
+      this.connectionFactory = connectionFactory;     
+      
+      this.clientID = clientID;
+      
+      this.dupsOKBatchSize = dupsOKBatchSize;
    }
    
    // ConnectionFactory implementation -------------------------------------------------------------
@@ -171,12 +181,12 @@
    
    public String toString()
    {
-      return "JBossConnectionFactory->" + delegate;
+      return "JBossConnectionFactory->" + connectionFactory;
    }
    
    public ClientConnectionFactory getDelegate()
    {
-      return delegate;
+      return connectionFactory;
    }
    
    // Package protected ----------------------------------------------------------------------------
@@ -187,9 +197,16 @@
                                                       boolean isXA, int type)
       throws JMSException
    {
-      ClientConnection res = delegate.createConnection(username, password);
-
-      return new JBossConnection(res, type);
+      try
+      {
+         ClientConnection res = connectionFactory.createConnection(username, password);
+                    
+         return new JBossConnection(res, type, connectionFactory.getServerVersion(), clientID, dupsOKBatchSize);
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
    
    // Private --------------------------------------------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/client/JBossMessageConsumer.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossMessageConsumer.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/JBossMessageConsumer.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,6 +21,7 @@
   */
 package org.jboss.jms.client;
 
+import javax.jms.Destination;
 import javax.jms.IllegalStateException;
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -32,11 +33,11 @@
 import javax.jms.TopicSubscriber;
 
 import org.jboss.jms.client.api.ClientConsumer;
-import org.jboss.jms.client.api.ClientSession;
 import org.jboss.jms.client.api.MessageHandler;
-import org.jboss.jms.destination.JBossDestination;
+import org.jboss.jms.exception.JMSExceptionHelper;
 import org.jboss.jms.message.JBossMessage;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -63,23 +64,42 @@
    private JBossSession session;
    
    private int ackMode;
-
+   
+   private boolean noLocal;
+   
+   private Destination destination;
+   
+   private String selector;
+   
+   private boolean deleteQueueOnClose;
+   
    // Constructors --------------------------------------------------
 
-   public JBossMessageConsumer(JBossSession session, ClientConsumer consumer) throws JMSException
+   public JBossMessageConsumer(JBossSession session, ClientConsumer consumer, boolean noLocal,
+                               Destination destination, String selector, boolean deleteQueueOnClose) throws JMSException
    {      
       this.session = session;
       
       this.consumer = consumer;
       
       this.ackMode = session.getAcknowledgeMode();
+      
+      this.noLocal = noLocal;
+      
+      this.destination = destination;
+      
+      this.selector = selector;
+      
+      this.deleteQueueOnClose = deleteQueueOnClose;
    }
 
    // MessageConsumer implementation --------------------------------
 
    public String getMessageSelector() throws JMSException
    {
-      return consumer.getMessageSelector();
+      checkClosed();
+      
+      return selector;
    }
 
    public MessageListener getMessageListener() throws JMSException
@@ -95,7 +115,14 @@
       
       coreListener = new JMSMessageListenerWrapper(session, listener, ackMode);
       
-      consumer.setMessageHandler(coreListener);
+      try
+      {
+         consumer.setMessageHandler(coreListener);
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    public Message receive() throws JMSException
@@ -115,31 +142,37 @@
      
    public void close() throws JMSException
    {
-      consumer.closing();
-      consumer.close();
+      try
+      {
+         consumer.close();                 
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    // QueueReceiver implementation ----------------------------------
 
    public Queue getQueue() throws JMSException
    {
-      return (Queue)JBossDestination.fromCoreDestination(consumer.getDestination());
+      return (Queue)destination;
    }
 
    // TopicSubscriber implementation --------------------------------
 
    public Topic getTopic() throws JMSException
    {
-      return (Topic)JBossDestination.fromCoreDestination(consumer.getDestination());
+      return (Topic)destination;
    }
 
 
    public boolean getNoLocal() throws JMSException
    {
-      return consumer.getNoLocal();
+      return noLocal;
    }
 
-   public ClientConsumer getDelegate()
+   public ClientConsumer getConsumer()
    {
        return consumer;
    }
@@ -167,30 +200,36 @@
    
    private JBossMessage getMessage(long timeout) throws JMSException
    {
-      org.jboss.messaging.core.Message message =  consumer.receive(timeout);
-            
-      JBossMessage jbm = null;
-      
-      if (message != null)
-      {         
-         //At this point JMS considers the message delivered
-         session.getCoreSession().delivered();
-                  
-         jbm = JBossMessage.createMessage(message, session.getCoreSession());
+      try
+      {
+         org.jboss.messaging.core.Message message =  consumer.receive(timeout);
+               
+         JBossMessage jbm = null;
          
-         try
-         {
-            jbm.doBeforeReceive();
-         }
-         catch (Exception e)
-         {
-            log.error("Failed to prepare message", e);
+         if (message != null)
+         {         
+            session.getCoreSession().acknowledge();
+                     
+            jbm = JBossMessage.createMessage(message, session.getCoreSession());
             
-            return null;
+            try
+            {
+               jbm.doBeforeReceive();
+            }
+            catch (Exception e)
+            {
+               log.error("Failed to prepare message", e);
+               
+               return null;
+            }
          }
+         
+         return jbm;
       }
-      
-      return jbm;
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    // Inner classes -------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/client/JBossMessageProducer.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossMessageProducer.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/JBossMessageProducer.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,18 +21,36 @@
   */
 package org.jboss.jms.client;
 
+import java.util.UUID;
+
+import javax.jms.BytesMessage;
+import javax.jms.DeliveryMode;
 import javax.jms.Destination;
+import javax.jms.IllegalStateException;
 import javax.jms.InvalidDestinationException;
 import javax.jms.JMSException;
+import javax.jms.MapMessage;
 import javax.jms.Message;
 import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
 import javax.jms.Queue;
 import javax.jms.QueueSender;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
 import javax.jms.Topic;
 import javax.jms.TopicPublisher;
 
+import org.jboss.jms.client.api.ClientProducer;
 import org.jboss.jms.destination.JBossDestination;
+import org.jboss.jms.exception.JMSExceptionHelper;
+import org.jboss.jms.message.JBossBytesMessage;
+import org.jboss.jms.message.JBossMapMessage;
+import org.jboss.jms.message.JBossMessage;
+import org.jboss.jms.message.JBossObjectMessage;
+import org.jboss.jms.message.JBossStreamMessage;
+import org.jboss.jms.message.JBossTextMessage;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -51,115 +69,179 @@
    
    // Attributes ----------------------------------------------------
    
-   protected org.jboss.jms.client.api.ClientProducer producer;
+   private ClientProducer producer;
+   
+   private boolean disableMessageID = false;
+   
+   private boolean disableMessageTimestamp = false;
+   
+   private int defaultPriority = 4;
+   
+   private long defaultTimeToLive = 0;
+   
+   private int defaultDeliveryMode = DeliveryMode.PERSISTENT;
+   
+   private JBossDestination defaultDestination;   
 
    // Constructors --------------------------------------------------
    
-   public JBossMessageProducer(org.jboss.jms.client.api.ClientProducer producer)
+   public JBossMessageProducer(ClientProducer producer, JBossDestination defaultDestination) throws JMSException
    {
       this.producer = producer;     
+      
+      this.defaultDestination = defaultDestination;
    }
    
    // MessageProducer implementation --------------------------------
    
    public void setDisableMessageID(boolean value) throws JMSException
    {
-      log.warn("JBoss Messaging does not support disabling message ID generation");
-
-      producer.setDisableMessageID(value);
+      checkClosed();
+      
+      disableMessageID = value;
    }
    
    public boolean getDisableMessageID() throws JMSException
    {
-      return producer.isDisableMessageID();
+      checkClosed();
+      
+      return disableMessageID;
    }
    
    public void setDisableMessageTimestamp(boolean value) throws JMSException
    {
-      producer.setDisableMessageTimestamp(value);
+      checkClosed();
+      
+      disableMessageTimestamp = value;
    }
    
    public boolean getDisableMessageTimestamp() throws JMSException
    {
-      return producer.isDisableMessageTimestamp();
+      checkClosed();
+      
+      return disableMessageTimestamp;
    }
    
    public void setDeliveryMode(int deliveryMode) throws JMSException
    {
-      producer.setDeliveryMode(deliveryMode);
+      checkClosed();
+      
+      this.defaultDeliveryMode = deliveryMode;
    }
    
    public int getDeliveryMode() throws JMSException
    {
-      return producer.getDeliveryMode();
+      checkClosed();
+      
+      return this.defaultDeliveryMode;
    }
    
    public void setPriority(int defaultPriority) throws JMSException
    {
-      producer.setPriority(defaultPriority);
+      checkClosed();
+      
+      this.defaultPriority = defaultPriority;
    }
    
    public int getPriority() throws JMSException
    {
-      return producer.getPriority();
+      checkClosed();
+      
+      return defaultPriority;
    }
    
    public void setTimeToLive(long timeToLive) throws JMSException
    {
-      producer.setTimeToLive(timeToLive);
+      checkClosed();
+      
+      this.defaultTimeToLive = timeToLive;
    }
    
    public long getTimeToLive() throws JMSException
    {
-      return producer.getTimeToLive();
+      checkClosed();
+      
+      return defaultTimeToLive;
    }
    
    public Destination getDestination() throws JMSException
    {
-      return producer.getDestination();
+      checkClosed();
+      
+      return defaultDestination;
    }
    
    public void close() throws JMSException
    {
-      producer.closing();
-      producer.close();
+      try
+      {
+         producer.close();
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }   
    }
    
    public void send(Message message) throws JMSException
    {
-      // by default the message never expires
-      send(message, -1, -1, Long.MIN_VALUE);
+      checkClosed();
+
+      message.setJMSDeliveryMode(defaultDeliveryMode);
+      
+      message.setJMSPriority(defaultPriority);
+      
+      doSend(message, defaultTimeToLive, defaultDestination);
    }
    
-   /**
-    * @param timeToLive - 0 means never expire.
-    */
-   public void send(Message message, int deliveryMode, int priority, long timeToLive)
-      throws JMSException
+   public void send(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
    { 
-      send(null, message, deliveryMode, priority, timeToLive);
+      checkClosed();
+
+      message.setJMSDeliveryMode(deliveryMode);
+      
+      message.setJMSPriority(priority);
+            
+      doSend(message, timeToLive, defaultDestination);
    }
    
    public void send(Destination destination, Message message) throws JMSException
    {      
-      send(destination, message, -1, -1, Long.MIN_VALUE);
+      checkClosed();
+
+      if (destination != null && !(destination instanceof JBossDestination))
+      {
+         throw new InvalidDestinationException("Not a JBoss Destination:" + destination);
+      }
+      
+      message.setJMSDeliveryMode(defaultDeliveryMode);
+      
+      message.setJMSPriority(defaultPriority);
+      
+      doSend(message, defaultTimeToLive, (JBossDestination)destination);
    }
 
+
    public void send(Destination destination,
-                    Message m,
+                    Message message,
                     int deliveryMode,
                     int priority,
                     long timeToLive) throws JMSException
    {
+      checkClosed();
+
       if (destination != null && !(destination instanceof JBossDestination))
       {
-         throw new InvalidDestinationException("Not a JBossDestination:" + destination);
+         throw new InvalidDestinationException("Not a JBoss Destination:" + destination);
       }
 
-      producer.send((JBossDestination)destination, m, deliveryMode, priority, timeToLive);
+      message.setJMSDeliveryMode(deliveryMode);
+      
+      message.setJMSPriority(priority);
+            
+      doSend(message, timeToLive, (JBossDestination)destination);
    }
 
-
    // TopicPublisher Implementation ---------------------------------
 
    public Topic getTopic() throws JMSException
@@ -225,5 +307,135 @@
    
    // Private -------------------------------------------------------
    
+   private void doSend(Message message, long timeToLive, JBossDestination destination) throws JMSException
+   {
+      if (timeToLive == 0)
+      {
+         message.setJMSExpiration(0);
+      }
+      else
+      {
+         message.setJMSExpiration(System.currentTimeMillis() + timeToLive);
+      }
+      
+      if (!disableMessageTimestamp)
+      {
+         message.setJMSTimestamp(System.currentTimeMillis());
+      }
+      else
+      {
+         message.setJMSTimestamp(0);
+      }
+      
+      // if a default destination was already specified then this must be same destination as
+      // that specified in the arguments
+
+      if (this.defaultDestination != null && !this.defaultDestination.equals(destination))
+      {
+         throw new UnsupportedOperationException("Where a default destination is specified " +
+                                                 "for the sender and a destination is " +
+                                                 "specified in the arguments to the send, " +
+                                                 "these destinations must be equal");
+      }
+      
+      JBossMessage jbm;
+
+      boolean foreign = false;
+
+      // First convert from foreign message if appropriate
+      if (!(message instanceof JBossMessage))
+      {
+         // JMS 1.1 Sect. 3.11.4: A provider must be prepared to accept, from a client,
+         // a message whose implementation is not one of its own.
+
+         if (message instanceof BytesMessage)
+         {
+            jbm = new JBossBytesMessage((BytesMessage)message);
+         }
+         else if (message instanceof MapMessage)
+         {
+            jbm = new JBossMapMessage((MapMessage)message);
+         }
+         else if (message instanceof ObjectMessage)
+         {
+            jbm = new JBossObjectMessage((ObjectMessage)message);
+         }
+         else if (message instanceof StreamMessage)
+         {
+            jbm = new JBossStreamMessage((StreamMessage)message);
+         }
+         else if (message instanceof TextMessage)
+         {
+            jbm = new JBossTextMessage((TextMessage)message);
+         }
+         else
+         {
+            jbm = new JBossMessage(message);
+         }
+
+         // Set the destination on the original message
+         message.setJMSDestination(destination);
+
+         foreign = true;
+      }
+      else
+      {
+         jbm = (JBossMessage)message;
+      }
+
+      if (!disableMessageID)
+      {
+         // Generate an id
+
+         String id = UUID.randomUUID().toString();
+
+         jbm.setJMSMessageID("ID:" + id);
+      }
+
+      if (foreign)
+      {
+         message.setJMSMessageID(jbm.getJMSMessageID());
+      }
+
+      jbm.setJMSDestination(destination);
+
+      try
+      {
+         jbm.doBeforeSend();
+      }
+      catch (Exception e)
+      {
+         JMSException je = new JMSException(e.getMessage());
+         
+         je.initCause(e);
+         
+         throw je;
+      }
+
+      JBossDestination dest = (JBossDestination)destination;
+
+      String coreDest = dest.getAddress();
+
+      // TODO - can optimise this copy to do copy lazily.
+      org.jboss.messaging.core.Message messageToSend = jbm.getCoreMessage().copy();
+
+      try
+      {
+         producer.send(coreDest, messageToSend);
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      } 
+   }
+   
+   private void checkClosed() throws JMSException
+   {
+      if (producer.isClosed())
+      {
+         throw new IllegalStateException("Prducer is closed");
+      }
+   }
+   
    // Inner classes -------------------------------------------------
 }

Modified: trunk/src/main/org/jboss/jms/client/JBossQueueBrowser.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossQueueBrowser.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/JBossQueueBrowser.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,7 +21,6 @@
   */
 package org.jboss.jms.client;
 
-import java.io.Serializable;
 import java.util.Enumeration;
 
 import javax.jms.JMSException;
@@ -29,9 +28,11 @@
 import javax.jms.QueueBrowser;
 
 import org.jboss.jms.client.api.ClientBrowser;
+import org.jboss.jms.exception.JMSExceptionHelper;
 import org.jboss.jms.message.JBossMessage;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -48,15 +49,15 @@
 
    // Attributes -----------------------------------------------------------------------------------
 
-   private ClientBrowser delegate;
+   private ClientBrowser browser;
    private Queue queue;
    private String messageSelector;
 
    // Constructors ---------------------------------------------------------------------------------
 
-   JBossQueueBrowser(Queue queue, String messageSelector, ClientBrowser delegate)
+   JBossQueueBrowser(Queue queue, String messageSelector, ClientBrowser browser)
    {
-      this.delegate = delegate;
+      this.browser = browser;
       this.queue = queue;
       this.messageSelector = messageSelector;
    }
@@ -65,14 +66,27 @@
 
    public void close() throws JMSException
    {
-      delegate.closing();
-      delegate.close();
+      try
+      {
+         browser.close();
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    public Enumeration getEnumeration() throws JMSException
    {
-      delegate.reset();
-      return new BrowserEnumeration();
+      try
+      {
+         browser.reset();
+         return new BrowserEnumeration();
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    public String getMessageSelector() throws JMSException
@@ -89,12 +103,12 @@
 
    public String toString()
    {
-      return "JBossQueueBrowser->" + delegate;
+      return "JBossQueueBrowser->" + browser;
    }
 
-   public ClientBrowser getDelegate()
+   public ClientBrowser getBrowser()
    {
-      return delegate;
+      return browser;
    }
 
    // Package protected ----------------------------------------------------------------------------
@@ -110,11 +124,10 @@
       public boolean hasMoreElements()
       {
          try
-         {
-            
-            return delegate.hasNextMessage();
+         {            
+            return browser.hasNextMessage();
          }
-         catch (JMSException e)
+         catch (MessagingException e)
          {
             throw new IllegalStateException(e.getMessage());
          }
@@ -124,7 +137,7 @@
       {
          try
          {
-            Message message = delegate.nextMessage();
+            Message message = browser.nextMessage();
 
             JBossMessage jbm = JBossMessage.createMessage(message, null);
             

Modified: trunk/src/main/org/jboss/jms/client/JBossSession.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossSession.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/JBossSession.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -23,10 +23,12 @@
 
 import java.io.Serializable;
 import java.util.LinkedList;
+import java.util.UUID;
 
 import javax.jms.BytesMessage;
 import javax.jms.Destination;
 import javax.jms.IllegalStateException;
+import javax.jms.InvalidClientIDException;
 import javax.jms.InvalidDestinationException;
 import javax.jms.JMSException;
 import javax.jms.MapMessage;
@@ -49,11 +51,13 @@
 import javax.jms.TopicPublisher;
 import javax.jms.TopicSession;
 import javax.jms.TopicSubscriber;
+import javax.jms.TransactionInProgressException;
 import javax.jms.XAQueueSession;
 import javax.jms.XASession;
 import javax.jms.XATopicSession;
 import javax.transaction.xa.XAResource;
 
+import org.jboss.jms.client.api.ClientBrowser;
 import org.jboss.jms.client.api.ClientConsumer;
 import org.jboss.jms.client.api.ClientProducer;
 import org.jboss.jms.client.api.ClientSession;
@@ -62,13 +66,17 @@
 import org.jboss.jms.destination.JBossTemporaryQueue;
 import org.jboss.jms.destination.JBossTemporaryTopic;
 import org.jboss.jms.destination.JBossTopic;
+import org.jboss.jms.exception.JMSExceptionHelper;
 import org.jboss.jms.message.JBossBytesMessage;
 import org.jboss.jms.message.JBossMapMessage;
 import org.jboss.jms.message.JBossMessage;
 import org.jboss.jms.message.JBossObjectMessage;
 import org.jboss.jms.message.JBossStreamMessage;
 import org.jboss.jms.message.JBossTextMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBindingQueryResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionQueueQueryResponseMessage;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -96,6 +104,8 @@
    
    // Attributes ----------------------------------------------------
    
+   private JBossConnection connection;
+   
    private ClientSession session;
 
    private int sessionType;
@@ -108,12 +118,17 @@
    
    private boolean transacted;
    
+   private boolean xa;
+   
    private boolean recoverCalled;
-   
+      
    // Constructors --------------------------------------------------
 
-   public JBossSession(boolean transacted, int ackMode, ClientSession session, int sessionType)
+   public JBossSession(JBossConnection connection, boolean transacted, boolean xa, int ackMode,
+                       ClientSession session, int sessionType)
    {      
+      this.connection = connection;
+      
       this.ackMode = ackMode;            
       
       this.session = session;
@@ -121,6 +136,8 @@
       this.sessionType = sessionType;
       
       this.transacted = transacted;
+      
+      this.xa = xa;
    }
 
    // Session implementation ----------------------------------------
@@ -209,7 +226,18 @@
       {
          throw new IllegalStateException("Cannot commit a non-transacted session");
       }
-      session.commit();
+      if (xa)
+      {
+         throw new TransactionInProgressException("Cannot call commit on an XA session");
+      }
+      try
+      {
+         session.commit();
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    public void rollback() throws JMSException
@@ -218,14 +246,31 @@
       {
          throw new IllegalStateException("Cannot rollback a non-transacted session");
       }
+      if (xa)
+      {
+         throw new TransactionInProgressException("Cannot call rollback on an XA session");
+      }
 
-      session.rollback();
+      try
+      {
+         session.rollback();
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    public void close() throws JMSException
    {
-      session.closing();
-      session.close();
+      try
+      {
+         session.close();
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    public void recover() throws JMSException
@@ -235,7 +280,14 @@
          throw new IllegalStateException("Cannot recover a transacted session");
       }
       
-      session.rollback();
+      try
+      {      
+         session.rollback();
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
       
       recoverCalled = true;
    }
@@ -288,57 +340,50 @@
    {
       if (d != null && !(d instanceof JBossDestination))
       {
-         throw new InvalidDestinationException("Not a JBossDestination:" + d);
+         throw new InvalidDestinationException("Not a JBoss Destination:" + d);
+      }           
+      
+      try
+      {
+         ClientProducer producer = session.createProducer();
+
+         return new JBossMessageProducer(producer, (JBossDestination)d);
       }
-           
-      ClientProducer producerDelegate = session.createClientProducer((JBossDestination)d);
-      
-      return new JBossMessageProducer(producerDelegate);
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
-  public MessageConsumer createConsumer(Destination d) throws JMSException
-  {
-     return createConsumer(d, null, false);
-  }
+   public MessageConsumer createConsumer(Destination d) throws JMSException
+   {
+      return createConsumer(d, null, false);
+   }
 
-  public MessageConsumer createConsumer(Destination d, String messageSelector) throws JMSException
-  {
-     return createConsumer(d, messageSelector, false);
-  }
+   public MessageConsumer createConsumer(Destination d, String messageSelector) throws JMSException
+   {
+      return createConsumer(d, messageSelector, false);
+   }
 
-   public MessageConsumer createConsumer(Destination d, String messageSelector, boolean noLocal)
-         throws JMSException
+   public MessageConsumer createConsumer(Destination dest, String messageSelector, boolean noLocal)
+      throws JMSException
    {
-      if (d == null)
+      if (dest == null)
       {
          throw new InvalidDestinationException("Cannot create a consumer with a null destination");
       }
-      if (!(d instanceof JBossDestination))
+
+      if (!(dest instanceof JBossDestination))
       {
-         throw new InvalidDestinationException("Not a JBossDestination:" + d);
+         throw new InvalidDestinationException("Not a JBossDestination:" + dest);
       }
-                        
-      ClientConsumer cd = session.
-         createClientConsumer(((JBossDestination)d).toCoreDestination(), messageSelector, noLocal, null);
 
-      return new JBossMessageConsumer(this, cd);
+      JBossDestination jbdest = (JBossDestination)dest;
+
+      ClientConsumer cd = createConsumer(jbdest, null, messageSelector, noLocal);
+
+      return new JBossMessageConsumer(this, cd, noLocal, dest, messageSelector, dest instanceof Topic);
    }
-   
-   private boolean isDeliveredBeforeOnMessage()
-   {
-      boolean deliveredBeforeOnMessage;
-      
-      if (transacted || ackMode == Session.CLIENT_ACKNOWLEDGE)
-      {
-         deliveredBeforeOnMessage = true;
-      }
-      else
-      {
-         deliveredBeforeOnMessage = false;
-      }
-      
-      return deliveredBeforeOnMessage;
-   }
 
    public Queue createQueue(String queueName) throws JMSException
    {
@@ -347,7 +392,26 @@
       {
          throw new IllegalStateException("Cannot create a queue using a TopicSession");
       }
-      return session.createQueue(queueName);
+
+      JBossQueue queue = new JBossQueue(queueName);
+
+      try
+      {      
+         SessionQueueQueryResponseMessage response = session.queueQuery(queue.getAddress());
+
+         if (!response.isExists())
+         {
+            throw new JMSException("There is no queue with name " + queueName);
+         }
+         else
+         {         
+            return queue;
+         }
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    public Topic createTopic(String topicName) throws JMSException
@@ -357,7 +421,26 @@
       {
          throw new IllegalStateException("Cannot create a topic on a QueueSession");
       }
-      return session.createTopic(topicName);
+      
+      JBossTopic topic = new JBossTopic(topicName);
+      
+      try
+      {      
+         SessionBindingQueryResponseMessage response = session.bindingQuery(topic.getAddress());
+         
+         if (!response.isExists())
+         {
+            throw new JMSException("There is no topic with name " + topicName);
+         }
+         else
+         {         
+            return topic;
+         }
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException
@@ -375,12 +458,134 @@
       {
          throw new InvalidDestinationException("Not a JBossTopic:" + topic);
       }
+            
+      JBossDestination jbdest = (JBossDestination)topic;
+            
+      ClientConsumer cd = createConsumer(jbdest, name, null, false);
 
-      ClientConsumer cd =
-         session.createClientConsumer(((JBossTopic)topic).toCoreDestination(), null, false, name);
-
-      return new JBossMessageConsumer(this, cd);
+      return new JBossMessageConsumer(this, cd, false, topic, null, false);
    }
+   
+   private ClientConsumer createConsumer(JBossDestination dest,
+                                         String subscriptionName, String selectorString, boolean noLocal)
+      throws JMSException
+   {      
+      try
+      {               
+         selectorString = "".equals(selectorString) ? null : selectorString;
+         
+         String coreFilterString = null;
+         
+         if (selectorString != null)
+         {
+            coreFilterString = SelectorTranslator.convertToJBMFilterString(selectorString);
+         }
+         
+         ClientConsumer consumer;
+         
+         if (dest instanceof Queue)
+         {
+            SessionQueueQueryResponseMessage response = session.queueQuery(dest.getAddress());
+            
+            if (!response.isExists())
+            {
+               throw new InvalidDestinationException("Queue " + dest.getName() + " does not exist");
+            }
+            
+            consumer = session.createConsumer(dest.getAddress(), coreFilterString, noLocal, false);
+         }
+         else
+         {
+            SessionBindingQueryResponseMessage response = session.bindingQuery(dest.getAddress());
+            
+            if (!response.isExists())
+            {
+               throw new InvalidDestinationException("Topic " + dest.getName() + " does not exist");
+            }
+                          
+            String queueName;
+            
+            if (subscriptionName == null)
+            {
+               //Non durable sub
+              
+               queueName = UUID.randomUUID().toString();
+               
+               session.createQueue(dest.getAddress(), queueName, coreFilterString, false, false);
+               
+               consumer = session.createConsumer(queueName, null, noLocal, true);
+            }
+            else
+            {
+               //Durable sub
+               
+               if (connection.getClientID() == null)
+               {
+                  throw new InvalidClientIDException("Cannot create durable subscription - client ID has not been set");
+               }
+               
+               if (dest.isTemporary())
+               {
+                  throw new InvalidDestinationException("Cannot create a durable subscription on a temporary topic");
+               }
+               
+               queueName =
+                  JBossTopic.createQueueNameForDurableSubscription(connection.getClientID(), subscriptionName);
+               
+               SessionQueueQueryResponseMessage subResponse = session.queueQuery(queueName);
+               
+               if (!subResponse.isExists())
+               {
+                  session.createQueue(dest.getAddress(), queueName, coreFilterString, true, false);
+               }
+               else
+               {
+                  //Already exists
+                  if (subResponse.getConsumerCount() > 0)
+                  {
+                     throw new IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)");                
+                  }
+                  
+                  // From javax.jms.Session Javadoc (and also JMS 1.1 6.11.1):
+                  // A client can change an existing durable subscription by creating a durable
+                  // TopicSubscriber with the same name and a new topic and/or message selector.
+                  // Changing a durable subscriber is equivalent to unsubscribing (deleting) the old
+                  // one and creating a new one.
+                  
+                  String oldFilterString = subResponse.getFilterString();
+                  
+                  boolean selectorChanged =
+                     (coreFilterString == null && oldFilterString != null) ||
+                     (oldFilterString == null && coreFilterString != null) ||
+                     (oldFilterString != null && coreFilterString != null &&
+                              !oldFilterString.equals(coreFilterString));
+                  
+   
+                  String oldTopicName = subResponse.getAddress();
+                  
+                  boolean topicChanged = !oldTopicName.equals(dest.getAddress());
+                  
+                  if (selectorChanged || topicChanged)
+                  {
+                     // Delete the old durable sub
+                     session.deleteQueue(queueName);
+                     
+                     //Create the new one
+                     session.createQueue(dest.getAddress(), queueName, coreFilterString, true, false);        
+                  }                          
+               }
+               
+               consumer = session.createConsumer(queueName, null, noLocal, false);
+            }         
+         }
+         
+         return consumer;
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }      
+   }
 
    public TopicSubscriber createDurableSubscriber(Topic topic,
                                                   String name,
@@ -406,10 +611,11 @@
          messageSelector = null;
       }
 
-      ClientConsumer cd = session.
-         createClientConsumer(((JBossTopic)topic).toCoreDestination(), messageSelector, noLocal, name);
+      JBossDestination jbdest = (JBossDestination)topic;
 
-      return new JBossMessageConsumer(this, cd);
+      ClientConsumer cd = createConsumer(jbdest, name, messageSelector, noLocal);
+
+      return new JBossMessageConsumer(this, cd, noLocal, topic, messageSelector, false);
    }
 
    public QueueBrowser createBrowser(Queue queue) throws JMSException
@@ -437,10 +643,18 @@
          messageSelector = null;
       }
 
-      org.jboss.jms.client.api.ClientBrowser del =
-         session.createClientBrowser(((JBossQueue)queue).toCoreDestination(), messageSelector);
-
-      return new JBossQueueBrowser(queue, messageSelector, del);
+      JBossQueue jbq = (JBossQueue)queue;
+      
+      try
+      {      
+         ClientBrowser browser = session.createBrowser(jbq.getAddress(), messageSelector);
+   
+         return new JBossQueueBrowser(queue, messageSelector, browser);
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    public TemporaryQueue createTemporaryQueue() throws JMSException
@@ -450,9 +664,23 @@
       {
          throw new IllegalStateException("Cannot create a temporary queue using a TopicSession");
       }
-      JBossTemporaryQueue queue = new JBossTemporaryQueue(session);
-      session.addTemporaryDestination(queue.toCoreDestination());
-      return queue;
+      
+      String queueName = UUID.randomUUID().toString();
+      
+      try
+      {      
+         JBossTemporaryQueue queue = new JBossTemporaryQueue(this, queueName);
+                           
+         session.createQueue(queue.getAddress(), queue.getAddress(), null, false, true);
+         
+         session.addAddress(queue.getAddress());
+         
+         return queue;      
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    public TemporaryTopic createTemporaryTopic() throws JMSException
@@ -462,9 +690,21 @@
       {
          throw new IllegalStateException("Cannot create a temporary topic on a QueueSession");
       }
-      JBossTemporaryTopic topic = new JBossTemporaryTopic(session);
-      session.addTemporaryDestination(topic.toCoreDestination());
-      return topic;
+      
+      String topicName = UUID.randomUUID().toString();
+      
+      try
+      {      
+         JBossTemporaryTopic topic = new JBossTemporaryTopic(this, topicName);
+                           
+         session.addAddress(topic.getAddress());
+         
+         return topic;
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
 
    public void unsubscribe(String name) throws JMSException
@@ -474,15 +714,37 @@
       {
          throw new IllegalStateException("Cannot unsubscribe using a QueueSession");
       }
-      session.unsubscribe(name);
+      
+      String queueName = JBossTopic.createQueueNameForDurableSubscription(connection.getClientID(), name);
+      
+      try
+      {      
+         SessionQueueQueryResponseMessage response = session.queueQuery(queueName);
+         
+         if (!response.isExists())
+         {
+            throw new InvalidDestinationException("Cannot unsubscribe, subscription with name " + name + " does not exist");
+         }
+         
+         if (response.getConsumerCount() != 0)
+         {
+            throw new IllegalStateException("Cannot unsubscribe durable subscription " +
+                                            name + " since it has active subscribers");
+         }
+         
+         session.deleteQueue(queueName);
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }
    }
    
    // XASession implementation
    
    public Session getSession() throws JMSException
    {      
-
-      if (!session.isXA())
+      if (!xa)
       {
          throw new IllegalStateException("Isn't an XASession");
       }
@@ -565,6 +827,50 @@
    {
       this.recoverCalled = recoverCalled;
    }
+   
+   public void deleteTemporaryDestination(JBossDestination destination) throws JMSException
+   {
+      try
+      {
+         if (destination instanceof Topic)
+         {
+            SessionBindingQueryResponseMessage response = session.bindingQuery(destination.getAddress());
+            
+            if (!response.isExists())
+            {
+               throw new InvalidDestinationException("Cannot delete temporary topic " +
+                                                      destination.getName() + " does not exist");
+            }
+            
+            if (!response.getQueueNames().isEmpty())
+            {
+               throw new IllegalStateException("Cannot delete temporary topic " +
+                                               destination.getName() + " since it has subscribers");
+            }        
+         }
+         else
+         {
+            SessionQueueQueryResponseMessage response = session.queueQuery(destination.getAddress());
+            
+            if (!response.isExists())
+            {
+               throw new InvalidDestinationException("Cannot delete temporary queue " +
+                                                      destination.getName() + " does not exist");
+            }
+            
+            if (response.getConsumerCount() > 0)
+            {
+               throw new IllegalStateException("Cannot delete temporary queue " +
+                                               destination.getName() + " since it has subscribers");
+            }
+         }   
+         session.removeAddress(destination.getAddress());
+      }
+      catch (MessagingException e)
+      {
+         throw JMSExceptionHelper.convertFromMessagingException(e);     
+      }      
+   }
 
    // Package protected ---------------------------------------------
    

Modified: trunk/src/main/org/jboss/jms/client/JMSMessageListenerWrapper.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JMSMessageListenerWrapper.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/JMSMessageListenerWrapper.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,15 +21,14 @@
    */
 package org.jboss.jms.client;
 
-import javax.jms.JMSException;
 import javax.jms.MessageListener;
 import javax.jms.Session;
 
-import org.jboss.jms.client.api.ClientSession;
 import org.jboss.jms.client.api.MessageHandler;
 import org.jboss.jms.message.JBossMessage;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * 
@@ -46,8 +45,6 @@
    
    private MessageListener listener;
    
-   private int ackMode;
-   
    private boolean transactedOrClientAck;
    
    public JMSMessageListenerWrapper(JBossSession session, MessageListener listener, int ackMode)
@@ -82,9 +79,9 @@
       {
          try
          {
-            session.getCoreSession().delivered();
+            session.getCoreSession().acknowledge();
          }
-         catch (JMSException e)
+         catch (MessagingException e)
          {
             log.error("Failed to deliver message", e);
          }
@@ -122,10 +119,10 @@
             //We don't want to call this if the connection/session was closed from inside onMessage
             if (!session.getCoreSession().isClosed())
             {
-               session.getCoreSession().delivered();
+               session.getCoreSession().acknowledge();
             }
          }
-         catch (JMSException e)
+         catch (MessagingException e)
          {
             log.error("Failed to deliver message", e);
          }

Modified: trunk/src/main/org/jboss/jms/client/api/ClientBrowser.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/api/ClientBrowser.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/api/ClientBrowser.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -7,9 +7,8 @@
 
 package org.jboss.jms.client.api;
 
-import javax.jms.JMSException;
-
 import org.jboss.messaging.core.Message;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -18,15 +17,15 @@
  */
 public interface ClientBrowser
 {
-   void reset() throws JMSException;
+   void reset() throws MessagingException;
 
-   Message nextMessage() throws JMSException;
+   Message nextMessage() throws MessagingException;
    
-   boolean hasNextMessage() throws JMSException;
+   boolean hasNextMessage() throws MessagingException;
       
-   Message[] nextMessageBlock(int maxMessages) throws JMSException;
+   Message[] nextMessageBlock(int maxMessages) throws MessagingException;
    
-   void closing() throws JMSException;
+   void close() throws MessagingException;
    
-   void close() throws JMSException;
+   boolean isClosed();
  }

Modified: trunk/src/main/org/jboss/jms/client/api/ClientConnection.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/api/ClientConnection.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/api/ClientConnection.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -7,52 +7,26 @@
 
 package org.jboss.jms.client.api;
 
-import javax.jms.ConnectionMetaData;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.ServerSessionPool;
+import org.jboss.messaging.util.MessagingException;
 
-import org.jboss.jms.client.JBossConnectionConsumer;
-import org.jboss.jms.client.remoting.MessagingRemotingConnection;
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
  * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
  */
 public interface ClientConnection
-{
-   ClientSession createClientSession(boolean transacted,
-                                     int acknowledgmentMode, boolean isXA) throws JMSException;
+{    
+   ClientSession createClientSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks,
+                                     int ackBatchSize) throws MessagingException;
 
-   String getClientID() throws JMSException;
+   void start() throws MessagingException;
 
-   int getServerID();
-   
-   void setClientID(String id) throws JMSException;
+   void stop() throws MessagingException;
 
-   void start() throws JMSException;
-
-   void stop() throws JMSException;
-
-   ExceptionListener getExceptionListener() throws JMSException;
+   FailureListener getFailureListener() throws MessagingException;
    
-   void setExceptionListener(ExceptionListener listener) throws JMSException;
+   void setFailureListener(FailureListener listener) throws MessagingException;
   
-   ConnectionMetaData getConnectionMetaData() throws JMSException;
+   void close() throws MessagingException;
    
-   JBossConnectionConsumer createConnectionConsumer(Destination dest,
-                                                    String subscriptionName,
-                                                    String messageSelector,
-                                                    ServerSessionPool sessionPool,
-                                                    int maxMessages) throws JMSException;
-
-   MessagingRemotingConnection getRemotingConnection();
-
-   void removeChild(String id) throws JMSException;
-   
-   void closing() throws JMSException;
-   
-   void close() throws JMSException;
+   boolean isClosed();
 }

Modified: trunk/src/main/org/jboss/jms/client/api/ClientConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/api/ClientConnectionFactory.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/api/ClientConnectionFactory.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,9 +21,7 @@
  */
 package org.jboss.jms.client.api;
 
-import javax.jms.JMSException;
-
-import org.jboss.messaging.core.remoting.RemotingConfiguration;
+import org.jboss.messaging.util.MessagingException;
 import org.jboss.messaging.util.Version;
 
 /**
@@ -34,14 +32,10 @@
  *
  */
 public interface ClientConnectionFactory
-{      
-   RemotingConfiguration getRemotingConfiguration();
-      
-   int getServerID();
+{         
+   ClientConnection createConnection() throws MessagingException;
    
-   Version getServerVersion();
+   ClientConnection createConnection(String username, String password) throws MessagingException; 
    
-   ClientConnection createConnection() throws JMSException;
-   
-   ClientConnection createConnection(String username, String password) throws JMSException;      
+   Version getServerVersion();   
 }

Modified: trunk/src/main/org/jboss/jms/client/api/ClientConsumer.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/api/ClientConsumer.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/api/ClientConsumer.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -7,40 +7,26 @@
 
 package org.jboss.jms.client.api;
 
-import javax.jms.JMSException;
-
-import org.jboss.messaging.core.Destination;
 import org.jboss.messaging.core.Message;
-import org.jboss.messaging.core.remoting.wireformat.DeliverMessage;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
  * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
  */
 public interface ClientConsumer
-{
-   String getID();
+{      
+   Message receive(long timeout) throws MessagingException;
    
-   void changeRate(float newRate) throws JMSException;
+   Message receiveImmediate() throws MessagingException;
+   
+   MessageHandler getMessageHandler() throws MessagingException;
 
-   MessageHandler getMessageHandler() throws JMSException;
-
-   void setMessageHandler(MessageHandler handler) throws JMSException;
-
-   Destination getDestination() throws JMSException;
-
-   boolean getNoLocal() throws JMSException;
-
-   String getMessageSelector() throws JMSException;
-
-   Message receive(long timeout) throws JMSException;
+   void setMessageHandler(MessageHandler handler) throws MessagingException;
    
-   void handleMessage(DeliverMessage message) throws Exception;
+   String getQueueName();
+        
+   void close() throws MessagingException;
    
-   void closing() throws JMSException;
-   
-   void close() throws JMSException;
-   
-   void recover(long lastDeliveryID) throws JMSException;
+   boolean isClosed();      
 }

Modified: trunk/src/main/org/jboss/jms/client/api/ClientProducer.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/api/ClientProducer.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/api/ClientProducer.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -7,50 +7,17 @@
 
 package org.jboss.jms.client.api;
 
-import javax.jms.JMSException;
-import javax.jms.Message;
+import org.jboss.messaging.core.Message;
+import org.jboss.messaging.util.MessagingException;
 
-import org.jboss.jms.destination.JBossDestination;
-
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
  */
 public interface ClientProducer
-{
-   String getID();
+{        
+   void send(String address, Message message) throws MessagingException;
+      
+   void close() throws MessagingException;
    
-   void setDisableMessageID(boolean value) throws JMSException;
-   
-   boolean isDisableMessageID() throws JMSException;
-   
-   void setDisableMessageTimestamp(boolean value) throws JMSException;
-   
-   boolean isDisableMessageTimestamp() throws JMSException;
-   
-   void setDeliveryMode(int deliveryMode) throws JMSException;
-   
-   int getDeliveryMode() throws JMSException;
-   
-   void setPriority(int defaultPriority) throws JMSException;
-   
-   int getPriority() throws JMSException;
-   
-   void setTimeToLive(long timeToLive) throws JMSException;
-   
-   long getTimeToLive() throws JMSException;
-   
-   JBossDestination getDestination() throws JMSException;
-   
-   void send(JBossDestination destination,
-             Message message,
-             int deliveryMode,
-             int priority,
-             long timeToLive) throws JMSException;
-   
-   void closing() throws JMSException;
-   
-   void close() throws JMSException;
-
+   boolean isClosed();   
 }

Modified: trunk/src/main/org/jboss/jms/client/api/ClientSession.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/api/ClientSession.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/api/ClientSession.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -7,70 +7,48 @@
 
 package org.jboss.jms.client.api;
 
-import javax.jms.JMSException;
 import javax.transaction.xa.XAResource;
 
-import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.destination.JBossQueue;
-import org.jboss.jms.destination.JBossTopic;
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.Message;
+import org.jboss.messaging.core.remoting.wireformat.SessionBindingQueryResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionQueueQueryResponseMessage;
+import org.jboss.messaging.util.MessagingException;
 
 /**
+ *  
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
  * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
  */
 public interface ClientSession extends XAResource
-{
-   ClientConnection getConnection();
-
-   String getID();
-
-   ClientConsumer createClientConsumer(Destination destination, String selector,
-                                       boolean noLocal, String subscriptionName) throws JMSException;
+{   
+   void createQueue(String address, String queueName, String filterString, boolean durable, boolean temporary)
+                    throws MessagingException;
    
-   ClientBrowser createClientBrowser(Destination queue, String messageSelector) throws JMSException;
+   void deleteQueue(String queueName) throws MessagingException;
    
-   ClientProducer createClientProducer(JBossDestination destination) throws JMSException;
-
-   JBossQueue createQueue(String queueName) throws JMSException;
-
-   JBossTopic createTopic(String topicName) throws JMSException;
-
-   void delivered() throws JMSException;
+   void addAddress(String address) throws MessagingException;
    
-   void addTemporaryDestination(Destination destination) throws JMSException;
-
-   void deleteTemporaryDestination(Destination destination) throws JMSException;
-
-   void unsubscribe(String subscriptionName) throws JMSException;
-
-   void send(Message message) throws JMSException;
-
-   XAResource getXAResource();
-
-   void commit() throws JMSException;
-
-   void rollback() throws JMSException;
-
-   boolean isXA() throws JMSException;
+   void removeAddress(String address) throws MessagingException;
    
-   void removeConsumer(ClientConsumer consumer) throws JMSException;
+   SessionQueueQueryResponseMessage queueQuery(String queueName) throws MessagingException;
    
-   void removeProducer(ClientProducer producer);
+   SessionBindingQueryResponseMessage bindingQuery(String address) throws MessagingException;
    
-   void removeBrowser(ClientBrowser browser);
+   ClientConsumer createConsumer(String queueName, String filterString,
+                                 boolean noLocal, boolean autoDeleteQueue) throws MessagingException;
    
-   boolean isClosed();
+   ClientBrowser createBrowser(String queueName, String messageSelector) throws MessagingException;
    
-   void closing() throws JMSException;
+   ClientProducer createProducer() throws MessagingException;
    
-   void close() throws JMSException;
+   XAResource getXAResource();
+
+   void commit() throws MessagingException;
+
+   void rollback() throws MessagingException;
+      
+   void acknowledge() throws MessagingException;
    
-   //TOD hide these  private api
-   void delivered(long deliveryID, boolean expired);
+   void close() throws MessagingException;
    
-   void flushAcks() throws JMSException;
-   
+   boolean isClosed();        
 }

Added: trunk/src/main/org/jboss/jms/client/api/FailureListener.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/api/FailureListener.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/client/api/FailureListener.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,36 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.jms.client.api;
+
+import org.jboss.messaging.util.MessagingException;
+
+/**
+ * 
+ * A FailureListener
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface FailureListener
+{
+   void onFailure(MessagingException me);
+}

Modified: trunk/src/main/org/jboss/jms/client/impl/ClientBrowserImpl.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/impl/ClientBrowserImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/impl/ClientBrowserImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,22 +21,18 @@
   */
 package org.jboss.jms.client.impl;
 
-import javax.jms.IllegalStateException;
-import javax.jms.JMSException;
-
 import org.jboss.jms.client.api.ClientBrowser;
-import org.jboss.jms.client.api.ClientSession;
 import org.jboss.jms.client.remoting.MessagingRemotingConnection;
 import org.jboss.messaging.core.Message;
-import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageRequest;
-import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageResponse;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockRequest;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockResponse;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageRequest;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageResponse;
-import org.jboss.messaging.core.remoting.wireformat.BrowserResetMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserHasNextMessageMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserHasNextMessageResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageBlockMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageBlockResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserResetMessage;
 import org.jboss.messaging.core.remoting.wireformat.CloseMessage;
-import org.jboss.messaging.core.remoting.wireformat.ClosingMessage;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -55,7 +51,7 @@
 
    private String id;
    
-	private ClientSession session;
+	private ClientSessionInternal session;
 	
 	private MessagingRemotingConnection remotingConnection;
 	
@@ -65,7 +61,7 @@
 
    // Constructors ---------------------------------------------------------------------------------
 
-   public ClientBrowserImpl(MessagingRemotingConnection remotingConnection, ClientSession session, String id)
+   public ClientBrowserImpl(MessagingRemotingConnection remotingConnection, ClientSessionInternal session, String id)
    {
       this.remotingConnection = remotingConnection;
       
@@ -74,9 +70,9 @@
       this.session = session;
    }
 
-   // Closeable implementation ---------------------------------------------------------------------
-
-   public synchronized void close() throws JMSException
+   // ClientBrowser implementation -----------------------------------------------------------------
+   
+   public synchronized void close() throws MessagingException
    {
       if (closed)
       {
@@ -95,49 +91,44 @@
       }
    }
 
-   public synchronized void closing() throws JMSException
+   public boolean isClosed()
    {
-      if (closed)
-      {
-         return;
-      }
-      
-      remotingConnection.send(id, new ClosingMessage());
+      return closed;
    }
 
-   public void reset() throws JMSException
+   public void reset() throws MessagingException
    {
       checkClosed();
       
-      remotingConnection.send(id, new BrowserResetMessage());
+      remotingConnection.send(id, new SessionBrowserResetMessage());
    }
 
-   public boolean hasNextMessage() throws JMSException
+   public boolean hasNextMessage() throws MessagingException
    {
       checkClosed();
       
-      BrowserHasNextMessageResponse response =
-         (BrowserHasNextMessageResponse)remotingConnection.send(id, new BrowserHasNextMessageRequest());
+      SessionBrowserHasNextMessageResponseMessage response =
+         (SessionBrowserHasNextMessageResponseMessage)remotingConnection.send(id, new SessionBrowserHasNextMessageMessage());
       
       return response.hasNext();
    }
 
-   public Message nextMessage() throws JMSException
+   public Message nextMessage() throws MessagingException
    {
       checkClosed();
       
-      BrowserNextMessageResponse response =
-         (BrowserNextMessageResponse)remotingConnection.send(id, new BrowserNextMessageRequest());
+      SessionBrowserNextMessageResponseMessage response =
+         (SessionBrowserNextMessageResponseMessage)remotingConnection.send(id, new SessionBrowserNextMessageMessage());
       
       return response.getMessage();
    }
 
-   public Message[] nextMessageBlock(int maxMessages) throws JMSException
+   public Message[] nextMessageBlock(int maxMessages) throws MessagingException
    {
       checkClosed();
       
-      BrowserNextMessageBlockResponse response =
-         (BrowserNextMessageBlockResponse)remotingConnection.send(id, new BrowserNextMessageBlockRequest(maxMessages));
+      SessionBrowserNextMessageBlockResponseMessage response =
+         (SessionBrowserNextMessageBlockResponseMessage)remotingConnection.send(id, new SessionBrowserNextMessageBlockMessage(maxMessages));
       return response.getMessages();
    }
 
@@ -149,11 +140,11 @@
 
    // Private --------------------------------------------------------------------------------------
    
-   private void checkClosed() throws IllegalStateException
+   private void checkClosed() throws MessagingException
    {
       if (closed)
       {
-         throw new IllegalStateException("Browser is closed");
+         throw new MessagingException(MessagingException.OBJECT_CLOSED, "Browser is closed");
       }
    }
 

Modified: trunk/src/main/org/jboss/jms/client/impl/ClientConnectionFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/impl/ClientConnectionFactoryImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/impl/ClientConnectionFactoryImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -23,18 +23,15 @@
 
 import java.io.Serializable;
 
-import javax.jms.JMSException;
-
 import org.jboss.jms.client.api.ClientConnection;
 import org.jboss.jms.client.api.ClientConnectionFactory;
 import org.jboss.jms.client.plugin.LoadBalancingFactory;
-import org.jboss.jms.client.remoting.ConsolidatedRemotingConnectionListener;
 import org.jboss.jms.client.remoting.MessagingRemotingConnection;
-import org.jboss.jms.exception.MessagingJMSException;
 import org.jboss.messaging.core.remoting.RemotingConfiguration;
 import org.jboss.messaging.core.remoting.wireformat.CreateConnectionRequest;
 import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 import org.jboss.messaging.util.Version;
 
 /**
@@ -69,18 +66,8 @@
  
    private int serverID;
    
-   private String clientID;
-
    private int prefetchSize = 150;
 
-   private boolean supportsFailover;
-
-   private boolean supportsLoadBalancing;
-
-   private LoadBalancingFactory loadBalancingFactory;
-
-   private int dupsOKBatchSize = 1000;
-
    private boolean strictTck;
    
    // Static ---------------------------------------------------------------------------------------
@@ -89,15 +76,13 @@
 
    public ClientConnectionFactoryImpl(int serverID,
          RemotingConfiguration remotingConfig, Version serverVersion, boolean strictTck,
-         int prefetchSize, int dupsOKBatchSize, String clientID)
+         int prefetchSize)
    {
       this.serverID = serverID;
       this.remotingConfig = remotingConfig;
       this.serverVersion = serverVersion;
       this.strictTck = strictTck;
       this.prefetchSize = prefetchSize;
-      this.dupsOKBatchSize = dupsOKBatchSize;
-      this.clientID = clientID;
    }
 
    public ClientConnectionFactoryImpl(RemotingConfiguration remotingConfig)
@@ -109,12 +94,12 @@
    {
    }
    
-   public ClientConnection createConnection() throws JMSException
+   public ClientConnection createConnection() throws MessagingException
    {
       return createConnection(null, null);
    }
    
-   public ClientConnection createConnection(String username, String password) throws JMSException
+   public ClientConnection createConnection(String username, String password) throws MessagingException
    {
       Version version = getVersionToUse(serverVersion);
       
@@ -131,20 +116,14 @@
          
          CreateConnectionRequest request =
             new CreateConnectionRequest(v, sessionID, JMSClientVMIdentifier.instance, username, password,
-                  prefetchSize, dupsOKBatchSize, clientID);
+                  prefetchSize);
          
          CreateConnectionResponse response =
             (CreateConnectionResponse)remotingConnection.send(id, request);
          
          ClientConnectionImpl connection =
-            new ClientConnectionImpl(response.getConnectionID(), serverID, strictTck, version, remotingConnection);
-         
-         //FIXME - get rid of this stupid ConsolidatedThingamajug bollocks
-         
-         ConsolidatedRemotingConnectionListener listener = new ConsolidatedRemotingConnectionListener(connection);
-         
-         remotingConnection.addConnectionListener(listener);
-         
+            new ClientConnectionImpl(response.getConnectionID(), serverID, strictTck, remotingConnection);
+
          return connection;
       }
       catch (Throwable t)
@@ -160,11 +139,18 @@
             }
          }
          
-         //TODO - we will sort out exception handling further in the refactoring
-         
-         log.error("Failed to start connection ", t);
-         
-         throw new MessagingJMSException("Failed to start connection", t);
+         if (t instanceof MessagingException)
+         {
+            throw (MessagingException)t;
+         }
+         else
+         {
+            MessagingException me = new MessagingException(MessagingException.INTERNAL_ERROR, "Failed to start connection");
+            
+            me.initCause(t);
+            
+            throw me;
+         }
       }
    }
    
@@ -175,11 +161,6 @@
       return remotingConfig;
    }
    
-   public int getServerID()
-   {
-      return serverID;
-   }
-   
    public Version getServerVersion()
    {
       return serverVersion;

Modified: trunk/src/main/org/jboss/jms/client/impl/ClientConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/impl/ClientConnectionImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/impl/ClientConnectionImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -26,35 +26,19 @@
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
-import javax.jms.ConnectionMetaData;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.IllegalStateException;
-import javax.jms.JMSException;
-import javax.jms.ServerSessionPool;
-import javax.jms.Session;
-
-import org.jboss.jms.client.JBossConnectionConsumer;
-import org.jboss.jms.client.JBossConnectionMetaData;
-import org.jboss.jms.client.api.ClientConnection;
 import org.jboss.jms.client.api.ClientSession;
-import org.jboss.jms.client.remoting.ConsolidatedRemotingConnectionListener;
+import org.jboss.jms.client.api.FailureListener;
 import org.jboss.jms.client.remoting.MessagingRemotingConnection;
-import org.jboss.jms.destination.JBossDestination;
 import org.jboss.messaging.core.remoting.wireformat.CloseMessage;
-import org.jboss.messaging.core.remoting.wireformat.ClosingMessage;
-import org.jboss.messaging.core.remoting.wireformat.CreateSessionRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateSessionResponse;
-import org.jboss.messaging.core.remoting.wireformat.GetClientIDRequest;
-import org.jboss.messaging.core.remoting.wireformat.GetClientIDResponse;
-import org.jboss.messaging.core.remoting.wireformat.SetClientIDMessage;
-import org.jboss.messaging.core.remoting.wireformat.StartConnectionMessage;
-import org.jboss.messaging.core.remoting.wireformat.StopConnectionMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionCreateSessionMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionCreateSessionResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionStartMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionStopMessage;
 import org.jboss.messaging.util.Logger;
-import org.jboss.messaging.util.Version;
+import org.jboss.messaging.util.MessagingException;
 
 /**
- * The client-side Connection delegate class.
+ * The client-side Connection connectionFactory class.
  *
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -65,7 +49,7 @@
  *
  * $Id: ClientConnectionImpl.java 3602 2008-01-21 17:48:32Z timfox $
  */
-public class ClientConnectionImpl implements ClientConnection
+public class ClientConnectionImpl implements ClientConnectionInternal
 {
    // Constants ------------------------------------------------------------------------------------
 
@@ -77,29 +61,21 @@
 
    private String id;
    
-   protected JBossConnectionMetaData connMetaData;
-
    private int serverID;
 
    private MessagingRemotingConnection remotingConnection;
 
-   private Version versionToUse;
-   
    private boolean strictTck;
    
    private Map<String, ClientSession> children = new ConcurrentHashMap<String, ClientSession>();
 
-   private boolean justCreated = true;
-
-   private String clientID;
-
    private volatile boolean closed;
 
    // Static ---------------------------------------------------------------------------------------
 
    // Constructors ---------------------------------------------------------------------------------
 
-   public ClientConnectionImpl(String id, int serverID, boolean strictTck, Version version,
+   public ClientConnectionImpl(String id, int serverID, boolean strictTck,
                                MessagingRemotingConnection connection)
    {
       this.id = id;
@@ -108,225 +84,98 @@
       
       this.strictTck = strictTck;
       
-      this.versionToUse = version;
-      
       this.remotingConnection = connection;
    }
-
-   // Closeable implementation ---------------------------------------------------------------------
-
-   public synchronized void close() throws JMSException
-   {
-      if (closed)
-      {
-         return;
-      }
-      
-      try
-      {
-         remotingConnection.send(id, new CloseMessage());
-      }
-      finally
-      {
-         // remove the consolidated remoting connection listener
-
-         ConsolidatedRemotingConnectionListener l = remotingConnection.removeConnectionListener();
-         
-         if (l != null)
-         {
-            l.clear();
-         }
-
-         // Finished with the connection - we need to shutdown callback server
-         remotingConnection.stop();
-
-         closed = true;
-      }
-   }
-
-   public synchronized void closing() throws JMSException
-   {
-      if (closed)
-      {
-         return;
-      }
-      
-      closeChildren();
-      
-      remotingConnection.send(id, new ClosingMessage());
-   }
    
-   // ClientConnection implementation ------------------------------------------------------------
+   // ClientConnection implementation --------------------------------------------------------------
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public JBossConnectionConsumer createConnectionConsumer(Destination dest,
-                                                           String subscriptionName,
-                                                           String messageSelector,
-                                                           ServerSessionPool sessionPool,
-                                                           int maxMessages) throws JMSException
+   public ClientSession createClientSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks,
+                                            int ackBatchSize) throws MessagingException
    {
       checkClosed();
-      
-      return new JBossConnectionConsumer(this, (JBossDestination)dest,
-                                         subscriptionName, messageSelector, sessionPool,
-                                         maxMessages);
-   }
 
+      ConnectionCreateSessionMessage request = new ConnectionCreateSessionMessage(xa, autoCommitSends, autoCommitAcks);
 
+      ConnectionCreateSessionResponseMessage response = (ConnectionCreateSessionResponseMessage)remotingConnection.send(id, request);   
 
-   public ClientSession createClientSession(boolean transacted,
-                                            int acknowledgementMode,
-                                            boolean isXA) throws JMSException
-   {
-      checkClosed();
-            
-      justCreated = false;
+      ClientSession session =  new ClientSessionImpl(this, response.getSessionID(), ackBatchSize);
 
-      CreateSessionRequest request = new CreateSessionRequest(transacted, acknowledgementMode, isXA);
-      
-      CreateSessionResponse response = (CreateSessionResponse)remotingConnection.send(id, request);   
-      
-      int ackBatchSize;
-      
-      if (transacted || acknowledgementMode == Session.CLIENT_ACKNOWLEDGE)
-      {
-         ackBatchSize = -1; //Infinite
-      }
-      else if (acknowledgementMode == Session.DUPS_OK_ACKNOWLEDGE)
-      {
-         ackBatchSize = response.getDupsOKBatchSize();
-      }
-      else
-      {
-         //Auto ack
-         ackBatchSize = 1;
-      }
-       
-      ClientSession session =  new ClientSessionImpl(this, response.getSessionID(), ackBatchSize, isXA);
-                  
       children.put(response.getSessionID(), session);
-      
+
       return session;
    }
-
-
-   public boolean isStrictTck()
+   
+   public void start() throws MessagingException
    {
-      return strictTck;
+      checkClosed();
+       
+      remotingConnection.send(id, new ConnectionStartMessage(), true);
    }
-
-   public String getClientID() throws JMSException
+   
+   public void stop() throws MessagingException
    {
       checkClosed();
       
-      justCreated = false;
-
-      if (clientID == null)
-      {
-         //Get from the server
-         clientID = ((GetClientIDResponse)remotingConnection.send(id, new GetClientIDRequest())).getClientID();
-      }
-      return clientID;
+      remotingConnection.send(id, new ConnectionStopMessage());
    }
-
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public ConnectionMetaData getConnectionMetaData() throws JMSException
+   
+   public FailureListener getFailureListener() throws MessagingException
    {
       checkClosed();
       
-      justCreated = false;
-
-      if (connMetaData == null)
-      {
-         connMetaData = new JBossConnectionMetaData(versionToUse);
-      }
-
-      return connMetaData;
+      return remotingConnection.getFailureListener();
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public ExceptionListener getExceptionListener() throws JMSException
+   public void setFailureListener(FailureListener listener) throws MessagingException
    {
-      justCreated = false;
-
-      return remotingConnection.getConnectionListener().getJMSExceptionListener(); 
-   }
-
-   public void setClientID(String clientID) throws JMSException
-   {
       checkClosed();
       
-      if (this.clientID != null)
+      remotingConnection.setFailureListener(listener);
+   }
+   
+   public synchronized void close() throws MessagingException
+   {
+      if (closed)
       {
-         throw new javax.jms.IllegalStateException("Client id has already been set");
+         return;
       }
-      if (!justCreated)
+      
+      try
       {
-         throw new IllegalStateException("setClientID can only be called directly after the connection is created");
+         closeChildren();
+         
+         remotingConnection.send(id, new CloseMessage());
       }
+      finally
+      {
+         remotingConnection.setFailureListener(null);
+         
+         // Finished with the connection - we need to shutdown callback server
+         remotingConnection.stop();
 
-      this.clientID = clientID;
-      
-      this.justCreated = false;
-
-      remotingConnection.send(id, new SetClientIDMessage(clientID));  
+         closed = true;
+      }
    }
-   
-   
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public void setExceptionListener(ExceptionListener listener) throws JMSException
-   {
-      checkClosed();
-      
-      justCreated = false;
 
-      remotingConnection.getConnectionListener().addJMSExceptionListener(listener);
-   }
-
-   public void start() throws JMSException
+   public boolean isClosed()
    {
-      checkClosed();
-      
-      justCreated = false;
-      
-      remotingConnection.send(id, new StartConnectionMessage(), true);
+      return closed;
    }
    
-   public void stop() throws JMSException
+   // ClientConnectionInternal implementation --------------------------------------------------------
+   
+   public int getServerID()
    {
-      checkClosed();
-      
-      justCreated = false;
-      
-      remotingConnection.send(id, new StopConnectionMessage());
+      return serverID;
    }
-
+   
    public MessagingRemotingConnection getRemotingConnection()
    {
       return remotingConnection;
    }
-
-   public int getServerID()
-   {
-      return serverID;
-   }
    
-   public void removeChild(String key) throws JMSException
+   public void removeChild(String key)
    {
-      checkClosed();
-      
       children.remove(key);
    }
 
@@ -338,15 +187,15 @@
 
    // Private --------------------------------------------------------------------------------------
    
-   private void checkClosed() throws IllegalStateException
+   private void checkClosed() throws MessagingException
    {
       if (closed)
       {
-         throw new IllegalStateException("Connection is closed");
+         throw new MessagingException(MessagingException.OBJECT_CLOSED, "Connection is closed");
       }
    }
    
-   private void closeChildren() throws JMSException
+   private void closeChildren() throws MessagingException
    {
       //We copy the set of children to prevent ConcurrentModificationException which would occur
       //when the child trues to remove itself from its parent
@@ -354,7 +203,6 @@
       
       for (ClientSession session: childrenClone)
       {
-         session.closing();
          session.close(); 
       }
    }

Added: trunk/src/main/org/jboss/jms/client/impl/ClientConnectionInternal.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/impl/ClientConnectionInternal.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/client/impl/ClientConnectionInternal.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.jms.client.impl;
+
+import org.jboss.jms.client.api.ClientConnection;
+import org.jboss.jms.client.remoting.MessagingRemotingConnection;
+
+/**
+ * 
+ * A ClientConnectionInternal
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface ClientConnectionInternal extends ClientConnection
+{
+   int getServerID();
+   
+   MessagingRemotingConnection getRemotingConnection();
+
+   void removeChild(String id);
+}

Modified: trunk/src/main/org/jboss/jms/client/impl/ClientConsumerImpl.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/impl/ClientConsumerImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/impl/ClientConsumerImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,30 +21,22 @@
   */
 package org.jboss.jms.client.impl;
 
-import javax.jms.IllegalStateException;
-import javax.jms.JMSException;
-
-import org.jboss.jms.client.api.ClientConsumer;
-import org.jboss.jms.client.api.ClientSession;
 import org.jboss.jms.client.api.MessageHandler;
 import org.jboss.jms.client.remoting.MessagingRemotingConnection;
-import org.jboss.messaging.core.Destination;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.PriorityLinkedList;
 import org.jboss.messaging.core.impl.PriorityLinkedListImpl;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
 import org.jboss.messaging.core.remoting.wireformat.CloseMessage;
-import org.jboss.messaging.core.remoting.wireformat.ClosingMessage;
 import org.jboss.messaging.core.remoting.wireformat.ConsumerChangeRateMessage;
 import org.jboss.messaging.core.remoting.wireformat.DeliverMessage;
 import org.jboss.messaging.util.Future;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
 
 /**
- * The client-side ClientConsumer delegate class.
- *
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -54,7 +46,7 @@
  *
  * $Id: ClientConsumerImpl.java 3603 2008-01-21 18:49:20Z timfox $
  */
-public class ClientConsumerImpl implements ClientConsumer
+public class ClientConsumerImpl implements ClientConsumerInternal
 {
    // Constants ------------------------------------------------------------------------------------
 
@@ -65,190 +57,42 @@
    // Attributes -----------------------------------------------------------------------------------
 
 	private String id;
-	private ClientSession session;
+	private ClientSessionInternal session;
    private int bufferSize;
-   private Destination destination;
-   private String selector;
-   private boolean noLocal;
    private PriorityLinkedList<DeliverMessage> buffer = new PriorityLinkedListImpl<DeliverMessage>(10);
    private volatile Thread receiverThread;
    private MessageHandler handler;
    private volatile boolean closed;
-   private boolean closing;
    private Object mainLock = new Object();
    private QueuedExecutor sessionExecutor;
    private boolean listenerRunning;
    private int consumeCount;
    private MessagingRemotingConnection remotingConnection;
-
+   private String queueName;
+   private long ignoreDeliveryMark = -1;
+   
    //FIXME - revisit closed and closing flags
    
    // Static ---------------------------------------------------------------------------------------
       
    // Constructors ---------------------------------------------------------------------------------
 
-   public ClientConsumerImpl(ClientSession session, String id, int bufferSize,
-                             Destination dest,
-                             String selector, boolean noLocal,
+   public ClientConsumerImpl(ClientSessionInternal session, String id, int bufferSize,
                              QueuedExecutor sessionExecutor,
-                             MessagingRemotingConnection remotingConnection)
+                             MessagingRemotingConnection remotingConnection,
+                             String queueName)
    {
       this.id = id;
       this.session = session;
       this.bufferSize = bufferSize;
-      this.destination = dest;
-      this.selector = selector;
-      this.noLocal = noLocal;
       this.sessionExecutor = sessionExecutor;
       this.remotingConnection = remotingConnection;    
+      this.queueName = queueName;
    }
 
-   // Closeable implementation ---------------------------------------------------------------------
-
-   public synchronized void close() throws JMSException
-   {
-      if (closed)
-      {
-         return;
-      }
+   // ClientConsumer implementation -----------------------------------------------------------------
       
-      try
-      {
-         remotingConnection.send(id, new CloseMessage());
-      }
-      finally
-      {
-         session.removeConsumer(this);
-         
-         closed = true;
-      }
-   }
-
-
-   public synchronized void closing() throws JMSException
-   {
-      if (closed)
-      {
-         return;       
-      }
-     
-      try
-      {
-         remotingConnection.send(id, new ClosingMessage());
-         
-         //Important! We set the handler to null so the next ListenerRunner won't run
-         if (handler != null)
-         {
-            setMessageHandler(null);
-         }
-         
-         //Now we wait for any current handler runners to run.
-         waitForOnMessageToComplete();   
-         
-         synchronized (mainLock)
-         {         
-            if (closing)
-            {
-               return;
-            }
-            
-            closing = true;   
-            
-            if (receiverThread != null)
-            {            
-               // Wake up any receive() thread that might be waiting
-               mainLock.notify();
-            }   
-            
-            this.handler = null;
-         }
-                              
-         if (trace) { log.trace(this + " closed"); }
-      }
-      finally
-      {
-         session.removeConsumer(this);
-      }
-
-      PacketDispatcher.client.unregister(id);
-   }
-
-
-   // ClientConsumer implementation --------------------------------------------------------------
-   
-   public String getID()
-   {
-      return id;
-   }
-      
-   public void changeRate(float newRate) throws JMSException
-   {
-      checkClosed();
-      
-      remotingConnection.send(id, new ConsumerChangeRateMessage(newRate), true);
-   }
-   
-   public MessageHandler getMessageHandler() throws JMSException
-   {
-      checkClosed();
-      
-      return handler;
-   }
-   
-   public void setMessageHandler(MessageHandler handler) throws JMSException
-   {  
-      checkClosed();
-      
-      synchronized (mainLock)
-      {
-         if (receiverThread != null)
-         {
-            // Should never happen
-            throw new IllegalStateException("ClientConsumer is currently in receive(..). " +
-               "Cannot set MessageListener");
-         }
-         
-         this.handler = handler;
-                            
-         if (handler != null && !buffer.isEmpty())
-         {  
-            listenerRunning = true;
-            
-            this.queueRunner(new ListenerRunner());
-         }        
-      }   
-   }
-   
-   public boolean getNoLocal() throws JMSException
-   {
-      checkClosed();
-      
-      return this.noLocal;
-   }
-
-   public Destination getDestination() throws JMSException
-   {
-      checkClosed();
-      
-      return this.destination;
-   }
-
-   public String getMessageSelector() throws JMSException
-   {
-      checkClosed();
-      
-      return this.selector;
-   }
-   
-   /**
-    * Method used by the client thread to synchronously get a Message, if available.
-    *
-    * @param timeout - the timeout value in milliseconds. A zero timeount never expires, and the
-    *        call blocks indefinitely. A -1 timeout means receiveNoWait(): return the next message
-    *        or null if one is not immediately available. Returns null if the consumer is
-    *        concurrently closed.
-    */
-   public Message receive(long timeout) throws JMSException
+   public Message receive(long timeout) throws MessagingException
    {      
       checkClosed();
       
@@ -258,17 +102,15 @@
       {        
          if (trace) { log.trace(this + " receiving, timeout = " + timeout); }
          
-         if (closing)
+         if (closed)
          {
-            // If consumer is closed or closing calling receive returns null
             if (trace) { log.trace(this + " closed, returning null"); }
             return null;
          }
          
          if (handler != null)
          {
-            throw new JMSException("The consumer has a MessageListener set, " +
-               "cannot call receive(..)");
+            throw new MessagingException(MessagingException.ILLEGAL_STATE, "Cannot call receive(...) - a MessageHandler is set");
          }
                        
          receiverThread = Thread.currentThread();
@@ -352,29 +194,119 @@
       return m.getMessage();
    } 
    
-//   public void addToFrontOfBuffer(JBossMessage proxy) throws JMSException
-//   {
-//      checkClosed();
-//      
-//      synchronized (mainLock)
-//      {
-//         buffer.addFirst(proxy, proxy.getJMSPriority());
-//         
-//         consumeCount--;
-//         
-//         messageAdded();
-//      }
-//   }
+   public Message receiveImmediate() throws MessagingException
+   { 
+      return receive(-1);
+   }
    
+   public MessageHandler getMessageHandler() throws MessagingException
+   {
+      checkClosed();
+      
+      return handler;
+   }
+   
+   public void setMessageHandler(MessageHandler handler) throws MessagingException
+   {  
+      checkClosed();
+      
+      synchronized (mainLock)
+      {
+         if (receiverThread != null)
+         {
+            throw new MessagingException(MessagingException.ILLEGAL_STATE, "Cannot set MessageHandler - consumer is in receive(...)");
+         }
+         
+         this.handler = handler;
+                            
+         if (handler != null && !buffer.isEmpty())
+         {  
+            listenerRunning = true;
+            
+            this.queueRunner(new ListenerRunner());
+         }        
+      }   
+   }
+   
+   public String getQueueName()
+   {
+      return queueName;
+   }
+      
+   public synchronized void close() throws MessagingException
+   {
+      if (closed)
+      {
+         return;
+      }
+               
+      try
+      {
+         //Important! We set the handler to null so the next ListenerRunner won't run
+         if (handler != null)
+         {
+            setMessageHandler(null);
+         }
+         
+         //Now we wait for any current handler runners to run.
+         waitForOnMessageToComplete();   
+         
+         //TODO sort out these close and closing flags
+         
+         synchronized (mainLock)
+         {                     
+            closed = true;
+                       
+            if (receiverThread != null)
+            {            
+               // Wake up any receive() thread that might be waiting
+               mainLock.notify();
+            }   
+            
+            this.handler = null;
+         }
+         
+         remotingConnection.send(id, new CloseMessage());
+         
+         PacketDispatcher.client.unregister(id);
+                                      
+         if (trace) { log.trace(this + " closed"); }
+                  
+      }
+      finally
+      {
+         session.removeConsumer(this);
+      }
+
+   }
+
+   public boolean isClosed()
+   {
+      return closed;
+   }
+
+   // ClientConsumerInternal implementation --------------------------------------------------------------
+   
+   public String getID()
+   {
+      return id;
+   }
+      
+   public void changeRate(float newRate) throws MessagingException
+   {
+      checkClosed();
+      
+      remotingConnection.send(id, new ConsumerChangeRateMessage(newRate), true);
+   }
+   
    public void handleMessage(final DeliverMessage message) throws Exception
    {
       synchronized (mainLock)
       {
-         if (closing)
+         if (closed)
          {
-            // Sanity - this should never happen - we should always wait for all deliveries to arrive
-            // when closing
-            throw new IllegalStateException(this + " is closed, so ignoring message");
+            //This is ok - we just ignore the message
+            return;
          }
                   
          if (ignoreDeliveryMark >= 0)
@@ -406,8 +338,6 @@
       }
    }
    
-   private long ignoreDeliveryMark = -1;
-   
    public void recover(long lastDeliveryID)
    {
       synchronized (mainLock)
@@ -426,7 +356,7 @@
             
    // Private --------------------------------------------------------------------------------------
    
-   private void checkSendChangeRate()
+   private void checkSendChangeRate() throws MessagingException
    {
       consumeCount++;
       
@@ -434,22 +364,10 @@
       {
          consumeCount = 0;
 
-         sendChangeRateMessage(1.0f);
+         changeRate(1.0f);
       }
    }
      
-   private void sendChangeRateMessage(float newRate) 
-   {
-      try
-      {
-         changeRate(newRate);
-      }
-      catch (JMSException e)
-      {
-         log.error("Failed to send changeRate message", e);
-      }
-   }
-   
    private void waitForOnMessageToComplete()
    {
       // Wait for any onMessage() executions to complete
@@ -468,9 +386,7 @@
       {
          sessionExecutor.execute(new Closer(result));
 
-         if (trace) { log.trace(this + " blocking wait for Closer execution"); }
          result.getResult();
-         if (trace) { log.trace(this + " got Closer result"); }
       }
       catch (InterruptedException e)
       {         
@@ -549,7 +465,7 @@
       }     
    }
         
-   private DeliverMessage getMessage(long timeout)
+   private DeliverMessage getMessage(long timeout) throws MessagingException
    {
       if (timeout == -1)
       {
@@ -562,7 +478,7 @@
             if (timeout == 0)
             {
                // wait for ever potentially
-               while (!closing && buffer.isEmpty())
+               while (!closed && buffer.isEmpty())
                {
                   if (trace) { log.trace(this + " waiting on main lock, no timeout"); }
 
@@ -576,7 +492,7 @@
                // wait with timeout
                long toWait = timeout;
              
-               while (!closing && buffer.isEmpty() && toWait > 0)
+               while (!closed && buffer.isEmpty() && toWait > 0)
                {
                   if (trace) { log.trace(this + " waiting on main lock, timeout " + toWait + " ms"); }
 
@@ -595,7 +511,7 @@
 
       DeliverMessage m = null;
              
-      if (!closing && !buffer.isEmpty())
+      if (!closed && !buffer.isEmpty())
       {
          m = buffer.removeFirst();
          
@@ -605,13 +521,14 @@
       return m;
    }
    
-   private void checkClosed() throws IllegalStateException
+   private void checkClosed() throws MessagingException
    {
       if (closed)
       {
-         throw new IllegalStateException("Consumer is closed");
+         throw new MessagingException(MessagingException.OBJECT_CLOSED, "Consumer is closed");
       }
    }
+
    
    // Inner classes --------------------------------------------------------------------------------
          
@@ -630,11 +547,7 @@
       
       public void run()
       {
-         if (trace) { log.trace("Closer starts running"); }
-
          result.setResult(null);
-
-         if (trace) { log.trace("Closer finished run"); }
       }
    }
    
@@ -645,74 +558,81 @@
    {
       public void run()
       {         
-         DeliverMessage msg = null;
-         
-         MessageHandler theListener = null;
-         
-         synchronized (mainLock)
+         try
          {
-            if (handler == null || buffer.isEmpty())
+            DeliverMessage msg = null;
+            
+            MessageHandler theListener = null;
+            
+            synchronized (mainLock)
             {
-               listenerRunning = false;
+               if (handler == null || buffer.isEmpty())
+               {
+                  listenerRunning = false;
+                  
+                  if (trace) { log.trace("no handler or buffer is empty, returning"); }
+                  
+                  return;
+               }
                
-               if (trace) { log.trace("no handler or buffer is empty, returning"); }
+               theListener = handler;
                
-               return;
+               // remove a message from the buffer
+   
+               msg = buffer.removeFirst();                
+               
+               checkSendChangeRate();
             }
             
-            theListener = handler;
+            /*
+             * Bug here is as follows:
+             * The next runner gets scheduled BEFORE the on message is executed
+             * so if the onmessage fails on acking it will be put on hold
+             * and failover will kick in, this will clear the executor
+             * so the next queud one disappears at everything grinds to a halt
+             * 
+             * Solution - don't use a session executor - have a session thread instead much nicer
+             */
+                                   
+            if (msg != null)
+            {     
+               boolean expired = msg.getMessage().isExpired();
+                           
+               session.delivered(msg.getDeliveryID(), expired);
+               
+               if (!expired)
+               {
+                  theListener.onMessage(msg.getMessage());
+               }
+            }
             
-            // remove a message from the buffer
-
-            msg = buffer.removeFirst();                
-            
-            checkSendChangeRate();
-         }
-         
-         /*
-          * Bug here is as follows:
-          * The next runner gets scheduled BEFORE the on message is executed
-          * so if the onmessage fails on acking it will be put on hold
-          * and failover will kick in, this will clear the executor
-          * so the next queud one disappears at everything grinds to a halt
-          * 
-          * Solution - don't use a session executor - have a session thread instead much nicer
-          */
-                                
-         if (msg != null)
-         {     
-            boolean expired = msg.getMessage().isExpired();
-                        
-            session.delivered(msg.getDeliveryID(), expired);
-            
-            if (!expired)
+            synchronized (mainLock)
             {
-               theListener.onMessage(msg.getMessage());
+               if (!buffer.isEmpty())
+               {
+                  //Queue up the next runner to run
+                  
+                  if (trace) { log.trace("More messages in buffer so queueing next onMessage to run"); }
+                  
+                  queueRunner(this);
+                  
+                  if (trace) { log.trace("Queued next onMessage to run"); }
+               }
+               else
+               {
+                  if (trace) { log.trace("no more messages in buffer, marking handler as not running"); }
+                  
+                  listenerRunning  = false;
+               }   
             }
+                     
+            if (trace) { log.trace("Exiting run()"); }
          }
-         
-         synchronized (mainLock)
+         catch (MessagingException e)
          {
-            if (!buffer.isEmpty())
-            {
-               //Queue up the next runner to run
-               
-               if (trace) { log.trace("More messages in buffer so queueing next onMessage to run"); }
-               
-               queueRunner(this);
-               
-               if (trace) { log.trace("Queued next onMessage to run"); }
-            }
-            else
-            {
-               if (trace) { log.trace("no more messages in buffer, marking handler as not running"); }
-               
-               listenerRunning  = false;
-            }   
+            log.error("Failure in ListenerRunner", e);
          }
-                  
-         if (trace) { log.trace("Exiting run()"); }
-      }
+      }      
    }   
   
 }

Added: trunk/src/main/org/jboss/jms/client/impl/ClientConsumerInternal.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/impl/ClientConsumerInternal.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/client/impl/ClientConsumerInternal.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.jms.client.impl;
+
+import org.jboss.jms.client.api.ClientConsumer;
+import org.jboss.messaging.core.remoting.wireformat.DeliverMessage;
+import org.jboss.messaging.util.MessagingException;
+
+/**
+ * 
+ * A ClientConsumerInternal
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface ClientConsumerInternal extends ClientConsumer
+{   
+   String getID();
+   
+   void changeRate(float newRate) throws MessagingException;
+
+   void handleMessage(DeliverMessage message) throws Exception;
+   
+   void recover(long lastDeliveryID) throws MessagingException;
+}

Modified: trunk/src/main/org/jboss/jms/client/impl/ClientConsumerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/impl/ClientConsumerPacketHandler.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/impl/ClientConsumerPacketHandler.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,10 +1,7 @@
 package org.jboss.jms.client.impl;
 
-import org.jboss.jms.client.api.ClientConsumer;
-import org.jboss.jms.message.JBossMessage;
 import org.jboss.messaging.core.remoting.PacketHandler;
 import org.jboss.messaging.core.remoting.PacketSender;
-import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
 import org.jboss.messaging.core.remoting.wireformat.DeliverMessage;
 import org.jboss.messaging.core.remoting.wireformat.Packet;
 import org.jboss.messaging.core.remoting.wireformat.PacketType;
@@ -20,16 +17,11 @@
 {
    private static final Logger log = Logger.getLogger(ClientConsumerImpl.class);
 
-   private final ClientConsumer clientConsumer;
+   private final ClientConsumerInternal clientConsumer;
 
    private final String consumerID;
 
-   /**
-    * @param messageHandler
-    * @param consumerID
-    */
-   public ClientConsumerPacketHandler(ClientConsumer clientConsumer,
-         String consumerID)
+   public ClientConsumerPacketHandler(ClientConsumerInternal clientConsumer, String consumerID)
    {
       this.clientConsumer = clientConsumer;
       
@@ -46,7 +38,7 @@
       try
       {
          PacketType type = packet.getType();
-         if (type == PacketType.MSG_DELIVERMESSAGE)
+         if (type == PacketType.SESS_DELIVER)
          {
             DeliverMessage message = (DeliverMessage) packet;
             
@@ -55,8 +47,7 @@
       }
       catch (Exception e)
       {
-         // TODO: Is there anything else to be done here if an exception happens?
-         log.error(e.getMessage(), e);
+         log.error("Failed to handle message", e);
       }
    }
 

Modified: trunk/src/main/org/jboss/jms/client/impl/ClientProducerImpl.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/impl/ClientProducerImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/impl/ClientProducerImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,37 +21,15 @@
   */
 package org.jboss.jms.client.impl;
 
-import java.util.UUID;
-
-import javax.jms.BytesMessage;
-import javax.jms.DeliveryMode;
-import javax.jms.IllegalStateException;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageFormatException;
-import javax.jms.ObjectMessage;
-import javax.jms.StreamMessage;
-import javax.jms.TextMessage;
-
 import org.jboss.jms.client.api.ClientProducer;
-import org.jboss.jms.client.api.ClientSession;
-import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.message.JBossBytesMessage;
-import org.jboss.jms.message.JBossMapMessage;
-import org.jboss.jms.message.JBossMessage;
-import org.jboss.jms.message.JBossObjectMessage;
-import org.jboss.jms.message.JBossStreamMessage;
-import org.jboss.jms.message.JBossTextMessage;
-import org.jboss.messaging.core.DestinationType;
-import org.jboss.messaging.core.impl.DestinationImpl;
+import org.jboss.messaging.core.Message;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
- * The client-side Producer delegate class.
+ * The client-side Producer connectionFactory class.
  *
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
  * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
  *
  * @version <tt>$Revision$</tt>
@@ -68,43 +46,29 @@
 
    private boolean trace = log.isTraceEnabled();
    
-   private ClientSession session;
+   private ClientSessionInternal session;
    
-   private JBossDestination destination;
-
-   private boolean disableMessageID = false;
-   
-   private boolean disableMessageTimestamp = false;
-   
-   private int priority = 4;
-   
-   private long timeToLive = 0;
-   
-   private int deliveryMode = DeliveryMode.PERSISTENT;
-   
-   private String id;
-   
    private volatile boolean closed;
    
    // Static ---------------------------------------------------------------------------------------
 
    // Constructors ---------------------------------------------------------------------------------
       
-   public ClientProducerImpl(ClientSession session, JBossDestination destination)
+   public ClientProducerImpl(ClientSessionInternal session)
    {
       this.session = session;
-      
-      this.destination = destination;
-      
-      this.id = UUID.randomUUID().toString();
    }
+   
+   // ClientProducer implementation ----------------------------------------------------------------
 
-   public String getID()
+   public void send(String address, Message message) throws MessagingException
    {
-      return id;
+      checkClosed();
+      
+      session.send(address, message);
    }
-
-   public synchronized void close() throws JMSException
+   
+   public synchronized void close() throws MessagingException
    {
       if (closed)
       {
@@ -115,264 +79,11 @@
       closed = true;
    }
 
-   public synchronized void closing() throws JMSException
-   {    
-   }
-
-   public JBossDestination getDestination() throws JMSException
+   public boolean isClosed()
    {
-      checkClosed();
-      
-      return this.destination;
+      return closed;
    }
-
-   public void send(JBossDestination destination, Message m, int deliveryMode, int priority,
-                    long timeToLive) throws JMSException
-   {
-      checkClosed();
-      
-      // configure the message for sending, using attributes stored as metadata
-
-      if (deliveryMode == -1)
-      {
-         // Use the delivery mode of the producer
-         deliveryMode = getDeliveryMode();
-         if (trace) { log.trace("Using producer's default delivery mode: " + deliveryMode); }
-      }
-      m.setJMSDeliveryMode(deliveryMode);
-
-      if (priority == -1)
-      {
-         // Use the priority of the producer
-         priority = getPriority();
-         if (trace) { log.trace("Using producer's default priority: " + priority); }
-      }
-      if (priority < 0 || priority > 9)
-      {
-         throw new MessageFormatException("Invalid message priority (" + priority + "). " +
-                                          "Valid priorities are 0-9");
-      }
-      m.setJMSPriority(priority);
-
-      if (this.isDisableMessageTimestamp())
-      {
-         m.setJMSTimestamp(0l);
-      }
-      else
-      {
-         m.setJMSTimestamp(System.currentTimeMillis());
-      }
-
-      if (timeToLive == Long.MIN_VALUE)
-      {
-         // Use time to live value from producer
-         timeToLive = getTimeToLive();
-         if (trace) { log.trace("Using producer's default timeToLive: " + timeToLive); }
-      }
-
-      if (timeToLive == 0)
-      {
-         // Zero implies never expires
-         m.setJMSExpiration(0);
-      }
-      else
-      {
-         m.setJMSExpiration(System.currentTimeMillis() + timeToLive);
-      }
-
-      if (destination == null)
-      {
-         // use destination from producer
-         destination = (JBossDestination)getDestination();
-
-         if (destination == null)
-         {
-            throw new UnsupportedOperationException("Destination not specified");
-         }
-
-         if (trace) { log.trace("Using producer's default destination: " + destination); }
-      }
-      else
-      {
-         // if a default destination was already specified then this must be same destination as
-         // that specified in the arguments
-
-         if (getDestination() != null &&
-             !getDestination().equals(destination))
-         {
-            throw new UnsupportedOperationException("Where a default destination is specified " +
-                                                    "for the sender and a destination is " +
-                                                    "specified in the arguments to the send, " +
-                                                    "these destinations must be equal");
-         }
-      }
-
-      JBossMessage jbm;
-
-      boolean foreign = false;
-
-      //First convert from foreign message if appropriate
-      if (!(m instanceof JBossMessage))
-      {
-         // it's a foreign message
-
-         // JMS 1.1 Sect. 3.11.4: A provider must be prepared to accept, from a client,
-         // a message whose implementation is not one of its own.
-
-         // create a matching JBossMessage Type from JMS Type
-         if (m instanceof BytesMessage)
-         {
-            jbm = new JBossBytesMessage((BytesMessage)m);
-         }
-         else if (m instanceof MapMessage)
-         {
-            jbm = new JBossMapMessage((MapMessage)m);
-         }
-         else if (m instanceof ObjectMessage)
-         {
-            jbm = new JBossObjectMessage((ObjectMessage)m);
-         }
-         else if (m instanceof StreamMessage)
-         {
-            jbm = new JBossStreamMessage((StreamMessage)m);
-         }
-         else if (m instanceof TextMessage)
-         {
-            jbm = new JBossTextMessage((TextMessage)m);
-         }
-         else
-         {
-            jbm = new JBossMessage(m);
-         }
-
-         //Set the destination on the original message
-         m.setJMSDestination(destination);
-
-         foreign = true;
-      }
-      else
-      {
-         jbm = (JBossMessage)m;
-      }
-
-      final boolean keepID = false;
-      
-      if (!keepID)
-      {
-         //Generate an id
-         
-         String id = UUID.randomUUID().toString();
-         
-         jbm.setJMSMessageID("ID:" + id);
-      }
-
-      if (foreign)
-      {
-         m.setJMSMessageID(jbm.getJMSMessageID());
-      }
-
-      jbm.setJMSDestination(destination);
-
-      try
-      {
-         jbm.doBeforeSend();
-      }
-      catch (Exception e)
-      {
-         JMSException exthrown = new JMSException (e.toString());
-         exthrown.initCause(e);
-         throw exthrown;
-      }
-
-      JBossDestination dest = (JBossDestination)destination;
-
-      //Set the destination on the core message - TODO temp for refactoring
-      org.jboss.messaging.core.Destination coreDest =
-         new DestinationImpl(dest.isQueue() ? DestinationType.QUEUE : DestinationType.TOPIC, dest.getName(), dest.isTemporary());
-      
-      //TODO - can optimise this copy to do copy lazily.
-      org.jboss.messaging.core.Message messageToSend = jbm.getCoreMessage().copy();
-
-      //FIXME - temp - for now we set destination as a header - should really be an attribute of the
-      //send packet - along with scheduleddelivery time
-
-      messageToSend.putHeader(org.jboss.messaging.core.Message.TEMP_DEST_HEADER_NAME, coreDest);
-
-      // we now invoke the send(Message) method on the session, which will eventually be fielded
-      // by connection endpoint
-      session.send(messageToSend);
-   }
-
-   public void setDeliveryMode(int deliveryMode) throws JMSException
-   {
-      checkClosed();
-      
-      this.deliveryMode = deliveryMode;
-   }
-
-   public int getDeliveryMode() throws JMSException
-   {
-      checkClosed();
-      
-      return this.deliveryMode;
-   }
-  
-   public boolean isDisableMessageID() throws JMSException
-   {
-      checkClosed();
-      
-      return this.disableMessageID;
-   }
-
-   public void setDisableMessageID(boolean value) throws JMSException
-   {
-      checkClosed();
-      
-      this.disableMessageID = value;   
-   }
-
-   public boolean isDisableMessageTimestamp() throws JMSException
-   {      
-      checkClosed();
-      
-      return this.disableMessageTimestamp;
-   }
-
-   public void setDisableMessageTimestamp(boolean value) throws JMSException
-   {
-      checkClosed();
-      
-      this.disableMessageTimestamp = value;
-   }
-
-   public void setPriority(int priority) throws JMSException
-   {
-      checkClosed();
-      
-      this.priority = priority;
-   }
-
-   public int getPriority() throws JMSException
-   {
-      checkClosed();
-      
-      return this.priority;
-   }
-
-   public long getTimeToLive() throws JMSException
-   {
-      checkClosed();
-      
-      return this.timeToLive;
-   }
-
-   public void setTimeToLive(long timeToLive) throws JMSException
-   {
-      checkClosed();
-      
-      this.timeToLive = timeToLive;
-   }
-
+   
    // Public ---------------------------------------------------------------------------------------
 
    // Protected ------------------------------------------------------------------------------------
@@ -381,11 +92,11 @@
 
    // Private --------------------------------------------------------------------------------------
 
-   private void checkClosed() throws IllegalStateException
+   private void checkClosed() throws MessagingException
    {
       if (closed)
       {
-         throw new IllegalStateException("Producer is closed");
+         throw new MessagingException(MessagingException.OBJECT_CLOSED, "Producer is closed");
       }
    }
    

Modified: trunk/src/main/org/jboss/jms/client/impl/ClientSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/impl/ClientSessionImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/impl/ClientSessionImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -27,61 +27,55 @@
 import java.util.Map;
 import java.util.Set;
 
-import javax.jms.IllegalStateException;
-import javax.jms.JMSException;
-import javax.jms.TransactionInProgressException;
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
 import org.jboss.jms.client.SelectorTranslator;
 import org.jboss.jms.client.api.ClientBrowser;
-import org.jboss.jms.client.api.ClientConnection;
 import org.jboss.jms.client.api.ClientConsumer;
 import org.jboss.jms.client.api.ClientProducer;
-import org.jboss.jms.client.api.ClientSession;
 import org.jboss.jms.client.remoting.MessagingRemotingConnection;
-import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.destination.JBossQueue;
-import org.jboss.jms.destination.JBossTopic;
-import org.jboss.messaging.core.Destination;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
 import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.AddTemporaryDestinationMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBindingQueryMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBindingQueryResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.CloseMessage;
-import org.jboss.messaging.core.remoting.wireformat.ClosingMessage;
-import org.jboss.messaging.core.remoting.wireformat.CreateBrowserRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateBrowserResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateConsumerRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateConsumerResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateDestinationRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateDestinationResponse;
-import org.jboss.messaging.core.remoting.wireformat.DeleteTemporaryDestinationMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateBrowserMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateBrowserResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateConsumerMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateConsumerResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateQueueMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionDeleteQueueMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionQueueQueryMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionQueueQueryResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionAcknowledgeMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionAddAddressMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionCancelMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionCommitMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionRemoveAddressMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionRollbackMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionSendMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXACommitMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAEndMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAForgetMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsRequest;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAJoinMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAPrepareMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAResumeMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXARollbackMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAStartMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXASuspendMessage;
-import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
 import org.jboss.messaging.util.ClearableQueuedExecutor;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
 
@@ -95,7 +89,7 @@
  *
  * $Id: ClientSessionImpl.java 3603 2008-01-21 18:49:20Z timfox $
  */
-public class ClientSessionImpl implements ClientSession
+public class ClientSessionImpl implements ClientSessionInternal
 {
    // Constants ------------------------------------------------------------------------------------
 
@@ -107,8 +101,6 @@
 
    private String id;
    
-   private boolean xa;
-
    private int lazyAckBatchSize;
    
    private volatile boolean closed;
@@ -130,21 +122,21 @@
 
    private MessagingRemotingConnection remotingConnection;
          
-   private ClientConnection connection;
+   private ClientConnectionInternal connection;
    
    private Set<ClientBrowser> browsers = new HashSet<ClientBrowser>();
    
    private Set<ClientProducer> producers = new HashSet<ClientProducer>();
    
-   private Map<String, ClientConsumer> consumers = new HashMap<String, ClientConsumer>();
+   private Map<String, ClientConsumerInternal> consumers = new HashMap<String, ClientConsumerInternal>();
    
    //For testing only
-   private boolean setForceNotSameRM;
-      
+   private boolean forceNotSameRM;
+   
    // Constructors ---------------------------------------------------------------------------------
    
-   public ClientSessionImpl(ClientConnection connection, String id,
-                            int lazyAckBatchSize, boolean xa)
+   public ClientSessionImpl(ClientConnectionInternal connection, String id,
+                            int lazyAckBatchSize) throws MessagingException
    {
       this.id = id;
       
@@ -152,146 +144,83 @@
       
       this.remotingConnection = connection.getRemotingConnection();
       
-      this.xa = xa;
- 
       executor = new ClearableQueuedExecutor(new LinkedQueue());
       
-      this.lazyAckBatchSize = lazyAckBatchSize;         
+      this.lazyAckBatchSize = lazyAckBatchSize;   
    }
    
-   // ClientSession implementation ----------------------------------------------------
-   
-   public String getID()
-   {
-      return id;
-   }
+   // ClientSession implementation -----------------------------------------------------------------
 
-   public synchronized void close() throws JMSException
+   public void createQueue(String address, String queueName, String filterString, boolean durable, boolean temporary)
+                           throws MessagingException
    {
-      if (closed)
-      {
-         return;
-      }
+      checkClosed();
 
-      try
-      {
-         remotingConnection.send(id, new CloseMessage());
-   
-         executor.shutdownNow();
-      }
-      finally
-      {
-         connection.removeChild(id);
-         
-         closed = true;
-      }
-   }
-  
-   public void closing() throws JMSException
-   {
-      if (closed)
-      {
-         return;
-      }
-      
-      closeChildren();
-      
-      //Make sure any remaining acks make it to the server
-      
-      acknowledgeInternal(false);      
-                 
-      ClosingMessage request = new ClosingMessage();
-      
+      SessionCreateQueueMessage request = new SessionCreateQueueMessage(address, queueName, filterString, durable, temporary);
+
       remotingConnection.send(id, request);
    }
 
-   public ClientConnection getConnection()
+   public void deleteQueue(String queueName) throws MessagingException
    {
-      return connection;
-   }
+      checkClosed();
 
-   public void addTemporaryDestination(Destination destination) throws JMSException
+      remotingConnection.send(id, new SessionDeleteQueueMessage(queueName));
+   }
+   
+   public SessionQueueQueryResponseMessage queueQuery(String queueName) throws MessagingException
    {
       checkClosed();
       
-      remotingConnection.send(id, new AddTemporaryDestinationMessage(destination), false);
+      SessionQueueQueryMessage request = new SessionQueueQueryMessage(queueName);
+      
+      SessionQueueQueryResponseMessage response = (SessionQueueQueryResponseMessage)remotingConnection.send(id, request);
+      
+      return response;
    }
-
-   public void commit() throws JMSException
+   
+   public SessionBindingQueryResponseMessage bindingQuery(String address) throws MessagingException
    {
       checkClosed();
-        
-      if (isXA())
-      {
-         throw new TransactionInProgressException("Cannot call commit on an XA session");
-      }
-
-      //Before committing we must make sure the acks make it to the server
-      //instead of this we could possibly add the lastDeliveryID in the SessionCommitMessage
-      acknowledgeInternal(false);
       
-      remotingConnection.send(id, new SessionCommitMessage());
+      SessionBindingQueryMessage request = new SessionBindingQueryMessage(address);
+      
+      SessionBindingQueryResponseMessage response = (SessionBindingQueryResponseMessage)remotingConnection.send(id, request);
+      
+      return response;
    }
    
-   public void rollback() throws JMSException
+   public void addAddress(String address) throws MessagingException
    {
       checkClosed();
-            
-      if (isXA())
-      {
-         throw new TransactionInProgressException("Cannot call rollback on an XA session");
-      }
       
-      //First we tell each consumer to clear it's buffers and ignore any deliveries with
-      //delivery id > last delivery id
+      SessionAddAddressMessage request = new SessionAddAddressMessage(address);
       
-      for (ClientConsumer consumer: consumers.values())
-      {
-         consumer.recover(lastID + 1);
-      }
-      
-      //Before rolling back we must make sure the acks make it to the server
-      //instead of this we could possibly add the lastDeliveryID in the SessionRollbackMessage
-      acknowledgeInternal(false);      
-
-      remotingConnection.send(id, new SessionRollbackMessage());
+      remotingConnection.send(id, request);
    }
-
-   public ClientBrowser createClientBrowser(Destination queue, String messageSelector)
-      throws JMSException
+   
+   public void removeAddress(String address) throws MessagingException
    {
       checkClosed();
       
-      String coreSelector = SelectorTranslator.convertToJBMFilterString(messageSelector);
+      SessionRemoveAddressMessage request = new SessionRemoveAddressMessage(address);
       
-      CreateBrowserRequest request = new CreateBrowserRequest(queue, coreSelector);
-      
-      CreateBrowserResponse response = (CreateBrowserResponse)remotingConnection.send(id, request);
-      
-      ClientBrowser browser = new ClientBrowserImpl(remotingConnection, this, response.getBrowserID());  
-      
-      browsers.add(browser);
-      
-      return browser;
+      remotingConnection.send(id, request);  
    }
    
-   public ClientConsumer createClientConsumer(Destination destination, String selector,
-                                              boolean noLocal, String subscriptionName) throws JMSException
+   public ClientConsumer createConsumer(String queueName, String filterString, boolean noLocal,
+                                        boolean autoDeleteQueue) throws MessagingException
    {
       checkClosed();
+    
+      SessionCreateConsumerMessage request =
+         new SessionCreateConsumerMessage(queueName, filterString, noLocal, autoDeleteQueue);
       
-      String coreSelector = SelectorTranslator.convertToJBMFilterString(selector);
+      SessionCreateConsumerResponseMessage response = (SessionCreateConsumerResponseMessage)remotingConnection.send(id, request);
       
-      CreateConsumerRequest request =
-         new CreateConsumerRequest(destination, coreSelector, noLocal, subscriptionName, false);
-      
-      CreateConsumerResponse response = (CreateConsumerResponse)remotingConnection.send(id, request);
-      
-      ClientConsumer consumer =
+      ClientConsumerInternal consumer =
          new ClientConsumerImpl(this, response.getConsumerID(), response.getBufferSize(),             
-                                destination,
-                                selector, noLocal,
-                                executor, remotingConnection);
+                                executor, remotingConnection, queueName);
 
       consumers.put(response.getConsumerID(), consumer);
 
@@ -304,56 +233,66 @@
       return consumer;
    }
    
-   public ClientProducer createClientProducer(JBossDestination destination) throws JMSException
+   public ClientBrowser createBrowser(String queueName, String messageSelector) throws MessagingException
    {
       checkClosed();
-      
-      ClientProducer producer = new ClientProducerImpl(this, destination);
-  
-      producers.add(producer);
-      
-      return producer;
+
+      String coreSelector = SelectorTranslator.convertToJBMFilterString(messageSelector);
+
+      SessionCreateBrowserMessage request = new SessionCreateBrowserMessage(queueName, coreSelector);
+
+      SessionCreateBrowserResponseMessage response = (SessionCreateBrowserResponseMessage)remotingConnection.send(id, request);
+
+      ClientBrowser browser = new ClientBrowserImpl(remotingConnection, this, response.getBrowserID());  
+
+      browsers.add(browser);
+
+      return browser;
    }
 
-   public JBossQueue createQueue(String queueName) throws JMSException
+   public ClientProducer createProducer() throws MessagingException
    {
       checkClosed();
-      
-      CreateDestinationRequest request = new CreateDestinationRequest(queueName, true);  
-      
-      CreateDestinationResponse response = (CreateDestinationResponse)remotingConnection.send(id, request);
-      
-      return (JBossQueue) response.getDestination();
+
+      ClientProducer producer = new ClientProducerImpl(this);
+
+      producers.add(producer);
+
+      return producer;
    }
    
-   public JBossTopic createTopic(String topicName) throws JMSException
+   public XAResource getXAResource()
    {
-      checkClosed();
-      
-      CreateDestinationRequest request = new CreateDestinationRequest(topicName, false); 
-      
-      CreateDestinationResponse response = (CreateDestinationResponse)remotingConnection.send(id, request);
-      
-      return (JBossTopic) response.getDestination();
+      return this;
    }
-
-   public void deleteTemporaryDestination(Destination destination) throws JMSException
+   
+   public void commit() throws MessagingException
    {
       checkClosed();
+        
+      acknowledgeInternal(false);
       
-      remotingConnection.send(id, new DeleteTemporaryDestinationMessage(destination));
+      remotingConnection.send(id, new SessionCommitMessage());
    }
    
-   //Internal method to be called from consumerImpl - should not expose this publicly
-   public void delivered(long deliverID, boolean expired)
+   public void rollback() throws MessagingException
    {
-      this.deliverID = deliverID;
+      checkClosed();
+            
+      //First we tell each consumer to clear it's buffers and ignore any deliveries with
+      //delivery id > last delivery id
       
-      this.deliveryExpired = expired;
+      for (ClientConsumerInternal consumer: consumers.values())
+      {
+         consumer.recover(lastID + 1);
+      }
+      
+      acknowledgeInternal(false);      
+
+      remotingConnection.send(id, new SessionRollbackMessage());
    }
    
-   //Called after a message has been delivered
-   public void delivered() throws JMSException
+   public void acknowledge() throws MessagingException
    {                        
       if (lastID + 1 != deliverID)
       {
@@ -389,43 +328,65 @@
          }                       
       }            
    }
-   
-   private void acknowledgeInternal(boolean block) throws JMSException
+
+   public synchronized void close() throws MessagingException
    {
-      if (acked)
+      if (closed)
       {
          return;
       }
-      
-      SessionAcknowledgeMessage message = new SessionAcknowledgeMessage(lastID, !broken);
-      remotingConnection.send(id, message, !block);
-      
-      acked = true;
+
+      try
+      {
+         closeChildren();
+         
+         //Make sure any remaining acks make it to the server
+         
+         acknowledgeInternal(false);      
+         
+         remotingConnection.send(id, new CloseMessage());
+   
+         executor.shutdownNow();
+      }
+      finally
+      {
+         connection.removeChild(id);
+         
+         closed = true;
+      }
    }
-      
-   public void unsubscribe(String subscriptionName) throws JMSException
+  
+   public boolean isClosed()
    {
-      checkClosed();
-      
-      remotingConnection.send(id, new UnsubscribeMessage(subscriptionName));
+      return closed;
    }
-
-   public XAResource getXAResource()
+   
+   // ClientSessionInternal implementation ------------------------------------------------------------
+   
+   public String getID()
    {
-      return this;
+      return id;
    }
+   
+   public ClientConnectionInternal getConnection()
+   {
+      return connection;
+   }
 
-   public void send(Message m) throws JMSException
+   public void delivered(long deliverID, boolean expired)
    {
-      checkClosed();
+      this.deliverID = deliverID;
       
-      SessionSendMessage message = new SessionSendMessage(m);
-      
-      remotingConnection.send(id, message, !m.isDurable());
+      this.deliveryExpired = expired;
    }
    
-   public void removeConsumer(ClientConsumer consumer) throws JMSException
+   public void flushAcks() throws MessagingException
    {
+      acknowledgeInternal(false);
+   }
+   
+   public void removeConsumer(ClientConsumerInternal consumer) throws MessagingException
+   {
       consumers.remove(consumer.getID());
             
       //1. flush any unacked message to the server
@@ -446,31 +407,16 @@
    {
       browsers.remove(browser);
    }
-     
-   public boolean isXA() throws JMSException
+   
+   public void send(String address, Message m) throws MessagingException
    {
       checkClosed();
       
-      return xa;
+      SessionSendMessage message = new SessionSendMessage(address, m);
+      
+      remotingConnection.send(id, message, !m.isDurable());
    }
-   
-//   public boolean isTransacted() throws JMSException
-//   {
-//      checkClosed();
-//      
-//      return transacted;
-//   }
-   
-   public boolean isClosed()
-   {
-      return closed;
-   }
-   
-   public void flushAcks() throws JMSException
-   {
-      this.acknowledgeInternal(false);
-   }
-   
+      
    // XAResource implementation --------------------------------------------------------------------
    
    public void commit(Xid xid, boolean onePhase) throws XAException
@@ -479,14 +425,14 @@
       { 
          SessionXACommitMessage packet = new SessionXACommitMessage(xid, onePhase);
                   
-         SessionXAResponse response = (SessionXAResponse)remotingConnection.send(id, packet);
+         SessionXAResponseMessage response = (SessionXAResponseMessage)remotingConnection.send(id, packet);
          
          if (response.isError())
          {
             throw new XAException(response.getResponseCode());
          }
       }
-      catch (JMSException e)
+      catch (MessagingException e)
       {
          log.error("Caught jmsexecptione ", e);
          //This should never occur
@@ -520,14 +466,14 @@
          //Need to flush any acks to server first
          acknowledgeInternal(false);
          
-         SessionXAResponse response = (SessionXAResponse)remotingConnection.send(id, packet);
+         SessionXAResponseMessage response = (SessionXAResponseMessage)remotingConnection.send(id, packet);
          
          if (response.isError())
          {
             throw new XAException(response.getResponseCode());
          }
       }
-      catch (JMSException e)
+      catch (MessagingException e)
       {
          log.error("Caught jmsexecptione ", e);
          //This should never occur
@@ -539,14 +485,14 @@
    {
       try
       {                              
-         SessionXAResponse response = (SessionXAResponse)remotingConnection.send(id, new SessionXAForgetMessage(xid));
+         SessionXAResponseMessage response = (SessionXAResponseMessage)remotingConnection.send(id, new SessionXAForgetMessage(xid));
          
          if (response.isError())
          {
             throw new XAException(response.getResponseCode());
          }
       }
-      catch (JMSException e)
+      catch (MessagingException e)
       {
          //This should never occur
          throw new XAException(XAException.XAER_RMERR);
@@ -557,12 +503,12 @@
    {
       try
       {                              
-         SessionXAGetTimeoutResponse response =
-            (SessionXAGetTimeoutResponse)remotingConnection.send(id, new SessionXAGetTimeoutMessage());
+         SessionXAGetTimeoutResponseMessage response =
+            (SessionXAGetTimeoutResponseMessage)remotingConnection.send(id, new SessionXAGetTimeoutMessage());
          
          return response.getTimeoutSeconds();
       }
-      catch (JMSException e)
+      catch (MessagingException e)
       {
          //This should never occur
          throw new XAException(XAException.XAER_RMERR);
@@ -592,7 +538,7 @@
       {
          SessionXAPrepareMessage packet = new SessionXAPrepareMessage(xid);
          
-         SessionXAResponse response = (SessionXAResponse)remotingConnection.send(id, packet);
+         SessionXAResponseMessage response = (SessionXAResponseMessage)remotingConnection.send(id, packet);
          
          if (response.isError())
          {
@@ -603,7 +549,7 @@
             return response.getResponseCode();
          }
       }
-      catch (JMSException e)
+      catch (MessagingException e)
       {
          log.error("Caught jmsexecptione ", e);
          //This should never occur
@@ -615,9 +561,9 @@
    {
       try
       {
-         SessionXAGetInDoubtXidsRequest packet = new SessionXAGetInDoubtXidsRequest();
+         SessionXAGetInDoubtXidsMessage packet = new SessionXAGetInDoubtXidsMessage();
          
-         SessionXAGetInDoubtXidsResponse response = (SessionXAGetInDoubtXidsResponse)remotingConnection.send(id, packet);
+         SessionXAGetInDoubtXidsResponseMessage response = (SessionXAGetInDoubtXidsResponseMessage)remotingConnection.send(id, packet);
          
          List<Xid> xids = response.getXids();
          
@@ -625,7 +571,7 @@
          
          return xidArray;
       }
-      catch (JMSException e)
+      catch (MessagingException e)
       {
          //This should never occur
          throw new XAException(XAException.XAER_RMERR);
@@ -639,14 +585,14 @@
 
          SessionXARollbackMessage packet = new SessionXARollbackMessage(xid);
          
-         SessionXAResponse response = (SessionXAResponse)remotingConnection.send(id, packet);
+         SessionXAResponseMessage response = (SessionXAResponseMessage)remotingConnection.send(id, packet);
          
          if (response.isError())
          {
             throw new XAException(response.getResponseCode());
          }
       }
-      catch (JMSException e)
+      catch (MessagingException e)
       {
          log.error("Caught jmsexecptione ", e);
          //This should never occur
@@ -658,12 +604,12 @@
    {
       try
       {                              
-         SessionXASetTimeoutResponse response =
-            (SessionXASetTimeoutResponse)remotingConnection.send(id, new SessionXASetTimeoutMessage(seconds));
+         SessionXASetTimeoutResponseMessage response =
+            (SessionXASetTimeoutResponseMessage)remotingConnection.send(id, new SessionXASetTimeoutMessage(seconds));
          
          return response.isOK();
       }
-      catch (JMSException e)
+      catch (MessagingException e)
       {
          //This should never occur
          throw new XAException(XAException.XAER_RMERR);
@@ -693,7 +639,7 @@
             throw new XAException(XAException.XAER_INVAL);
          }
                      
-         SessionXAResponse response = (SessionXAResponse)remotingConnection.send(id, packet);
+         SessionXAResponseMessage response = (SessionXAResponseMessage)remotingConnection.send(id, packet);
          
          if (response.isError())
          {
@@ -701,7 +647,7 @@
             throw new XAException(response.getResponseCode());
          }
       }
-      catch (JMSException e)
+      catch (MessagingException e)
       {
          log.error("Caught jmsexecptione ", e);
          //This should never occur
@@ -711,8 +657,6 @@
 
    // Public ---------------------------------------------------------------------------------------
   
-   private boolean forceNotSameRM;
-   
    public void setForceNotSameRM(boolean force)
    {
       this.forceNotSameRM = force;
@@ -724,23 +668,33 @@
 
    // Private --------------------------------------------------------------------------------------
 
-   private void checkClosed() throws IllegalStateException
+   private void acknowledgeInternal(boolean block) throws MessagingException
    {
+      if (acked)
+      {
+         return;
+      }
+      
+      SessionAcknowledgeMessage message = new SessionAcknowledgeMessage(lastID, !broken);
+      remotingConnection.send(id, message, !block);
+      
+      acked = true;
+   }
+   
+   private void checkClosed() throws MessagingException
+   {
       if (closed)
       {
-         throw new IllegalStateException("Session is closed");
+         throw new MessagingException(MessagingException.OBJECT_CLOSED, "Session is closed");
       }
    }
         
-   private void closeChildren() throws JMSException
+   private void closeChildren() throws MessagingException
    {
-
       Set<ClientConsumer> consumersClone = new HashSet<ClientConsumer>(consumers.values());
       
       for (ClientConsumer consumer: consumersClone)
       {
-         consumer.closing();
-         
          consumer.close();
       }
       
@@ -748,8 +702,6 @@
       
       for (ClientProducer producer: producersClone)
       {
-         producer.closing();
-         
          producer.close();
       }
       
@@ -757,8 +709,6 @@
       
       for (ClientBrowser browser: browsersClone)
       {
-         browser.closing();
-         
          browser.close();
       }
    }

Added: trunk/src/main/org/jboss/jms/client/impl/ClientSessionInternal.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/impl/ClientSessionInternal.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/client/impl/ClientSessionInternal.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.jms.client.impl;
+
+import org.jboss.jms.client.api.ClientBrowser;
+import org.jboss.jms.client.api.ClientProducer;
+import org.jboss.jms.client.api.ClientSession;
+import org.jboss.messaging.core.Message;
+import org.jboss.messaging.util.MessagingException;
+
+/**
+ * 
+ * A ClientSessionInternal
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface ClientSessionInternal extends ClientSession
+{
+   String getID();
+   
+   ClientConnectionInternal getConnection();
+      
+   void delivered(long deliveryID, boolean expired);
+   
+   void flushAcks() throws MessagingException;
+   
+   void removeConsumer(ClientConsumerInternal consumer) throws MessagingException;
+   
+   void removeProducer(ClientProducer producer);
+   
+   void removeBrowser(ClientBrowser browser);
+   
+   void send(String address, Message message) throws MessagingException;   
+}

Modified: trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -28,7 +28,7 @@
 
    private static final Random random = new Random();
 
-   // The index of the next delegate to be used
+   // The index of the next connectionFactory to be used
    private int next;
 
    private ClientConnectionFactoryImpl[] delegates;

Deleted: trunk/src/main/org/jboss/jms/client/remoting/ConsolidatedRemotingConnectionListener.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/ConsolidatedRemotingConnectionListener.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/remoting/ConsolidatedRemotingConnectionListener.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,131 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.jms.client.remoting;
-
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-
-import org.jboss.jms.client.api.ClientConnection;
-import org.jboss.messaging.util.Logger;
-
-/**
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- * 
- * FIXME - get rid of this class - it's not needed
- *
- * $Id$
- */
-public class ConsolidatedRemotingConnectionListener
-{
-   // Constants ------------------------------------------------------------------------------------
-
-   private static final Logger log = Logger.getLogger(ConsolidatedRemotingConnectionListener.class);
-
-   // Static ---------------------------------------------------------------------------------------
-
-   // Attributes -----------------------------------------------------------------------------------
-
-   private ClientConnection connection;
-
-   private ExceptionListener jmsExceptionListener;
-
-   // Constructors ---------------------------------------------------------------------------------
-
-   public ConsolidatedRemotingConnectionListener(ClientConnection connection)
-   {
-      this.connection = connection;
-   }
-
-   // ConnectionListener implementation ------------------------------------------------------------
-
-   public void handleConnectionException(Throwable throwable)
-   {
-      // forward the exception to delegate listener and JMS ExceptionListeners; synchronize
-      // to avoid race conditions
-
-      ExceptionListener jmsExceptionListenerCopy;
-  
-      synchronized(this)
-      {
-         jmsExceptionListenerCopy = jmsExceptionListener;
-      }
-      
-      if (jmsExceptionListenerCopy != null)
-      {
-         JMSException jmsException = null;
-
-         if (throwable instanceof Error)
-         {
-            final String msg = "Caught Error on underlying remoting connection";
-            log.error(this + ": " + msg, throwable);
-            jmsException = new JMSException(msg + ": " + throwable.getMessage());
-         }
-         else if (throwable instanceof Exception)
-         {
-            Exception e = (Exception)throwable;
-            jmsException = new JMSException("Failure on underlying remoting connection");
-            jmsException.setLinkedException(e);
-         }
-         else
-         {
-            // Some other Throwable subclass
-            final String msg = "Caught Throwable on underlying remoting connection";
-            log.error(this + ": " + msg, throwable);
-            jmsException = new JMSException(msg + ": " + throwable.getMessage());
-         }
-
-         jmsExceptionListenerCopy.onException(jmsException);
-      }
-   }
-
-   // Public ---------------------------------------------------------------------------------------
-
-   public synchronized void addJMSExceptionListener(ExceptionListener jmsExceptionListener)
-   {
-      log.trace(this + " adding JMS exception listener " + jmsExceptionListener);
-      this.jmsExceptionListener = jmsExceptionListener;
-   }
-
-   public synchronized ExceptionListener getJMSExceptionListener()
-   {
-      return jmsExceptionListener;
-   }
-
-   /**
-    * Clears all delegate listeners
-    */
-   public synchronized void clear()
-   {
-      jmsExceptionListener = null;
-      log.trace(this + " cleared");
-   }
-
-   public void setConnection(ClientConnection connection)
-   {
-      this.connection = connection;
-   }
-
-   public String toString()
-   {
-      if (connection == null)
-      {
-         return "ConsolidatedListener(UNINITIALIZED)";
-      }
-      return connection + ".ConsolidatedListener";
-   }
-
-   // Package protected ----------------------------------------------------------------------------
-
-   // Protected ------------------------------------------------------------------------------------
-
-   // Private --------------------------------------------------------------------------------------
-
-   // Inner classes --------------------------------------------------------------------------------
-
-}

Modified: trunk/src/main/org/jboss/jms/client/remoting/MessagingRemotingConnection.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/MessagingRemotingConnection.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/client/remoting/MessagingRemotingConnection.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -23,20 +23,15 @@
 
 import static org.jboss.messaging.core.remoting.ConnectorRegistrySingleton.REGISTRY;
 
-import java.io.IOException;
-
-import javax.jms.JMSException;
-
-import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.jms.exception.MessagingNetworkFailureException;
+import org.jboss.jms.client.api.FailureListener;
 import org.jboss.messaging.core.remoting.Client;
 import org.jboss.messaging.core.remoting.NIOConnector;
 import org.jboss.messaging.core.remoting.RemotingConfiguration;
 import org.jboss.messaging.core.remoting.impl.ClientImpl;
 import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
+import org.jboss.messaging.core.remoting.wireformat.MessagingExceptionMessage;
 import org.jboss.messaging.util.Logger;
-import org.jgroups.persistence.CannotConnectException;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * 
@@ -65,10 +60,6 @@
 
    private Client client;
 
-   // Maintaining a reference to the remoting connection listener for cases when we need to
-   // explicitly remove it from the remoting client
-   private ConsolidatedRemotingConnectionListener remotingConnectionListener;
-   
    // Constructors ---------------------------------------------------------------------------------
 
    public MessagingRemotingConnection(RemotingConfiguration remotingConfig) throws Exception
@@ -127,71 +118,65 @@
    /**
     * send the packet and block until a response is received (<code>oneWay</code> is set to <code>false</code>)
     */
-   public AbstractPacket send(String id, AbstractPacket packet) throws JMSException
+   public AbstractPacket send(String id, AbstractPacket packet) throws MessagingException
    {
       return send(id, packet, false);
    }
    
-   public AbstractPacket send(String id, AbstractPacket packet, boolean oneWay) throws JMSException
+   public AbstractPacket send(String id, AbstractPacket packet, boolean oneWay) throws MessagingException
    {
       assert packet != null;
 
       packet.setTargetID(id);
+      
+      AbstractPacket response;
+      
       try
+      {      
+         response = (AbstractPacket) client.send(packet, oneWay);
+      }
+      catch (Exception e)
       {
-         AbstractPacket response = (AbstractPacket) client.send(packet, oneWay);
+         log.error("Caught unexpected exception", e);
          
-         if (oneWay == false && response == null)
-         {
-            throw new IllegalStateException("No response received for " + packet);
-         }
+         throw new MessagingException(MessagingException.INTERNAL_ERROR);
+      }
+      
+      if (oneWay == false && response == null)
+      {
+         throw new IllegalStateException("No response received for " + packet);
+      }
+      
+      if (response instanceof MessagingExceptionMessage)
+      {
+         MessagingExceptionMessage message = (MessagingExceptionMessage) response;
          
-         if (response instanceof JMSExceptionMessage)
-         {
-            JMSExceptionMessage message = (JMSExceptionMessage) response;
-            
-            throw message.getException();
-         }
-         else
-         {
-            return response;
-         }
+         throw message.getException();
       }
-      catch (Throwable t)
+      else
       {
-         throw handleThrowable(t);
-      }     
+         return response;
+      } 
    }
    
-   public synchronized void addConnectionListener(ConsolidatedRemotingConnectionListener listener)
+   public synchronized void setFailureListener(FailureListener listener)
    {
-      this.remotingConnectionListener = listener;
       if (client != null)
-         client.addConnectionListener(remotingConnectionListener);
-      
+      {
+         client.setFailureListener(listener);
+      }
    }
 
-   public synchronized ConsolidatedRemotingConnectionListener getConnectionListener()
+   public synchronized FailureListener getFailureListener()
    {
-      return remotingConnectionListener;
-   }
-
-   /**
-    * May return null, if no connection listener was previously installed.
-    */
-   public synchronized ConsolidatedRemotingConnectionListener removeConnectionListener()
-   {
-      if (remotingConnectionListener == null)
+      if (client != null)
       {
+         return client.getFailureListener();
+      }
+      else
+      {
          return null;
       }
-
-      client.removeConnectionListener(remotingConnectionListener);
-
-      log.trace(this + " removed consolidated connection listener from " + client);
-      ConsolidatedRemotingConnectionListener toReturn = remotingConnectionListener;
-      remotingConnectionListener = null;
-      return toReturn;
    }
 
    // Package protected ----------------------------------------------------------------------------
@@ -200,47 +185,6 @@
 
    // Private --------------------------------------------------------------------------------------
    
-   private JMSException handleThrowable(Throwable t)
-   {
-      // ConnectionFailedException could happen during ConnectionFactory.createConnection.
-      // IOException could happen during an interrupted exception.
-      // CannotConnectionException could happen during a communication error between a connected
-      // remoting client and the server (what means any new invocation).
-
-      if (t instanceof JMSException)
-      {
-         return (JMSException)t;
-      }
-      else if ((t instanceof IOException))
-      {
-         return new MessagingNetworkFailureException((Exception)t);
-      }
-      //This can occur if failure happens when Client.connect() is called
-      //Ideally remoting should have a consistent API
-      else if (t instanceof RuntimeException)
-      {
-         RuntimeException re = (RuntimeException)t;
-
-         Throwable initCause = re.getCause();
-
-         if (initCause != null)
-         {
-            do
-            {
-               if ((initCause instanceof CannotConnectException) ||
-                        (initCause instanceof IOException))
-               {
-                  return new MessagingNetworkFailureException((Exception)initCause);
-               }
-               initCause = initCause.getCause();
-            }
-            while (initCause != null);
-         }
-      }
-
-      return new MessagingJMSException("Failed to invoke", t);
-   }  
-   
    // Inner classes --------------------------------------------------------------------------------
 
 }

Modified: trunk/src/main/org/jboss/jms/destination/JBossDestination.java
===================================================================
--- trunk/src/main/org/jboss/jms/destination/JBossDestination.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/destination/JBossDestination.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,9 +21,6 @@
   */
 package org.jboss.jms.destination;
 
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
 import java.io.Serializable;
 
 import javax.jms.Destination;
@@ -31,8 +28,6 @@
 import javax.naming.Reference;
 
 import org.jboss.jms.referenceable.SerializableObjectRefAddr;
-import org.jboss.messaging.core.DestinationType;
-import org.jboss.messaging.core.impl.DestinationImpl;
 
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -45,130 +40,21 @@
 {
    // Constants -----------------------------------------------------
 
-   private final static long serialVersionUID = -3483274922186827576L;
-   
-   private static final byte NULL = 0;
-   
-   private static final byte QUEUE = 1;
-   
-   private static final byte TOPIC = 2;
-   
-   private static final byte TEMP_QUEUE = 3;
-   
-   private static final byte TEMP_TOPIC = 4;
-   
    // Static --------------------------------------------------------
-   
-   public static JBossDestination fromCoreDestination(org.jboss.messaging.core.Destination destination)
-   {
-      if (destination.isTemporary())
-      {
-         if (destination.getType() == DestinationType.QUEUE)
-         {
-            return new JBossQueue(destination.getName());
-         }
-         else
-         {
-            return new JBossTopic(destination.getName());
-         }
-      }
-      else
-      {
-         if (destination.getType() == DestinationType.QUEUE)
-         {
-            return new JBossTemporaryQueue(destination.getName());
-         }
-         else
-         {
-            return new JBossTemporaryTopic(destination.getName());
-         }
-      }
-   }
-   
-   public static void writeDestination(DataOutputStream out, Destination dest) throws IOException
-   {
-      JBossDestination jb = (JBossDestination)dest;
-            
-      if (dest == null)
-      {
-         out.writeByte(NULL);
-      }
-      else
-      {
-         if (!jb.isTemporary())
-         {
-            if (jb.isQueue())
-            {
-               out.writeByte(QUEUE);
-            }
-            else 
-            {
-               out.writeByte(TOPIC);
-            }
-         }
-         else
-         {
-            if (jb.isQueue())
-            {
-               out.writeByte(TEMP_QUEUE);
-            }
-            else 
-            {
-               out.writeByte(TEMP_TOPIC);
-            }
-         }
-         out.writeUTF(jb.getName());
-      }
-   }
-   
-   public static JBossDestination readDestination(DataInputStream in) throws IOException
-   {
-      byte b = in.readByte();
       
-      if (b == NULL)
-      {
-         return null;
-      }
-      else
-      {
-         String name = in.readUTF();
-         
-         JBossDestination dest;
-         
-         if (b == QUEUE)
-         {
-            dest = new JBossQueue(name);
-         }
-         else if (b == TOPIC)
-         {
-            dest = new JBossTopic(name);
-         }
-         else if (b == TEMP_QUEUE)
-         {
-            dest = new JBossTemporaryQueue(name);
-         }
-         else if (b == TEMP_TOPIC)
-         {
-            dest = new JBossTemporaryTopic(name);
-         }
-         else
-         {
-            throw new IllegalStateException("Invalid value:" + b);
-         }
-         
-         return dest;
-      }
-   }
-
-   
    // Attributes ----------------------------------------------------
 
    protected String name;
    
+   private String address;
+   
+      
    // Constructors --------------------------------------------------
 
-   public JBossDestination(String name)
+   public JBossDestination(String address, String name)
    {
+      this.address = address;
+      
       this.name = name;
    }
    
@@ -184,67 +70,40 @@
 
    // Public --------------------------------------------------------
    
-   public String getName()
+   public String getAddress()
    {
-      return name;
+      return address;
    }
-
-   public abstract boolean isTopic();
    
-   public abstract boolean isQueue();
-   
-   public boolean isTemporary()
+   public String getName()
    {
-      return false;
+      return name;
    }
    
+   public abstract boolean isTemporary();
+
    public boolean equals(Object o)
    {
       if (this == o)
       {
          return true;
       }
+      
       if (!(o instanceof JBossDestination))
       {
          return false;
       }
+      
       JBossDestination that = (JBossDestination)o;
-      if (name == null)
-      {
-         return isTopic() == that.isTopic() && that.name == null;
-      }
-      return isTopic() == that.isTopic() && this.name.equals(that.name);
+      
+      return this.address.equals(that.address);      
    }
 
-   //Cache the hashCode
-   private int hash;
-   
    public int hashCode()
    {
-      if (hash != 0)
-      {
-         return hash;
-      }
-      else
-      {
-         int code = 0;
-         if (name != null)
-         {
-            code = name.hashCode();
-         }
-         hash = code + (isTopic() ? 37 : 71);
-         return hash;
-      }           
+      return address.hashCode();      
    }
    
-   public org.jboss.messaging.core.Destination toCoreDestination()
-   {
-      org.jboss.messaging.core.Destination dest =
-         new DestinationImpl(this.isQueue() ? DestinationType.QUEUE: DestinationType.TOPIC, name, isTemporary());
-      
-      return dest;
-   }
-   
    // Package protected ---------------------------------------------
    
    // Protected -----------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/destination/JBossQueue.java
===================================================================
--- trunk/src/main/org/jboss/jms/destination/JBossQueue.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/destination/JBossQueue.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -26,6 +26,7 @@
 
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @version <tt>$Revision$</tt>
  *
  * $Id$
@@ -35,6 +36,8 @@
    // Constants -----------------------------------------------------
    
    private static final long serialVersionUID = 4121129234371655479L;
+   
+   private static final String JMS_QUEUE_ADDRESS_PREFIX = "queuejms.";
 
    // Static --------------------------------------------------------
    
@@ -44,35 +47,28 @@
 
    public JBossQueue(String name)
    {
-      super(name);
+      super(JMS_QUEUE_ADDRESS_PREFIX + name, name);
    }
    
-   // JBossDestination overrides ------------------------------------
-
-   public boolean isTopic()
-   {
-      return false;
-   }
-
-   public boolean isQueue()
-   {
-      return true;
-   }
-
    // Queue implementation ------------------------------------------
 
    public String getQueueName() throws JMSException
    {
-      return getName();
+      return name;
    }
 
    // Public --------------------------------------------------------
    
+   public boolean isTemporary()
+   {
+      return false;
+   }
+   
    public String toString()
    {
       return "JBossQueue[" + name + "]";
    }
-
+   
    // Package protected ---------------------------------------------
    
    // Protected -----------------------------------------------------

Deleted: trunk/src/main/org/jboss/jms/destination/JBossTemporaryQueue.java
===================================================================
--- trunk/src/main/org/jboss/jms/destination/JBossTemporaryQueue.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/destination/JBossTemporaryQueue.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,98 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.jms.destination;
-
-import java.util.UUID;
-
-import javax.jms.JMSException;
-import javax.jms.TemporaryQueue;
-
-import org.jboss.jms.client.api.ClientSession;
-
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class JBossTemporaryQueue extends JBossQueue implements TemporaryQueue
-{
-   // Constants -----------------------------------------------------
-   
-   private static final long serialVersionUID = 4250425221695034957L;
-      
-   // Attributes ----------------------------------------------------
-   
-   private transient ClientSession delegate;
-   
-   
-   // Static --------------------------------------------------------
-   
-   // Constructors --------------------------------------------------
-   
-   public JBossTemporaryQueue(ClientSession delegate)
-   {
-      super(UUID.randomUUID().toString());
-      
-      this.delegate = delegate;
-   }
-   
-   public JBossTemporaryQueue(String name)
-   {
-      super(name);
-   }
-   
-   // TemporaryQueue implementation ---------------------------------
-   
-   public void delete() throws JMSException
-   {
-      if (delegate != null)
-      {
-         delegate.deleteTemporaryDestination(this.toCoreDestination());
-      }
-   }
-   
-   // JBossDestination overrides ------------------------------------
-   
-   public boolean isTemporary()
-   {
-      return true;
-   }
-
-   // Public --------------------------------------------------------
-
-   public String toString()
-   {
-      return "JBossTemporaryQueue[" + name + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-   
-   // Private -------------------------------------------------------
-   
-   // Inner classes -------------------------------------------------
-   
-  
-}

Deleted: trunk/src/main/org/jboss/jms/destination/JBossTemporaryTopic.java
===================================================================
--- trunk/src/main/org/jboss/jms/destination/JBossTemporaryTopic.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/destination/JBossTemporaryTopic.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,93 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.jms.destination;
-
-import java.util.UUID;
-
-import javax.jms.JMSException;
-import javax.jms.TemporaryTopic;
-
-import org.jboss.jms.client.api.ClientSession;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class JBossTemporaryTopic extends JBossTopic implements TemporaryTopic
-{
-   // Constants -----------------------------------------------------
-   
-   private static final long serialVersionUID = -1412919224718697967L;
-      
-   // Attributes ----------------------------------------------------
-   
-   private transient ClientSession delegate;
-   
-   // Static --------------------------------------------------------
-   
-   // Constructors --------------------------------------------------
-   
-   public JBossTemporaryTopic(ClientSession delegate)
-   {
-      super(UUID.randomUUID().toString());
-      
-      this.delegate = delegate;
-   }
-    
-   public JBossTemporaryTopic(String name)
-   {
-      super(name);
-   }
-   
-   // TemporaryQueue implementation ---------------------------------
-   
-   public void delete() throws JMSException
-   {
-      if (delegate != null) delegate.deleteTemporaryDestination(this.toCoreDestination());
-   }
-   
-   // JBossDestination overrides ------------------------------------
-   
-   public boolean isTemporary()
-   {
-      return true;
-   }
-
-   // Public --------------------------------------------------------
-
-   public String toString()
-   {
-      return "JBossTemporaryTopic[" + name + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-   
-   // Private -------------------------------------------------------
-   
-   // Inner classes -------------------------------------------------
-   
-
-}

Modified: trunk/src/main/org/jboss/jms/destination/JBossTopic.java
===================================================================
--- trunk/src/main/org/jboss/jms/destination/JBossTopic.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/destination/JBossTopic.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -26,6 +26,7 @@
 
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @version <tt>$Revision$</tt>
  *
  * $Id$
@@ -35,45 +36,45 @@
    // Constants -----------------------------------------------------
 
    private static final long serialVersionUID = 3257845497845724981L;
+   
+   private static final String JMS_TOPIC_ADDRESS_PREFIX = "topicjms.";
 
    // Static --------------------------------------------------------
    
+   public static String createQueueNameForDurableSubscription(String clientID, String subscriptionName)
+   {
+      return clientID + "." + subscriptionName;
+   }
+   
    // Attributes ----------------------------------------------------     
    
    // Constructors --------------------------------------------------
 
    public JBossTopic(String name)
    {
-      super(name);
+      super(JMS_TOPIC_ADDRESS_PREFIX + name, name);
    }
    
-
-   // JBossDestination overrides ------------------------------------
-
-   public boolean isTopic()
-   {
-      return true;
-   }
-
-   public boolean isQueue()
-   {
-      return false;
-   }
-
    // Topic implementation ------------------------------------------
 
    public String getTopicName() throws JMSException
    {
-      return getName();
+      return name;
    }
 
    // Public --------------------------------------------------------
 
+   public boolean isTemporary()
+   {
+      return false;
+   }   
+   
    public String toString()
    {
       return "JBossTopic[" + name + "]";
    }
-
+   
+  
    // Package protected ---------------------------------------------
    
    // Protected -----------------------------------------------------

Copied: trunk/src/main/org/jboss/jms/exception/JMSExceptionHelper.java (from rev 3654, trunk/src/main/org/jboss/jms/exception/MessagingJMSException.java)
===================================================================
--- trunk/src/main/org/jboss/jms/exception/JMSExceptionHelper.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/exception/JMSExceptionHelper.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,113 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.jms.exception;
+
+import javax.jms.InvalidDestinationException;
+import javax.jms.InvalidSelectorException;
+import javax.jms.JMSException;
+import javax.jms.JMSSecurityException;
+
+import org.jboss.messaging.util.MessagingException;
+
+/**
+ * 
+ * A JMSExceptionHelper
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class JMSExceptionHelper
+{
+   // Constants -----------------------------------------------------
+   
+   // Static --------------------------------------------------------
+   
+   public static JMSException convertFromMessagingException(MessagingException me)
+   {
+      JMSException je;
+      switch (me.getCode())
+      {
+         case MessagingException.CONNECTION_TIMEDOUT:
+            je = new JMSException(me.getMessage());
+            break;
+
+         case MessagingException.ILLEGAL_STATE:
+            je = new javax.jms.IllegalStateException(me.getMessage());
+            break;
+         
+         case MessagingException.INTERNAL_ERROR:
+            je =  new JMSException(me.getMessage());
+            break;
+            
+         case MessagingException.INVALID_FILTER_EXPRESSION:
+            je = new InvalidSelectorException(me.getMessage());
+            break;
+            
+         case MessagingException.NOT_CONNECTED:
+            je = new JMSException(me.getMessage());
+            break;
+            
+         case MessagingException.OBJECT_CLOSED:
+            je = new javax.jms.IllegalStateException(me.getMessage());
+            break;
+            
+         case MessagingException.QUEUE_DOES_NOT_EXIST:
+            je = new InvalidDestinationException(me.getMessage());
+            break;
+            
+         case MessagingException.QUEUE_EXISTS:
+            je = new InvalidDestinationException(me.getMessage());
+            break;
+            
+         case MessagingException.SECURITY_EXCEPTION:
+            je = new JMSSecurityException(me.getMessage());
+            break;
+            
+         case MessagingException.UNSUPPORTED_PACKET:
+            je =  new javax.jms.IllegalStateException(me.getMessage());
+            break;
+            
+         default:
+            je = new JMSException(me.getMessage());
+      }
+      
+      je.setStackTrace(me.getStackTrace());
+      
+      je.initCause(me);
+      
+      return je;
+   }
+   
+   // Attributes ----------------------------------------------------
+
+   // Constructors --------------------------------------------------
+  
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+   
+   // Protected -----------------------------------------------------
+   
+   // Private -------------------------------------------------------
+   
+   // Inner classes -------------------------------------------------   
+}

Deleted: trunk/src/main/org/jboss/jms/exception/MessagingJMSException.java
===================================================================
--- trunk/src/main/org/jboss/jms/exception/MessagingJMSException.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/exception/MessagingJMSException.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,89 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.jms.exception;
-
-import javax.jms.JMSException;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>1.1</tt>
- *
- * MessagingJMSException.java,v 1.1 2006/03/28 14:26:17 timfox Exp
- */
-public class MessagingJMSException extends JMSException
-{
-   // Constants -----------------------------------------------------
-   
-   private static final long serialVersionUID = -2234413113067993755L;
-
-   // Static --------------------------------------------------------
-   
-   
-   // Attributes ----------------------------------------------------
-
-   // Constructors --------------------------------------------------
-  
-   public MessagingJMSException(String reason) {
-     this(reason, null, null);
-   }
-
-   public MessagingJMSException(Throwable cause) {
-     this(null, null, cause);
-   }
-
-   public MessagingJMSException(String reason, String errorCode) {
-     this(reason, errorCode, null);
-   }
-
-   public MessagingJMSException(String reason, Throwable cause)
-   {
-      this(reason, null, cause);
-   }
-
-   public MessagingJMSException(String reason, String errorCode, Throwable cause)
-   {
-      super(reason, errorCode);
-      if (cause != null)
-      {
-         if (cause instanceof Exception)
-         {
-            setLinkedException((Exception)cause);
-         }
-         else
-         {
-            setLinkedException(new Exception(cause));
-         }
-
-         this.initCause(cause);
-      }
-   }
-
-   // Public --------------------------------------------------------
-
-   // Package protected ---------------------------------------------
-   
-   // Protected -----------------------------------------------------
-   
-   // Private -------------------------------------------------------
-   
-   // Inner classes -------------------------------------------------   
-}

Deleted: trunk/src/main/org/jboss/jms/exception/MessagingNetworkFailureException.java
===================================================================
--- trunk/src/main/org/jboss/jms/exception/MessagingNetworkFailureException.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/exception/MessagingNetworkFailureException.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.exception;
-
-/**
- * A MessagingNetworkFailureException
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class MessagingNetworkFailureException extends MessagingJMSException
-{
-   private static final long serialVersionUID = 1255764532063281353L;
-
-   public MessagingNetworkFailureException(Throwable cause)
-   {
-      super(cause);
-   }
-
-   public MessagingNetworkFailureException(String reason, String errorCode, Throwable cause)
-   {
-      super(reason, errorCode, cause);
-   }
-
-   public MessagingNetworkFailureException(String reason, String errorCode)
-   {
-      super(reason, errorCode);
-   }
-
-   public MessagingNetworkFailureException(String reason, Throwable cause)
-   {
-      super(reason, cause);
-   }
-
-   public MessagingNetworkFailureException(String reason)
-   {
-      super(reason);
-   }
-
-}

Deleted: trunk/src/main/org/jboss/jms/exception/MessagingShutdownException.java
===================================================================
--- trunk/src/main/org/jboss/jms/exception/MessagingShutdownException.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/exception/MessagingShutdownException.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,60 +0,0 @@
-/*
-   * JBoss, Home of Professional Open Source
-   * Copyright 2005, JBoss Inc., and individual contributors as indicated
-   * by the @authors tag. See the copyright.txt in the distribution for a
-   * full listing of individual contributors.
-   *
-   * This is free software; you can redistribute it and/or modify it
-   * under the terms of the GNU Lesser General Public License as
-   * published by the Free Software Foundation; either version 2.1 of
-   * the License, or (at your option) any later version.
-   *
-   * This software is distributed in the hope that it will be useful,
-   * but WITHOUT ANY WARRANTY; without even the implied warranty of
-   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   * Lesser General Public License for more details.
-   *
-   * You should have received a copy of the GNU Lesser General Public
-   * License along with this software; if not, write to the Free
-   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-   */
-
-package org.jboss.jms.exception;
-
-/**
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @version <tt>$Revision$</tt>
- *          $Id$
- */
-public class MessagingShutdownException extends MessagingJMSException
-{
-   private static final long serialVersionUID = -2234413113067993577L;
-
-   // Constructors ---------------------------------------------------------------------------------
-
-   public MessagingShutdownException(String reason)
-   {
-      super(reason);
-   }
-
-   public MessagingShutdownException(Throwable cause)
-   {
-      super(cause);
-   }
-
-   public MessagingShutdownException(String reason, String errorCode)
-   {
-      super(reason, errorCode);
-   }
-
-   public MessagingShutdownException(String reason, Throwable cause)
-   {
-      super(reason, cause);
-   }
-
-   public MessagingShutdownException(String reason, String errorCode, Throwable cause)
-   {
-      super(reason, errorCode, cause);
-   }
-}

Deleted: trunk/src/main/org/jboss/jms/exception/MessagingTransactionRolledBackException.java
===================================================================
--- trunk/src/main/org/jboss/jms/exception/MessagingTransactionRolledBackException.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/exception/MessagingTransactionRolledBackException.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,92 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.jms.exception;
-
-import javax.jms.TransactionRolledBackException;
-
-/**
- * 
- * A JBossTransactionRolledBackException.
- * 
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class MessagingTransactionRolledBackException extends TransactionRolledBackException
-{
-   // Constants -----------------------------------------------------
-   
-   private static final long serialVersionUID = -1395246656299977995L;
-
-   // Static --------------------------------------------------------
-      
-   // Attributes ----------------------------------------------------
-   
-   // Constructors --------------------------------------------------
-   
-   public MessagingTransactionRolledBackException(String reason)
-   {
-      this(reason, null, null);
-   }
-   
-   public MessagingTransactionRolledBackException(Exception cause)
-   {
-      this(null, null, cause);
-   }
-   
-   public MessagingTransactionRolledBackException(String reason, String errorCode)
-   {
-      this(reason, errorCode, null);
-   }
-   
-   public MessagingTransactionRolledBackException(String reason, Throwable cause)
-   {
-      this(reason, null, cause);
-   }
-   
-   public MessagingTransactionRolledBackException(String reason, String errorCode, Throwable cause)
-   {
-      super(reason, errorCode);
-      if (cause != null)
-      {
-         if (cause instanceof Exception)
-         {
-            setLinkedException((Exception)cause);
-         }
-         else
-         {
-            setLinkedException(new Exception(cause));
-         }
-      }
-   }
-   
-   // Public --------------------------------------------------------
-   
-   // Package protected ---------------------------------------------
-   
-   // Protected -----------------------------------------------------
-   
-   // Private -------------------------------------------------------
-   
-   // Inner classes -------------------------------------------------  
-}

Deleted: trunk/src/main/org/jboss/jms/exception/MessagingXAException.java
===================================================================
--- trunk/src/main/org/jboss/jms/exception/MessagingXAException.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/exception/MessagingXAException.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,81 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.jms.exception;
-
-import javax.transaction.xa.XAException;
-
-/**
- * 
- * A MessagingXAException
-
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- *
- */
-public class MessagingXAException extends XAException
-{
-   private static final long serialVersionUID = 1144870736311098699L;
-   
-   private Throwable cause;
-   
-   private String msg;
-   
-   public MessagingXAException(int code)
-   {
-      super(code);
-   }
-   
-   public MessagingXAException(int code, Throwable cause)
-   {
-      super(code);
-      
-      this.cause = cause;
-   }
-   
-   public MessagingXAException(int code, String msg)
-   {
-      super(code);
-      
-      this.msg = msg;
-   }
-   
-   public MessagingXAException(int code, String msg, Throwable cause)
-   {
-      super(code);
-      
-      this.msg = msg;
-      
-      this.cause = cause;
-   }
-   
-   public Throwable getCause()
-   {
-      return cause;
-   }
-   
-   public String getMessage()
-   {
-      return msg;
-   }
-}

Modified: trunk/src/main/org/jboss/jms/jndi/JNDIObjectDeployer.java
===================================================================
--- trunk/src/main/org/jboss/jms/jndi/JNDIObjectDeployer.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/jndi/JNDIObjectDeployer.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -62,8 +62,8 @@
    MessagingServer messagingServer;
 
    private static final String CLIENTID_ELEMENT = "client-id";
+   private static final String DUPS_OK_BATCH_SIZE_ELEMENT = "dups-ok-batch-size";
    private static final String PREFETECH_SIZE_ELEMENT = "prefetch-size";
-   private static final String DUPS_OK_BATCH_SIZE = "dups-ok-batch-size";
    private static final String SUPPORTS_FAILOVER = "supports-failover";
    private static final String SUPPORTS_LOAD_BALANCING = "supports-load-balancing";
    private static final String LOAD_BALANCING_FACTORY = "load-balancing-factory";
@@ -152,7 +152,11 @@
             try
             {
                initialContext.lookup(jndiName);
-               throw new InvalidDestinationException("Destination " + jndiName + " already exists");
+               //throw new InvalidDestinationException("Destination " + jndiName + " already exists");
+               
+               log.warn("Destination " + jndiName + " already exists");
+               
+               return;
             }
             catch (NameNotFoundException e)
             {
@@ -188,9 +192,9 @@
 
          NodeList attributes = node.getChildNodes();
          boolean cfStrictTck = false;
-         int prefetchSize = 150;
-         int dupsOKBatchSize = 1000;
+         int prefetchSize = 150;  
          String clientID = null;
+         int dupsOKBatchSize = 1000;
          for (int j = 0; j < attributes.getLength(); j++)
          {
             if (STRICT_TCK.equalsIgnoreCase(attributes.item(j).getNodeName()))
@@ -205,7 +209,7 @@
             {
                clientID = attributes.item(j).getTextContent();
             }
-            if (DUPS_OK_BATCH_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            else if (this.DUPS_OK_BATCH_SIZE_ELEMENT.equalsIgnoreCase(attributes.item(j).getNodeName()))
             {
                dupsOKBatchSize = Integer.parseInt(attributes.item(j).getTextContent().trim());
             }
@@ -222,34 +226,28 @@
                //setLoadBalancingFactory(attributes.item(j).getTextContent().trim());
             }
          }
-//       The server peer strict setting overrides the connection factory
+
          boolean useStrict = messagingServer.getConfiguration().isStrictTck() || cfStrictTck;
 
          ClientConnectionFactoryImpl delegate =
                  new ClientConnectionFactoryImpl(messagingServer.getConfiguration().getMessagingServerID(),
-                         remotingConfig, version, useStrict, prefetchSize, dupsOKBatchSize, clientID);
+                         remotingConfig, version, useStrict, prefetchSize);
 
-         log.debug(this + " created local delegate " + delegate);
+         log.debug(this + " created local connectionFactory " + delegate);
 
-         // Registering with the dispatcher should always be the last thing otherwise a client could
-         // use a partially initialised object
-
-         //messagingServer.getMinaService().getDispatcher().register(endpoint.newHandler());
-         return new JBossConnectionFactory(delegate);
+         return new JBossConnectionFactory(delegate, clientID, dupsOKBatchSize);
       }
       else if (node.getNodeName().equals(QUEUE_NODE_NAME))
       {
          String queueName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
          messagingServer.createQueue(queueName);
          return new JBossQueue(queueName);
-
       }
       else if (node.getNodeName().equals(TOPIC_NODE_NAME))
       {
          String topicName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
          messagingServer.createTopic(topicName);
          return new JBossTopic(topicName);
-
       }
       return null;
    }

Modified: trunk/src/main/org/jboss/jms/message/JBossBytesMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossBytesMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/message/JBossBytesMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -34,7 +34,7 @@
 import javax.jms.MessageFormatException;
 
 import org.jboss.jms.client.api.ClientSession;
-import org.jboss.jms.exception.MessagingJMSException;
+import org.jboss.jms.exception.JMSExceptionHelper;
 
 /**
  * This class implements javax.jms.BytesMessage.
@@ -115,7 +115,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -132,7 +134,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -149,7 +153,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -166,7 +172,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -183,7 +191,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -200,7 +210,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -217,7 +229,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -234,7 +248,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -251,7 +267,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -268,7 +286,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -285,7 +305,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -298,7 +320,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -311,7 +335,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -324,7 +350,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -337,7 +365,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -350,7 +380,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -363,7 +395,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -376,7 +410,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -389,7 +425,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -402,7 +440,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -415,7 +455,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -428,7 +470,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -441,7 +485,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -455,7 +501,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 
@@ -509,7 +557,9 @@
       }
       catch (IOException e)
       {
-         throw new MessagingJMSException("IOException", e);
+         JMSException je = new JMSException("IOException");
+         je.initCause(e);
+         throw je;
       }
    }
 

Modified: trunk/src/main/org/jboss/jms/message/JBossMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/message/JBossMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -39,9 +39,10 @@
 import javax.jms.MessageNotWriteableException;
 
 import org.jboss.jms.client.api.ClientSession;
-import org.jboss.jms.exception.MessagingJMSException;
+import org.jboss.jms.exception.JMSExceptionHelper;
 import org.jboss.messaging.core.impl.MessageImpl;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * 
@@ -74,8 +75,6 @@
 
    private static final String JBM_MESSAGE_ID = "JMSMessageID";
    
-   //private static final String CORRELATIONIDBYTES_HEADER_NAME = "JMSCorre";
-   
    private static final String TYPE_HEADER_NAME = "JMSType";
    
    public static final String JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME = "JMS_JBOSS_SCHEDULED_DELIVERY";
@@ -347,7 +346,7 @@
       }
       else
       {
-         throw new MessagingJMSException("DeliveryImpl mode must be either DeliveryMode.PERSISTENT "
+         throw new JMSException("DeliveryImpl mode must be either DeliveryMode.PERSISTENT "
                + "or DeliveryMode.NON_PERSISTENT");
       }
    }
@@ -743,7 +742,18 @@
    
    public void acknowledge() throws JMSException
    {
-      session.commit();
+      try
+      {
+         session.commit();
+      }
+      catch (MessagingException e)
+      {
+         JMSException je = new JMSException(e.toString());
+         
+         je.initCause(e);
+         
+         throw je;         
+      } 
    }
     
    // Public --------------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/server/SecurityStore.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/SecurityStore.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/server/SecurityStore.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -23,13 +23,12 @@
 
 import java.util.HashSet;
 
-import javax.jms.JMSSecurityException;
 import javax.security.auth.Subject;
 
 import org.jboss.jms.server.security.CheckType;
 import org.jboss.jms.server.security.Role;
-import org.jboss.messaging.core.Destination;
 import org.jboss.messaging.util.HierarchicalRepository;
+import org.jboss.messaging.util.MessagingException;
 
 
 /**
@@ -40,27 +39,10 @@
  */
 public interface SecurityStore
 {
-   /**
-    * Authenticate the specified user with the given password. Implementations are most likely to
-    * delegates to a JBoss AuthenticationManager.
-    *
-    * Successful autentication will place a new SubjectContext on thread local, which will be used
-    * in the authorization process. However, we need to make sure we clean up thread local
-    * immediately after we used the information, otherwise some other people security my be screwed
-    * up, on account of thread local security stack being corrupted.
-    *
-    * @throws JMSSecurityException if the user is not authenticated
-    */
-   Subject authenticate(String user, String password) throws JMSSecurityException;
 
-   /**
-    * Authorize that the subject has at least one of the specified roles. Implementations are most
-    * likely to delegates to a JBoss AuthenticationManager.
-    *
-    * @param rolePrincipals - The set of roles allowed to read/write/create the destination.
-    * @return true if the subject is authorized, or false if not.
-    */
-   boolean authorize(String user,  Destination destination, CheckType checkType);
+   Subject authenticate(String user, String password) throws MessagingException;
 
+   boolean authorize(String user, String destination, CheckType checkType);
+
    void setSecurityRepository(HierarchicalRepository<HashSet<Role>> securityRepository);
 }

Deleted: trunk/src/main/org/jboss/jms/server/TransactionRepository.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/TransactionRepository.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/server/TransactionRepository.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,36 +0,0 @@
-package org.jboss.jms.server;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.transaction.xa.Xid;
-
-import org.jboss.messaging.core.Transaction;
-
-
-//FIXME temp class
-public class TransactionRepository
-{
-   private Map<Xid, Transaction> map;
-   
-   public TransactionRepository()
-   {
-      map = new ConcurrentHashMap<Xid, Transaction>();
-   }
-   
-   public void addTransaction(Xid xid, Transaction transaction)
-   {
-      map.put(xid, transaction);
-   }
-   
-   public Transaction getTransaction(Xid xid)
-   {
-      return map.get(xid);
-   }
-   
-   public Transaction removeTransaction(Xid xid)
-   {
-      return map.remove(xid);
-   }
-      
-}

Modified: trunk/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -31,8 +31,6 @@
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
-import javax.jms.JMSException;
-
 import org.jboss.jms.server.ConnectionManager;
 import org.jboss.jms.server.endpoint.ServerConnectionEndpoint;
 import org.jboss.messaging.core.remoting.ConnectionExceptionListener;
@@ -277,11 +275,10 @@
             try
             {
       			log.debug("clearing up state for connection " + sce);
-               sce.closing();
                sce.close();
                log.debug("cleared up state for connection " + sce);
             }
-            catch (JMSException e)
+            catch (Exception e)
             {
                log.error("Failed to close connection", e);
             }          

Modified: trunk/src/main/org/jboss/jms/server/container/SecurityAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/container/SecurityAspect.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/server/container/SecurityAspect.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -29,8 +29,8 @@
 import org.jboss.jms.server.SecurityStore;
 import org.jboss.jms.server.endpoint.ServerConnectionEndpoint;
 import org.jboss.jms.server.security.CheckType;
-import org.jboss.messaging.core.Destination;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * This aspect enforces the JBossMessaging JMS security policy.
@@ -62,9 +62,9 @@
 
    private boolean trace = log.isTraceEnabled();
 
-   private Set<Destination> readCache;
+   private Set<String> readCache;
 
-   private Set<Destination> writeCache;
+   private Set<String> writeCache;
 
    private Set createCache;
 
@@ -78,11 +78,11 @@
    // Public --------------------------------------------------------
    public SecurityAspect()
    {
-      readCache = new HashSet();
+      readCache = new HashSet<String>();
 
-      writeCache = new HashSet();
+      writeCache = new HashSet<String>();
 
-      createCache = new HashSet();
+      createCache = new HashSet<String>();
    }
 
    // Package protected ---------------------------------------------
@@ -91,7 +91,7 @@
 
    // Private -------------------------------------------------------
 
-   public boolean checkCached(Destination dest, CheckType checkType)
+   public boolean checkCached(String dest, CheckType checkType)
    {
       long now = System.currentTimeMillis();
 
@@ -136,15 +136,9 @@
       return granted;
    }
 
-   public void check(Destination dest, CheckType checkType, ServerConnectionEndpoint conn)
-      throws JMSSecurityException
+   public void check(String dest, CheckType checkType, ServerConnectionEndpoint conn)
+      throws MessagingException
    {
-      if (dest.isTemporary())
-      {
-         if (trace) { log.trace("skipping permission check on temporary destination " + dest); }
-         return;
-      }
-
       if (trace) { log.trace("checking access permissions to " + dest); }
 
       if (checkCached(dest, checkType))
@@ -153,8 +147,6 @@
          return;
       }
 
-      String name = dest.getName();
-
       SecurityStore sm = conn.getSecurityManager();
 
       // Authenticate. Successful autentication will place a new SubjectContext on thread local,
@@ -173,9 +165,9 @@
                " is not authorized to " +
                (checkType == CheckType.READ ? "read from" :
                   checkType == CheckType.WRITE ? "write to" : "create durable sub on") +
-               " destination " + name;
+               " destination " + dest;
 
-            throw new JMSSecurityException(msg);
+            throw new MessagingException(MessagingException.SECURITY_EXCEPTION, msg);
          }
       }
       finally

Deleted: trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryAdvisedPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryAdvisedPacketHandler.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryAdvisedPacketHandler.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,195 +0,0 @@
-/*
-   * JBoss, Home of Professional Open Source
-   * Copyright 2005, JBoss Inc., and individual contributors as indicated
-   * by the @authors tag. See the copyright.txt in the distribution for a
-   * full listing of individual contributors.
-   *
-   * This is free software; you can redistribute it and/or modify it
-   * under the terms of the GNU Lesser General Public License as
-   * published by the Free Software Foundation; either version 2.1 of
-   * the License, or (at your option) any later version.
-   *
-   * This software is distributed in the hope that it will be useful,
-   * but WITHOUT ANY WARRANTY; without even the implied warranty of
-   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   * Lesser General Public License for more details.
-   *
-   * You should have received a copy of the GNU Lesser General Public
-   * License along with this software; if not, write to the Free
-   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-   */
-package org.jboss.jms.server.endpoint;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONNECTION;
-
-import javax.jms.JMSException;
-
-import org.jboss.jms.client.impl.ClientConnectionFactoryImpl;
-import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.logging.Logger;
-import org.jboss.messaging.core.MessagingServer;
-import org.jboss.messaging.core.remoting.PacketHandler;
-import org.jboss.messaging.core.remoting.PacketSender;
-import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.CreateConnectionRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
-import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
-import org.jboss.messaging.core.remoting.wireformat.Packet;
-import org.jboss.messaging.core.remoting.wireformat.PacketType;
-import org.jboss.messaging.util.ExceptionUtil;
-
-/**
- * A packet handler for creating connections. All ConnectionFactories will use the same instance of this
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public class ConnectionFactoryAdvisedPacketHandler implements
-        PacketHandler
-{
-   private static final Logger log = Logger.getLogger(ConnectionFactoryAdvisedPacketHandler.class);
-   MessagingServer messagingServer;
-
-
-   public ConnectionFactoryAdvisedPacketHandler(MessagingServer messagingServer)
-   {
-      this.messagingServer = messagingServer;
-   }/*
-   * The advantage to use String as ID is that we can leverage Java 5 UUID to
-   * generate these IDs. However theses IDs are 128 bite long and it increases
-   * the size of a packet (compared to integer or long).
-   *
-   * By switching to Long, we could reduce the size of the packet and maybe
-   * increase the performance (to check after some performance tests)
-   */
-   public String getID()
-   {
-      return ClientConnectionFactoryImpl.id;
-   }
-
-   public void handle(Packet packet, PacketSender sender)
-      {
-         try
-         {
-            AbstractPacket response = null;
-
-            PacketType type = packet.getType();
-            if (type == REQ_CREATECONNECTION)
-            {
-               CreateConnectionRequest request = (CreateConnectionRequest) packet;
-               response = createConnectionDelegate(request
-                     .getUsername(), request.getPassword(), request.getRemotingSessionID(),
-                     request.getClientVMID(), request.getPrefetchSize(), request.getDupsOKBatchSize(),
-                       request.getClientID(), request.getVersion());
-            }
-            else
-            {
-               response = new JMSExceptionMessage(new MessagingJMSException(
-                     "Unsupported packet for browser: " + packet));
-            }
-
-            // reply if necessary
-            if (response != null)
-            {
-               response.normalize(packet);
-               sender.send(response);
-            }
-
-         } catch (JMSException e)
-         {
-            JMSExceptionMessage message = new JMSExceptionMessage(e);
-            message.normalize(packet);
-            sender.send(message);
-         }
-      }
-
-
-   public CreateConnectionResponse createConnectionDelegate(String username,
-                                                          String password,
-                                                          String remotingSessionID,
-                                                          String clientVMID, int prefetchSize, int dupsOKBatchSize,
-                                                          String clientID,
-                                                          byte versionToUse)
-      throws JMSException
-   {
-      try
-      {
-         return
-            createConnectionDelegateInternal(username, password,
-                                             remotingSessionID, clientVMID,  prefetchSize, dupsOKBatchSize, clientID,
-                                             versionToUse);
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " createFailoverConnectionDelegate");
-      }
-
-   }
-
-   private CreateConnectionResponse
-      createConnectionDelegateInternal(String username,
-                                       String password,
-                                       String remotingSessionID, String clientVMID, int prefetchSize, int dupsOKBatchSize,
-                                       String clientID,
-                                       byte versionToUse)
-      throws Exception
-   {
-      log.trace("creating a new connection for user " + username);
-
-      // Authenticate. Successful autentication will place a new SubjectContext on thread local,
-      // which will be used in the authorization process. However, we need to make sure we clean
-      // up thread local immediately after we used the information, otherwise some other people
-      // security my be screwed up, on account of thread local security stack being corrupted.
-
-      messagingServer.getSecurityManager().authenticate(username, password);
-
-      // We don't need the SubjectContext on thread local anymore, clean it up
-      SecurityActions.popSubjectContext();
-
-      String clientIDUsed = clientID;
-
-      // see if there is a preconfigured client id for the user
-      if (username != null)
-      {
-         String preconfClientID =
-            messagingServer.getJmsUserManagerInstance().getPreConfiguredClientID(username);
-
-         if (preconfClientID != null)
-         {
-            clientIDUsed = preconfClientID;
-         }
-      }
-
-      // create the corresponding "server-side" connection endpoint and register it with the
-      // server peer's ClientManager
-      final ServerConnectionEndpoint endpoint =
-         new ServerConnectionEndpoint(messagingServer, clientIDUsed, username, password, prefetchSize,
-                                      remotingSessionID, clientVMID, versionToUse,
-                                      dupsOKBatchSize);
-
-      String connectionID = endpoint.getConnectionID();
-
-      messagingServer.getRemotingService().getDispatcher().register(endpoint.newHandler());
-
-      log.trace("created and registered " + endpoint);
-
-      return new CreateConnectionResponse(connectionID);
-   }
-   
-   public void addSender(String VMID, String remotingSessionID,
-         PacketSender sender) throws JMSException
-   {
-      log.debug("Adding PacketSender on ConnectionFactory");
-      messagingServer.getConnectionManager().addConnectionFactoryCallback(getID(), VMID, remotingSessionID, sender);
-   }
-
-   public void removeSender(String VMID, String remotingSessionID,
-         PacketSender sender) throws JMSException
-   {
-      log.debug("Removing PacketSender on ConnectionFactory");
-      messagingServer.getConnectionManager().removeConnectionFactoryCallback(getID(), VMID, sender);
-   }
-
-}

Added: trunk/src/main/org/jboss/jms/server/endpoint/MessagingServerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/MessagingServerPacketHandler.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/server/endpoint/MessagingServerPacketHandler.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,153 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005, JBoss Inc., and individual contributors as indicated
+   * by the @authors tag. See the copyright.txt in the distribution for a
+   * full listing of individual contributors.
+   *
+   * This is free software; you can redistribute it and/or modify it
+   * under the terms of the GNU Lesser General Public License as
+   * published by the Free Software Foundation; either version 2.1 of
+   * the License, or (at your option) any later version.
+   *
+   * This software is distributed in the hope that it will be useful,
+   * but WITHOUT ANY WARRANTY; without even the implied warranty of
+   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   * Lesser General Public License for more details.
+   *
+   * You should have received a copy of the GNU Lesser General Public
+   * License along with this software; if not, write to the Free
+   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   */
+package org.jboss.jms.server.endpoint;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CREATECONNECTION;
+
+import org.jboss.jms.client.impl.ClientConnectionFactoryImpl;
+import org.jboss.logging.Logger;
+import org.jboss.messaging.core.MessagingServer;
+import org.jboss.messaging.core.remoting.PacketSender;
+import org.jboss.messaging.core.remoting.wireformat.CreateConnectionRequest;
+import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
+import org.jboss.messaging.core.remoting.wireformat.Packet;
+import org.jboss.messaging.core.remoting.wireformat.PacketType;
+import org.jboss.messaging.util.MessagingException;
+
+/**
+ * A packet handler for all packets that need to be handled at the server level
+ * 
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class MessagingServerPacketHandler extends ServerPacketHandlerSupport
+{
+   private static final Logger log = Logger.getLogger(MessagingServerPacketHandler.class);
+   
+   private MessagingServer messagingServer;
+
+   public MessagingServerPacketHandler(MessagingServer messagingServer)
+   {
+      this.messagingServer = messagingServer;
+   }
+   
+   /*
+   * The advantage to use String as ID is that we can leverage Java 5 UUID to
+   * generate these IDs. However theses IDs are 128 bite long and it increases
+   * the size of a packet (compared to integer or long).
+   *
+   * By switching to Long, we could reduce the size of the packet and maybe
+   * increase the performance (to check after some performance tests)
+   */
+   public String getID()
+   {
+      return ClientConnectionFactoryImpl.id;
+   }
+
+   public Packet doHandle(Packet packet, PacketSender sender) throws Exception
+   {
+      Packet response = null;
+     
+      PacketType type = packet.getType();
+      
+      if (type == CREATECONNECTION)
+      {
+         CreateConnectionRequest request = (CreateConnectionRequest) packet;
+         
+         response = createConnection(request
+               .getUsername(), request.getPassword(), request.getRemotingSessionID(),
+               request.getClientVMID(), request.getPrefetchSize());
+      }     
+      else
+      {
+         throw new MessagingException(MessagingException.UNSUPPORTED_PACKET,
+                                      "Unsupported packet " + type);
+      }
+      
+      return response;
+   }
+
+   private CreateConnectionResponse
+      createConnection(String username,
+                              String password,
+                              String remotingSessionID, String clientVMID, int prefetchSize)
+      throws Exception
+   {
+      log.trace("creating a new connection for user " + username);
+
+      // Authenticate. Successful autentication will place a new SubjectContext on thread local,
+      // which will be used in the authorization process. However, we need to make sure we clean
+      // up thread local immediately after we used the information, otherwise some other people
+      // security my be screwed up, on account of thread local security stack being corrupted.
+
+      messagingServer.getSecurityManager().authenticate(username, password);
+
+      // We don't need the SubjectContext on thread local anymore, clean it up
+      SecurityActions.popSubjectContext();
+
+      //Client ID is a JMS concept and does not belong on the server
+      
+//      String clientIDUsed = clientID;
+//
+//      // see if there is a preconfigured client id for the user
+//      if (username != null)
+//      {
+//         String preconfClientID =
+//            messagingServer.getJmsUserManagerInstance().getPreConfiguredClientID(username);
+//
+//         if (preconfClientID != null)
+//         {
+//            clientIDUsed = preconfClientID;
+//         }
+//      }
+
+      // create the corresponding "server-side" connection endpoint and register it with the
+      // server peer's ClientManager
+      final ServerConnectionEndpoint endpoint =
+         new ServerConnectionEndpoint(messagingServer, username, password, prefetchSize,
+                                      remotingSessionID, clientVMID);
+
+      String connectionID = endpoint.getConnectionID();
+
+      messagingServer.getRemotingService().getDispatcher().register(endpoint.newHandler());
+
+      log.trace("created and registered " + endpoint);
+
+      return new CreateConnectionResponse(connectionID);
+   }
+   
+   public void addSender(String VMID, String remotingSessionID,
+         PacketSender sender) throws Exception
+   {
+      log.debug("Adding PacketSender on ConnectionFactory");
+      messagingServer.getConnectionManager().addConnectionFactoryCallback(getID(), VMID, remotingSessionID, sender);
+   }
+
+   public void removeSender(String VMID, String remotingSessionID,
+         PacketSender sender) throws Exception
+   {
+      log.debug("Removing PacketSender on ConnectionFactory");
+      messagingServer.getConnectionManager().removeConnectionFactoryCallback(getID(), VMID, sender);
+   }
+
+}

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,10 +21,10 @@
  */
 package org.jboss.jms.server.endpoint;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_BROWSER_RESET;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CLOSE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_HASNEXTMESSAGE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_NEXTMESSAGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_RESET;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CLOSE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_HASNEXTMESSAGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_NEXTMESSAGE;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -32,9 +32,7 @@
 
 import javax.jms.IllegalStateException;
 import javax.jms.InvalidSelectorException;
-import javax.jms.JMSException;
 
-import org.jboss.jms.exception.MessagingJMSException;
 import org.jboss.messaging.core.Filter;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.MessageReference;
@@ -42,15 +40,13 @@
 import org.jboss.messaging.core.impl.filter.FilterImpl;
 import org.jboss.messaging.core.remoting.PacketHandler;
 import org.jboss.messaging.core.remoting.PacketSender;
-import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageResponse;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageResponse;
-import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserHasNextMessageResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.NullPacket;
 import org.jboss.messaging.core.remoting.wireformat.Packet;
 import org.jboss.messaging.core.remoting.wireformat.PacketType;
-import org.jboss.messaging.util.ExceptionUtil;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * Concrete implementation of BrowserEndpoint.
@@ -104,136 +100,95 @@
 
    // BrowserEndpoint implementation ---------------------------------------------------------------
 
-   public void reset() throws JMSException
+   public void reset() throws Exception
    {
-      try
+      if (closed)
       {
-         if (closed)
-         {
-            throw new IllegalStateException("Browser is closed");
-         }
+         throw new IllegalStateException("Browser is closed");
+      }
 
-         log.trace(this + " is being resetted");
+      log.trace(this + " is being resetted");
 
-         iterator = createIterator();
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " hasNextMessage");
-      }
+      iterator = createIterator();
    }
 
-   public boolean hasNextMessage() throws JMSException
+   public boolean hasNextMessage() throws Exception
    {
-      try
+      if (closed)
       {
-         if (closed)
-         {
-            throw new IllegalStateException("Browser is closed");
-         }
+         throw new IllegalStateException("Browser is closed");
+      }
 
-         if (iterator == null)
-         {
-            iterator = createIterator();
-         }
-
-         boolean has = iterator.hasNext();
-         if (trace) { log.trace(this + (has ? " has": " DOESN'T have") + " a next message"); }
-         return has;
-      }   
-      catch (Throwable t)
+      if (iterator == null)
       {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " hasNextMessage");
+         iterator = createIterator();
       }
+
+      boolean has = iterator.hasNext();
+      if (trace) { log.trace(this + (has ? " has": " DOESN'T have") + " a next message"); }
+      return has;
    }
    
-   public Message nextMessage() throws JMSException
+   public Message nextMessage() throws Exception
    {
-      try
+      if (closed)
       {
-         if (closed)
-         {
-            throw new IllegalStateException("Browser is closed");
-         }
+         throw new IllegalStateException("Browser is closed");
+      }
 
-         if (iterator == null)
-         {
-            iterator = createIterator();
-         }
-
-         Message r = (Message)iterator.next();
-   
-         if (trace) { log.trace(this + " returning " + r); }
-         
-         return r;
-      }   
-      catch (Throwable t)
+      if (iterator == null)
       {
-         t.printStackTrace();
-         throw ExceptionUtil.handleJMSInvocation(t, this + " nextMessage");
+         iterator = createIterator();
       }
+
+      Message r = (Message)iterator.next();
+
+      if (trace) { log.trace(this + " returning " + r); }
+      
+      return r;
    }
 
-   public Message[] nextMessageBlock(int maxMessages) throws JMSException
+   public Message[] nextMessageBlock(int maxMessages) throws Exception
    {
-
       if (trace) { log.trace(this + " returning next message block of " + maxMessages); }
 
-      try
+      if (closed)
       {
-         if (closed)
-         {
-            throw new IllegalStateException("Browser is closed");
-         }
-         
-         if (maxMessages < 2)
-         {
-            throw new IllegalArgumentException("maxMessages must be >=2 otherwise use nextMessage");
-         }
+         throw new IllegalStateException("Browser is closed");
+      }
+      
+      if (maxMessages < 2)
+      {
+         throw new IllegalArgumentException("maxMessages must be >=2 otherwise use nextMessage");
+      }
 
-         if (iterator == null)
-         {
-            iterator = createIterator();
-         }
-
-         ArrayList messages = new ArrayList(maxMessages);
-         int i = 0;
-         while (i < maxMessages)
-         {
-            if (iterator.hasNext())
-            {
-               Message m = (Message)iterator.next();
-               messages.add(m);
-               i++;
-            }
-            else break;
-         }		
-   		return (Message[])messages.toArray(new Message[messages.size()]);	
-      }   
-      catch (Throwable t)
+      if (iterator == null)
       {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " nextMessageBlock");
+         iterator = createIterator();
       }
+
+      ArrayList messages = new ArrayList(maxMessages);
+      int i = 0;
+      while (i < maxMessages)
+      {
+         if (iterator.hasNext())
+         {
+            Message m = (Message)iterator.next();
+            messages.add(m);
+            i++;
+         }
+         else break;
+      }		
+		return (Message[])messages.toArray(new Message[messages.size()]);	
    }
    
-   public void close() throws JMSException
+   public void close() throws Exception
    {
-      try
-      {
-         localClose();
-         session.removeBrowser(id);
-         log.trace(this + " closed");
-      }   
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " close");
-      }
+      localClose();
+      session.removeBrowser(id);
+      log.trace(this + " closed");
    }
-         
-   public void closing() throws JMSException
-   {
-   }
-   
+           
    // Public ---------------------------------------------------------------------------------------
 
    public String toString()
@@ -243,7 +198,7 @@
 
    // Package protected ----------------------------------------------------------------------------
    
-   void localClose() throws JMSException
+   void localClose() throws Exception
    {
       if (closed)
       {
@@ -282,59 +237,51 @@
 
    // Inner classes --------------------------------------------------------------------------------
    
-   private class ServerBrowserEndpointHandler implements PacketHandler {
+   private class ServerBrowserEndpointHandler extends ServerPacketHandlerSupport
+   {
 
       public String getID()
       {
          return ServerBrowserEndpoint.this.id;
       }
       
-      public void handle(Packet packet, PacketSender sender)
+      public Packet doHandle(Packet packet, PacketSender sender) throws Exception
       {
-         try
-         {
-            Packet response = null;
+         Packet response = null;
 
-            PacketType type = packet.getType();
-            if (type == REQ_BROWSER_HASNEXTMESSAGE)
-            {
-               response = new BrowserHasNextMessageResponse(hasNextMessage());
-            } else if (type == REQ_BROWSER_NEXTMESSAGE)
-            {
-               Message message = nextMessage();
-               response = new BrowserNextMessageResponse(message);
-            } else if (type == MSG_BROWSER_RESET)
-            {
-               reset();
-            } else if (type == PacketType.MSG_CLOSING)
-            {
-               closing();
-            } else if (type == MSG_CLOSE)
-            {
-               close();
-            } else
-            {
-               response = new JMSExceptionMessage(new MessagingJMSException(
-                     "Unsupported packet for browser: " + packet));
-            }
-
-            // reply if necessary
-            if (response == null && packet.isOneWay() == false)
-            {
-               response = new NullPacket();               
-            }
+         PacketType type = packet.getType();
+         
+         if (type == SESS_BROWSER_HASNEXTMESSAGE)
+         {
+            response = new SessionBrowserHasNextMessageResponseMessage(hasNextMessage());
+         }
+         else if (type == SESS_BROWSER_NEXTMESSAGE)
+         {
+            Message message = nextMessage();
             
-            if (response != null)
-            {
-               response.normalize(packet);
-               sender.send(response);
-            }
-         } catch (JMSException e)
+            response = new SessionBrowserNextMessageResponseMessage(message);
+         }
+         else if (type == SESS_BROWSER_RESET)
          {
-            JMSExceptionMessage message = new JMSExceptionMessage(e);
-            message.normalize(packet);
-            sender.send(message);
+            reset();
          }
+         else if (type == CLOSE)
+         {
+            close();
+         }
+         else
+         {
+            throw new MessagingException(MessagingException.UNSUPPORTED_PACKET,
+                                         "Unsupported packet " + type);
+         }
+
+         // reply if necessary
+         if (response == null && packet.isOneWay() == false)
+         {
+            response = new NullPacket();               
+         }            
+         
+         return response;
       }
 
       @Override

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,56 +21,35 @@
   */
 package org.jboss.jms.server.endpoint;
 
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CLOSE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONN_START;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONN_STOP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONN_CREATESESSION;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CLOSE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SETCLIENTID;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_STARTCONNECTION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_STOPCONNECTION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATESESSION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETCLIENTID;
-
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
-import javax.jms.IllegalStateException;
-import javax.jms.JMSException;
-import javax.jms.Session;
-import javax.transaction.xa.Xid;
-
-import org.jboss.jms.exception.MessagingJMSException;
 import org.jboss.jms.server.ConnectionManager;
 import org.jboss.jms.server.SecurityStore;
-import org.jboss.jms.server.TransactionRepository;
-import org.jboss.jms.server.container.SecurityAspect;
 import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.DestinationType;
 import org.jboss.messaging.core.MessagingServer;
 import org.jboss.messaging.core.PostOffice;
-import org.jboss.messaging.core.impl.ConditionImpl;
-import org.jboss.messaging.core.impl.XidImpl;
+import org.jboss.messaging.core.Queue;
 import org.jboss.messaging.core.remoting.PacketHandler;
 import org.jboss.messaging.core.remoting.PacketSender;
-import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.CreateSessionRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateSessionResponse;
-import org.jboss.messaging.core.remoting.wireformat.GetClientIDResponse;
-import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionCreateSessionMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionCreateSessionResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.NullPacket;
 import org.jboss.messaging.core.remoting.wireformat.Packet;
 import org.jboss.messaging.core.remoting.wireformat.PacketType;
-import org.jboss.messaging.core.remoting.wireformat.SetClientIDMessage;
-import org.jboss.messaging.util.ExceptionUtil;
+import org.jboss.messaging.util.ConcurrentHashSet;
 import org.jboss.messaging.util.Logger;
-import org.jboss.messaging.util.Util;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * Concrete implementation of ConnectionEndpoint.
@@ -94,336 +73,150 @@
 
    // Attributes -----------------------------------------------------------------------------------
 
-   private SecurityAspect security = new SecurityAspect();
-
    private String id;
 
    private volatile boolean closed;
+   
    private volatile boolean started;
 
-   private String clientID;
    private String username;
+   
    private String password;
 
    private String remotingClientSessionID;
+   
    private String jmsClientVMID;
 
-   // the server itself
    private MessagingServer messagingServer;
 
-   // access to server's extensions
    private PostOffice postOffice;
+   
    private SecurityStore sm;
+   
    private ConnectionManager cm;
-   private TransactionRepository tr;
 
-   // Map<sessionID - ServerSessionEndpoint>
-   private Map sessions;
+   private ConcurrentMap<String, ServerSessionEndpoint> sessions = new ConcurrentHashMap<String, ServerSessionEndpoint>();
 
-   // Set<?>
-   private Set temporaryDestinations;
+   private Set<Queue> temporaryQueues = new ConcurrentHashSet<Queue>();
 
    private int prefetchSize;
-   private int dupsOKBatchSize;
 
-
-   private byte usingVersion;
-
    // Constructors ---------------------------------------------------------------------------------
 
-   /**
-    * @param failedNodeID - zero or positive values mean connection creation attempt is result of
-    *        failover. Negative values are ignored (mean regular connection creation attempt).
-    */
-   public ServerConnectionEndpoint(MessagingServer messagingServer, String clientID,
+   public ServerConnectionEndpoint(MessagingServer messagingServer,
                                    String username, String password, int prefetchSize,
                                    String remotingSessionID,
-                                   String clientVMID,
-                                   byte versionToUse,
-                                   int dupsOKBatchSize) throws Exception
+                                   String clientVMID) throws Exception
    {
       this.messagingServer = messagingServer;
 
-
       sm = messagingServer.getSecurityManager();
       cm = messagingServer.getConnectionManager();
       postOffice = messagingServer.getPostOffice();
-      tr = messagingServer.getTransactionRepository();
 
       started = false;
 
       this.id = UUID.randomUUID().toString();
-      this.clientID = clientID;
+      
       this.prefetchSize = prefetchSize;
 
-      this.dupsOKBatchSize = dupsOKBatchSize;
-
-      sessions = new HashMap();
-      temporaryDestinations = new HashSet();
-
       this.username = username;
+      
       this.password = password;
 
       this.remotingClientSessionID = remotingSessionID;
 
       this.jmsClientVMID = clientVMID;
-      this.usingVersion = versionToUse;
-
-      this.messagingServer.getConnectionManager().
-         registerConnection(jmsClientVMID, remotingClientSessionID, this);
+      
+      cm.registerConnection(jmsClientVMID, remotingClientSessionID, this);
    }
 
    // ConnectionDelegate implementation ------------------------------------------------------------
 
-   public CreateSessionResponse createSession(boolean transacted,
-                                              int acknowledgementMode,
-                                              boolean xa,
+   public ConnectionCreateSessionResponseMessage createSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks,
                                               PacketSender sender)
-      throws JMSException
-   {
-      try
-      {
-         log.trace(this + " creating " + (transacted ? "transacted" : "non transacted") +
-            " session, " + Util.acknowledgmentMode(acknowledgementMode) + ", " +
-            (xa ? "XA": "non XA"));
+      throws Exception
+   {           
+      String sessionID = UUID.randomUUID().toString();
+ 
+      ServerSessionEndpoint ep =
+         new ServerSessionEndpoint(sessionID, this, autoCommitSends, autoCommitAcks, xa, messagingServer.getResourceManager());            
 
-         if (closed)
-         {
-            throw new IllegalStateException("Connection is closed");
-         }
-
-         String sessionID = UUID.randomUUID().toString();
-
-         //TODO do this checks on the client side
-         boolean autoCommitSends;
-         
-         boolean autoCommitAcks;
-         
-         if (!transacted)
-         {
-            if (acknowledgementMode == Session.AUTO_ACKNOWLEDGE || acknowledgementMode == Session.DUPS_OK_ACKNOWLEDGE)
-            {
-               autoCommitSends = true;
-               
-               autoCommitAcks = true;
-            }
-            else if (acknowledgementMode == Session.CLIENT_ACKNOWLEDGE)
-            {
-               autoCommitSends = true;
-               
-               autoCommitAcks = false;
-            }
-            else
-            {
-               throw new IllegalArgumentException("Invalid ack mode " + acknowledgementMode);
-            }
-         }
-         else
-         {
-            autoCommitSends = false;
-            
-            autoCommitAcks = false;
-         }
-         
-         //Note we only replicate transacted and client acknowledge sessions.
-         ServerSessionEndpoint ep =
-            new ServerSessionEndpoint(sessionID, this, autoCommitSends, autoCommitAcks, xa, sender,
-                                      messagingServer.getResourceManager());            
-
-         synchronized (sessions)
-         {
-            sessions.put(sessionID, ep);
-         }
-
-         messagingServer.addSession(sessionID, ep);
-
-         messagingServer.getRemotingService().getDispatcher().register(ep.newHandler());
-         
-         return new CreateSessionResponse(sessionID, dupsOKBatchSize);
-      }
-      catch (Throwable t)
+      synchronized (sessions)
       {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " createSessionDelegate");
+         sessions.put(sessionID, ep);
       }
+
+      messagingServer.addSession(sessionID, ep);
+
+      messagingServer.getRemotingService().getDispatcher().register(ep.newHandler());
+      
+      return new ConnectionCreateSessionResponseMessage(sessionID);
    }
    
-   public String getClientID() throws JMSException
+   public void start() throws Exception
    {
-      try
+      if (closed)
       {
-         if (closed)
-         {
-            throw new IllegalStateException("Connection is closed");
-         }
-         return clientID;
+         throw new IllegalStateException("Connection is closed");
       }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " getClientID");
-      }
+      
+      setStarted(true);
    }
 
-   public void setClientID(String clientID) throws JMSException
+   public synchronized void stop() throws Exception
    {
-      try
+      if (closed)
       {
-         if (closed)
-         {
-            throw new IllegalStateException("Connection is closed");
-         }
-
-         if (this.clientID != null)
-         {
-            throw new IllegalStateException("Cannot set clientID, already set as " + this.clientID);
-         }
-
-         log.trace(this + "setting client ID to " + clientID);
-
-         this.clientID = clientID;
+         throw new IllegalStateException("Connection is closed");
       }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " setClientID");
-      }
+
+      setStarted(false);
    }
 
-   public void start() throws JMSException
+   public void close() throws Exception
    {
-      try
+      if (closed)
       {
-         if (closed)
-         {
-            throw new IllegalStateException("Connection is closed");
-         }
-         setStarted(true);
-         log.trace(this + " started");
+         log.warn("Connection is already closed");
+         return;
       }
-      catch (Throwable t)
+
+      //We clone to avoid deadlock http://jira.jboss.org/jira/browse/JBMESSAGING-836
+      Map<String, ServerSessionEndpoint> sessionsClone = new HashMap<String, ServerSessionEndpoint>(sessions);
+      
+      for(ServerSessionEndpoint session: sessionsClone.values())
       {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " start");
+         session.localClose();
       }
-   }
 
-   public synchronized void stop() throws JMSException
-   {
-      try
-      {
-         if (closed)
-         {
-            throw new IllegalStateException("Connection is closed");
-         }
+      sessions.clear();
+      
+      Set<String> addresses = new HashSet<String>();
 
-         setStarted(false);
-
-         log.trace("Connection " + id + " stopped");
+      for (Queue tempQueue: temporaryQueues)
+      {                        
+         Binding binding = postOffice.getBinding(tempQueue.getName());
+         
+         addresses.add(binding.getAddress());     
+         
+         postOffice.removeBinding(tempQueue.getName());         
       }
-      catch (Throwable t)
+      
+      for (String address: addresses)
       {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " stop");
+         postOffice.removeAllowableAddress(address);
       }
-   }
 
-   public void close() throws JMSException
-   {
-      try
-      {
-         if (trace) { log.trace(this + " close()"); }
+      temporaryQueues.clear();      
 
-         if (closed)
-         {
-            log.warn("Connection is already closed");
-            return;
-         }
+      cm.unregisterConnection(jmsClientVMID, remotingClientSessionID);
 
-         //We clone to avoid deadlock http://jira.jboss.org/jira/browse/JBMESSAGING-836
-         Map sessionsClone;
-         synchronized (sessions)
-         {
-            sessionsClone = new HashMap(sessions);
-         }
+      messagingServer.getRemotingService().getDispatcher().unregister(id);
 
-         for(Iterator i = sessionsClone.values().iterator(); i.hasNext(); )
-         {
-            ServerSessionEndpoint sess = (ServerSessionEndpoint)i.next();
-
-            sess.localClose();
-         }
-
-         sessions.clear();
-
-         synchronized (temporaryDestinations)
-         {
-            for(Iterator i = temporaryDestinations.iterator(); i.hasNext(); )
-            {
-               Destination dest = (Destination)i.next();
-               
-               Condition condition = new ConditionImpl(dest.getType(), dest.getName());
-
-               //FIXME - these comparisons belong on client side - not here
-               
-               if (dest.getType() == DestinationType.QUEUE)
-               {
-               	// Temporary queues must be unbound on ALL nodes of the cluster
-                  
-               	postOffice.removeQueue(condition, dest.getName(), messagingServer.getConfiguration().isClustered());
-               }
-               else
-               {
-                  //No need to unbind - this will already have happened, and removeAllReferences
-                  //will have already been called when the subscriptions were closed
-                  //which always happens before the connection closed (depth first close)
-               	//note there are no durable subs on a temporary topic
-
-                  List<Binding> bindings = postOffice.getBindingsForCondition(condition);
-                  
-                  if (!bindings.isEmpty())
-               	{
-                  	//This should never happen
-                  	throw new IllegalStateException("Cannot delete temporary destination if it has consumer(s)");
-               	}
-               }
-               
-               postOffice.removeCondition(condition);
-            }
-
-            temporaryDestinations.clear();
-         }
-
-         cm.unregisterConnection(jmsClientVMID, remotingClientSessionID);
-
-         messagingServer.getRemotingService().getDispatcher().unregister(id);
-
-         closed = true;
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " close");
-      }
+      closed = true;
    }
 
-   public void closing() throws JMSException
-   {
-   }
-
-   /**
-    * Get array of XA transactions in prepared state-
-    * This would be used by the transaction manager in recovery or by a tool to apply
-    * heuristic decisions to commit or rollback particular transactions
-    */
-   public XidImpl[] getPreparedTransactions() throws JMSException
-   {
-      try
-      {
-         List<Xid> xids = messagingServer.getPersistenceManager().getInDoubtXids();
-
-         return (XidImpl[])xids.toArray(new XidImpl[xids.size()]);
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " getPreparedTransactions");
-      }
-   }
-
    // Public ---------------------------------------------------------------------------------------
 
    public String getUsername()
@@ -446,17 +239,6 @@
       return messagingServer;
    }
 
-
-   public Collection getSessions()
-   {
-      ArrayList list = new ArrayList();
-      synchronized (sessions)
-      {
-         list.addAll(sessions.values());
-      }
-      return list;
-   }
-
    public PacketHandler newHandler()
    {
       return new ConnectionPacketHandler();
@@ -469,11 +251,6 @@
 
    // Package protected ----------------------------------------------------------------------------
 
-   byte getUsingVersion()
-   {
-      return usingVersion;
-   }
-
    int getPrefetchSize()
    {
       return prefetchSize;
@@ -491,71 +268,49 @@
 
    void removeSession(String sessionId) throws Exception
    {
-      synchronized (sessions)
+      if (sessions.remove(sessionId) == null)
       {
-         if (sessions.remove(sessionId) == null)
-         {
-            throw new IllegalStateException("Cannot find session with id " + sessionId + " to remove");
-         }
-      }
+         throw new IllegalStateException("Cannot find session with id " + sessionId + " to remove");
+      }      
    }
 
-   void addTemporaryDestination(Destination dest)
+   void addTemporaryQueue(Queue queue)
    {
-      synchronized (temporaryDestinations)
-      {
-         temporaryDestinations.add(dest);
-      }
+      temporaryQueues.add(queue);      
    }
-
-   void removeTemporaryDestination(Destination dest)
+   
+   void removeTemporaryQueue(Queue queue)
    {
-      synchronized (temporaryDestinations)
-      {
-         temporaryDestinations.remove(dest);
-      }
+      temporaryQueues.remove(queue);      
    }
 
-   boolean hasTemporaryDestination(Destination dest)
-   {
-      synchronized (temporaryDestinations)
-      {
-         return temporaryDestinations.contains(dest);
-      }
-   }
-
    String getRemotingClientSessionID()
    {
       return remotingClientSessionID;
    }
-
   
    // Protected ------------------------------------------------------------------------------------
 
    // Private --------------------------------------------------------------------------------------
    
-   private void setStarted(boolean s) throws Exception
+   private void setStarted(boolean started) throws Exception
    {
       //We clone to avoid deadlock http://jira.jboss.org/jira/browse/JBMESSAGING-836
-      Map sessionsClone = null;
+      Map<String, ServerSessionEndpoint> sessionsClone = null;
       
-      synchronized(sessions)
+      sessionsClone = new HashMap<String, ServerSessionEndpoint>(sessions);
+            
+      for (ServerSessionEndpoint session: sessionsClone.values() )
       {
-         sessionsClone = new HashMap(sessions);
+         session.setStarted(started);
       }
       
-      for (Iterator i = sessionsClone.values().iterator(); i.hasNext(); )
-      {
-         ServerSessionEndpoint sd = (ServerSessionEndpoint)i.next();
-         
-         sd.setStarted(s);
-      }
-      started = s;      
+      this.started = started;      
    }   
     
    // Inner classes --------------------------------------------------------------------------------
 
-   private class ConnectionPacketHandler implements PacketHandler
+   private class ConnectionPacketHandler extends ServerPacketHandlerSupport
    {
       public ConnectionPacketHandler()
       {
@@ -566,62 +321,43 @@
          return ServerConnectionEndpoint.this.id;
       }
 
-      public void handle(Packet packet, PacketSender sender)
+      public Packet doHandle(Packet packet, PacketSender sender) throws Exception
       {
-         try
-         {
-            Packet response = null;
+         Packet response = null;
 
-            PacketType type = packet.getType();
-            if (type == REQ_CREATESESSION)
-            {
-               CreateSessionRequest request = (CreateSessionRequest) packet;
-               response = createSession(
-                     request.isTransacted(), request.getAcknowledgementMode(),
-                     request.isXA(), sender);
-            } else if (type == MSG_STARTCONNECTION)
-            {
-               start();
-            } else if (type == MSG_STOPCONNECTION)
-            {
-               stop();
-            } else if (type == PacketType.MSG_CLOSING)
-            {              
-               closing();
-            } else if (type == MSG_CLOSE)
-            {
-               close();
-            } 
-            else if (type == REQ_GETCLIENTID)
-            {
-               response = new GetClientIDResponse(getClientID());
-            } else if (type == MSG_SETCLIENTID)
-            {
-               SetClientIDMessage message = (SetClientIDMessage) packet;
-               setClientID(message.getClientID());
-            } else
-            {
-               response = new JMSExceptionMessage(new MessagingJMSException(
-                     "Unsupported packet for browser: " + packet));
-            }
-
-            // reply if necessary
-            if (response == null && packet.isOneWay() == false)
-            {
-               response = new NullPacket();               
-            }
+         PacketType type = packet.getType();
+         
+         if (type == CONN_CREATESESSION)
+         {
+            ConnectionCreateSessionMessage request = (ConnectionCreateSessionMessage) packet;
             
-            if (response != null)
-            {
-               response.normalize(packet);
-               sender.send(response);
-            }
-         } catch (JMSException e)
+            response = createSession(request.isXA(), request.isAutoCommitSends(), request.isAutoCommitAcks(), sender);
+         }
+         else if (type == CONN_START)
          {
-            JMSExceptionMessage message = new JMSExceptionMessage(e);
-            message.normalize(packet);
-            sender.send(message);
+            start();
          }
+         else if (type == CONN_STOP)
+         {
+            stop();
+         }
+         else if (type == CLOSE)
+         {
+            close();
+         }                       
+         else
+         {
+            throw new MessagingException(MessagingException.UNSUPPORTED_PACKET,
+                                         "Unsupported packet " + type);
+         }
+
+         // reply if necessary
+         if (response == null && packet.isOneWay() == false)
+         {
+            response = new NullPacket();               
+         }
+         
+         return response;
       }
 
       @Override

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,35 +21,25 @@
  */
 package org.jboss.jms.server.endpoint;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CHANGERATE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CLOSE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONS_CHANGERATE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CLOSE;
 
-import javax.jms.JMSException;
-
-import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.messaging.core.Condition;
 import org.jboss.messaging.core.Consumer;
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.DestinationType;
 import org.jboss.messaging.core.Filter;
 import org.jboss.messaging.core.HandleStatus;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.MessageReference;
 import org.jboss.messaging.core.MessagingServer;
 import org.jboss.messaging.core.PersistenceManager;
-import org.jboss.messaging.core.PostOffice;
 import org.jboss.messaging.core.Queue;
-import org.jboss.messaging.core.impl.ConditionImpl;
 import org.jboss.messaging.core.remoting.PacketHandler;
 import org.jboss.messaging.core.remoting.PacketSender;
-import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
 import org.jboss.messaging.core.remoting.wireformat.ConsumerChangeRateMessage;
-import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
 import org.jboss.messaging.core.remoting.wireformat.NullPacket;
 import org.jboss.messaging.core.remoting.wireformat.Packet;
 import org.jboss.messaging.core.remoting.wireformat.PacketType;
-import org.jboss.messaging.util.ExceptionUtil;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * Concrete implementation of a ClientConsumer. 
@@ -80,24 +70,12 @@
 
    private Queue messageQueue;
 
-   private String queueName;
-
    private ServerSessionEndpoint sessionEndpoint;
 
    private boolean noLocal;
 
    private Filter filter;
 
-   private Destination destination;
-
-   private Queue dlq;
-
-   private Queue expiryQueue;
-
-   private long redeliveryDelay;
-   
-   private int maxDeliveryAttempts;
-
    private boolean started;
 
    // This lock protects starting and stopping
@@ -111,20 +89,15 @@
    private volatile int sendCount;
    
    private boolean firstTime = true;
-      
-   //FIXME temp
-   public Queue getMessageQueue()
-   {
-      return messageQueue;
-   }
    
+   private boolean autoDeleteQueue;
+
    // Constructors ---------------------------------------------------------------------------------
 
-   ServerConsumerEndpoint(MessagingServer sp, String id, Queue messageQueue, String queueName,
+   ServerConsumerEndpoint(MessagingServer sp, String id, Queue messageQueue,                          
 					           ServerSessionEndpoint sessionEndpoint, Filter filter,
-					           boolean noLocal, Destination destination, Queue dlq,
-					           Queue expiryQueue, long redeliveryDelay, int maxDeliveryAttempts,
-					           int prefetchSize)
+					           boolean noLocal, 
+					           int prefetchSize, boolean autoDeleteQueue)
    {
       if (trace)
       {
@@ -135,22 +108,10 @@
 
       this.messageQueue = messageQueue;
 
-      this.queueName = queueName;
-
       this.sessionEndpoint = sessionEndpoint;
 
       this.noLocal = noLocal;
 
-      this.destination = destination;
-
-      this.dlq = dlq;
-
-      this.redeliveryDelay = redeliveryDelay;
-
-      this.expiryQueue = expiryQueue;
-      
-      this.maxDeliveryAttempts = maxDeliveryAttempts;
-
       // Always start as false - wait for consumer to initiate.
       this.clientAccepting = false;
       
@@ -162,6 +123,8 @@
                 
       this.started = this.sessionEndpoint.getConnectionEndpoint().isStarted();
       
+      this.autoDeleteQueue = autoDeleteQueue;
+      
       // adding the consumer to the queue
       messageQueue.addConsumer(this);
       
@@ -189,24 +152,11 @@
 
       if (ref.getMessage().isExpired())
       {         
-         sessionEndpoint.expireDelivery(ref, expiryQueue);
+         sessionEndpoint.expireDelivery(ref);
          
          return HandleStatus.HANDLED;
       }
       
-// TODO re-implement preserve ordering      
-//      if (preserveOrdering && remote)
-//      {
-//      	//If the header exists it means the message has already been sucked once - so reject.
-//      	
-//      	if (ref.getMessage().getHeader(Message.CLUSTER_SUCKED) != null)
-//      	{
-//      		if (trace) { log.trace("Message has already been sucked once - not sucking again"); }
-//      		
-//      		return null;
-//      	}      	    
-//      }
-
       synchronized (startStopLock)
       {
          // If the consumer is stopped then we don't accept the message, it should go back into the
@@ -281,91 +231,61 @@
 
    public boolean accept(Message msg)
    {
-      boolean accept = true;
-
-      //FIXME - we shouldn't have checks like this - it should be the client side which decides whether
-      //to have a filter on the consumer
-      if (destination.getType() == DestinationType.QUEUE)
+      if (filter != null)
       {
-         // For subscriptions message selection is handled in the Subscription itself we do not want
-         // to do the check twice
-         if (filter != null)
-         {
-            accept = filter.match(msg);
+         boolean accept = filter.match(msg);
 
-            if (trace) { log.trace("message filter " + (accept ? "accepts " : "DOES NOT accept ") + "the message"); }
-         }
+         if (trace) { log.trace("message filter " + (accept ? "accepts " : "DOES NOT accept ") + "the message"); }
+         
+         return accept;
       }
-      
-      return accept;
+      else
+      {
+         return true;
+      }
    }
 
    // Closeable implementation ---------------------------------------------------------------------
 
-   public void closing() throws JMSException
+   public void close() throws Exception
    {
-      try
+      if (trace)
       {
-         if (trace) { log.trace(this + " closing");}
-
-         stop();
+         log.trace(this + " close");
       }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " closing");
-      }
-   }
+      
+      stop();
 
-   public void close() throws JMSException
-   {
-      try
-      {
-         if (trace)
-         {
-            log.trace(this + " close");
-         }
+      localClose();
 
-         localClose();
-
-         sessionEndpoint.removeConsumer(id);
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " close");
-      }
+      sessionEndpoint.removeConsumer(id);
+           
    }
 
    // ConsumerEndpoint implementation --------------------------------------------------------------
 
-   public void changeRate(float newRate) throws JMSException
+   public void changeRate(float newRate) throws Exception
    {
       if (trace)
       {
          log.trace(this + " changing rate to " + newRate);
       }
 
-      try
+      if (newRate > 0)
       {
-         if (newRate > 0)
-         {
-            sendCount = 0;
-            
-            clientAccepting = true;
-         }
-         else
-         {
-            clientAccepting = false;
-         }
-
-         if (clientAccepting)
-         {
-            promptDelivery();
-         }
+         sendCount = 0;
+         
+         clientAccepting = true;
       }
-      catch (Throwable t)
+      else
       {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " changeRate");
+         clientAccepting = false;
       }
+
+      if (clientAccepting)
+      {
+         promptDelivery();
+      }
    }
 
    // Public ---------------------------------------------------------------------------------------
@@ -375,16 +295,6 @@
       return "ConsumerEndpoint[" + id + "]";
    }
 
-//   public Destination getDestination()
-//   {
-//      return destination;
-//   }
-//
-//   public ServerSessionEndpoint getSessionEndpoint()
-//   {
-//      return sessionEndpoint;
-//   }
-
    public PacketHandler newHandler()
    {
       return new ServerConsumerEndpointPacketHandler();
@@ -402,86 +312,28 @@
       //No need to lock since caller already has the lock
       this.started = started;      
    }
-   
-   Queue getDLQ()
-   {
-      return dlq;
-   }
-
-   Queue getExpiryQueue()
-   {
-      return expiryQueue;
-   }
-
-   long getRedliveryDelay()
-   {
-      return redeliveryDelay;
-   }
-   
-   int getMaxDeliveryAttempts()
-   {
-   	return maxDeliveryAttempts;
-   }
-   
-   String getQueueName()
-   {
-   	return queueName;
-   }
-
+    
    void localClose() throws Exception
    {
       if (trace) { log.trace(this + " grabbed the main lock in close() " + this); }
 
       messageQueue.removeConsumer(this);
       
-      sessionEndpoint.getConnectionEndpoint().getMessagingServer().getRemotingService().getDispatcher().unregister(id);
-            
-      // If this is a consumer of a non durable subscription then we want to unbind the
-      // subscription and delete all its data.
-
-      //FIXME - We shouldn't have checks like this on the server side - it should the jms client
-      //which decides whether to delete it or not
-      if (destination.getType() == DestinationType.TOPIC)
+      sessionEndpoint.getConnectionEndpoint().getMessagingServer().getRemotingService().getDispatcher().unregister(id);     
+      
+      if (autoDeleteQueue)
       {
-         PostOffice postOffice = sessionEndpoint.getConnectionEndpoint().getMessagingServer().getPostOffice();
-                  
-         MessagingServer sp = sessionEndpoint.getConnectionEndpoint().getMessagingServer();
-         
-         if (!messageQueue.isDurable())
+         if (messageQueue.getConsumerCount() == 0)
          {
-            Condition condition = new ConditionImpl(destination.getType(), destination.getName());
+            MessagingServer server = sessionEndpoint.getConnectionEndpoint().getMessagingServer();
             
-            postOffice.removeQueue(condition, messageQueue.getName(), false);
-
-            //TODO message counters are handled elsewhere
+            server.getPostOffice().removeBinding(messageQueue.getName());
             
-//            if (!messageQueue.isTemporary())
-//            {
-//	            String counterName = ManagedDestination.SUBSCRIPTION_MESSAGECOUNTER_PREFIX + queueName;
-//	
-//	            MessageCounter counter = sp.getMessageCounterManager().unregisterMessageCounter(counterName);
-//	
-//	            if (counter == null)
-//	            {
-//	               throw new IllegalStateException("Cannot find counter to remove " + counterName);
-//	            }
-//            }
+            if (messageQueue.isDurable())
+            {
+               server.getPersistenceManager().deleteAllReferences(messageQueue);
+            }
          }
-         else
-         {
-         	//Durable sub consumer
-         	
-            //TODO - how do we ensure this for JBM 2.0 ?
-            
-//         	if (queue.isClustered() && sp.getConfiguration().isClustered())
-//            {
-//            	//Clustered durable sub consumer created - we need to remove this info from the replicator
-//            	
-//            	Replicator rep = (Replicator)postOffice;
-//            	
-//            	rep.remove(queue.getName());
-//            }
-         }
       }
    }
 
@@ -531,71 +383,50 @@
    {
       this.replier = replier;
    }
-//
-//   public void deliver(DeliverMessage message)
-//   {
-//      if (replier != null)
-//      {
-//         message.setTargetID(id);
-//         replier.send(message);
-//      } else
-//      {
-//         log.error("No replier to deliver message to consumer");
-//      }
-//   }
 
    // Inner classes --------------------------------------------------------------------------------
    
-   private class ServerConsumerEndpointPacketHandler implements PacketHandler {
+   private class ServerConsumerEndpointPacketHandler extends ServerPacketHandlerSupport
+   {
 
       public String getID()
       {
          return ServerConsumerEndpoint.this.id;
       }
 
-      public void handle(Packet packet, PacketSender sender)
+      public Packet doHandle(Packet packet, PacketSender sender) throws Exception
       {
-         try
+         Packet response = null;
+
+         PacketType type = packet.getType();
+         
+         if (type == CONS_CHANGERATE)
          {
-            Packet response = null;
+            setReplier(sender);
 
-            PacketType type = packet.getType();
-            if (type == MSG_CHANGERATE)
-            {
-               setReplier(sender);
-
-               ConsumerChangeRateMessage message = (ConsumerChangeRateMessage) packet;
-               changeRate(message.getRate());
-            } else if (type == PacketType.MSG_CLOSING)
-            {
-               closing();
-            } else if (type == MSG_CLOSE)
-            {
-               close();
-               setReplier(null);
-            } else
-            {
-               response = new JMSExceptionMessage(new MessagingJMSException(
-                     "Unsupported packet for browser: " + packet));
-            }
-
-            // reply if necessary
-            if (response == null && packet.isOneWay() == false)
-            {
-               response = new NullPacket();               
-            }
+            ConsumerChangeRateMessage message = (ConsumerChangeRateMessage) packet;
             
-            if (response != null)
-            {
-               response.normalize(packet);
-               sender.send(response);
-            }
-         } catch (JMSException e)
+            changeRate(message.getRate());
+         }
+         else if (type == CLOSE)
          {
-            JMSExceptionMessage message = new JMSExceptionMessage(e);
-            message.normalize(packet);
-            sender.send(message);
+            close();
+            
+            setReplier(null);
          }
+         else
+         {
+            throw new MessagingException(MessagingException.UNSUPPORTED_PACKET,
+                  "Unsupported packet " + type);
+         }
+
+         // reply if necessary
+         if (response == null && packet.isOneWay() == false)
+         {
+            response = new NullPacket();               
+         }
+         
+         return response;
       }
 
       @Override

Added: trunk/src/main/org/jboss/jms/server/endpoint/ServerPacketHandlerSupport.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerPacketHandlerSupport.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerPacketHandlerSupport.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,66 @@
+package org.jboss.jms.server.endpoint;
+
+import org.jboss.logging.Logger;
+import org.jboss.messaging.core.remoting.PacketHandler;
+import org.jboss.messaging.core.remoting.PacketSender;
+import org.jboss.messaging.core.remoting.wireformat.MessagingExceptionMessage;
+import org.jboss.messaging.core.remoting.wireformat.Packet;
+import org.jboss.messaging.util.MessagingException;
+
+/**
+ * 
+ * A ServerPacketHandlerSupport
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public abstract class ServerPacketHandlerSupport implements PacketHandler
+{
+   private static final Logger log = Logger.getLogger(ServerPacketHandlerSupport.class);
+   
+   
+   public void handle(Packet packet, PacketSender sender)
+   {
+      Packet response;
+      
+      try
+      {      
+         response = doHandle(packet, sender);
+      }
+      catch (Exception e)
+      {
+         MessagingException me;
+         
+         if (e instanceof MessagingException)
+         {
+            me = (MessagingException)e;
+         }
+         else
+         {
+            log.error("Caught unexpected exception", e);
+            
+            me = new MessagingException(MessagingException.INTERNAL_ERROR);
+         }
+                  
+         response = new MessagingExceptionMessage(me);         
+      }
+      
+      // reply if necessary
+      if (response != null && !packet.isOneWay())
+      {
+         response.normalize(packet);
+         
+         try
+         {
+            sender.send(response);
+         }
+         catch (Exception e)
+         {
+            log.error("Failed to send packet", e);
+         }
+      }
+   }
+   
+   protected abstract Packet doHandle(Packet packet, PacketSender sender) throws Exception;
+
+}

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,35 +1,52 @@
 /*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.jms.server.endpoint;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_ADDTEMPORARYDESTINATION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CLOSE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_DELETETEMPORARYDESTINATION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SENDMESSAGE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_UNSUBSCRIBE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATEBROWSER;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONSUMER;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATEDESTINATION;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_ACKNOWLEDGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CANCEL;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CLOSE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_COMMIT;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_ROLLBACK;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_SEND;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_COMMIT;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_END;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_FORGET;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_GET_TIMEOUT;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_JOIN;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_RESUME;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_ROLLBACK;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_SET_TIMEOUT;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_START;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_SUSPEND;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BINDINGQUERY;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATEBROWSER;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATECONSUMER;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATEQUEUE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_DELETE_QUEUE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_QUEUEQUERY;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_INDOUBT_XIDS;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_PREPARE;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -37,25 +54,14 @@
 import java.util.Map;
 import java.util.UUID;
 
-import javax.jms.IllegalStateException;
-import javax.jms.InvalidDestinationException;
-import javax.jms.InvalidSelectorException;
-import javax.jms.JMSException;
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
-import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.destination.JBossQueue;
-import org.jboss.jms.destination.JBossTopic;
-import org.jboss.jms.exception.MessagingJMSException;
 import org.jboss.jms.server.container.SecurityAspect;
 import org.jboss.jms.server.security.CheckType;
 import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
 import org.jboss.messaging.core.Delivery;
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.DestinationType;
 import org.jboss.messaging.core.Filter;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.MessageReference;
@@ -64,77 +70,76 @@
 import org.jboss.messaging.core.Queue;
 import org.jboss.messaging.core.ResourceManager;
 import org.jboss.messaging.core.Transaction;
-import org.jboss.messaging.core.impl.ConditionImpl;
 import org.jboss.messaging.core.impl.DeliveryImpl;
 import org.jboss.messaging.core.impl.TransactionImpl;
 import org.jboss.messaging.core.impl.filter.FilterImpl;
 import org.jboss.messaging.core.remoting.PacketHandler;
 import org.jboss.messaging.core.remoting.PacketSender;
-import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.AddTemporaryDestinationMessage;
-import org.jboss.messaging.core.remoting.wireformat.CreateBrowserRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateBrowserResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateConsumerRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateConsumerResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateDestinationRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateDestinationResponse;
-import org.jboss.messaging.core.remoting.wireformat.DeleteTemporaryDestinationMessage;
-import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBindingQueryMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBindingQueryResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateBrowserMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateBrowserResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateConsumerMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateConsumerResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateQueueMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionDeleteQueueMessage;
 import org.jboss.messaging.core.remoting.wireformat.NullPacket;
 import org.jboss.messaging.core.remoting.wireformat.Packet;
 import org.jboss.messaging.core.remoting.wireformat.PacketType;
+import org.jboss.messaging.core.remoting.wireformat.SessionQueueQueryMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionQueueQueryResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionAcknowledgeMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionAddAddressMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionCancelMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionRemoveAddressMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionSendMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXACommitMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAEndMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAForgetMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsResponse;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAJoinMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAPrepareMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAResumeMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXARollbackMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAStartMessage;
-import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
-import org.jboss.messaging.util.ExceptionUtil;
 import org.jboss.messaging.util.Logger;
-import org.jboss.messaging.util.MessageQueueNameHelper;
+import org.jboss.messaging.util.MessagingException;
 
 import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
 import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
 
 /**
  * Session implementation
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * Parts derived from JBM 1.x ServerSessionEndpoint by
- *
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a> Parts derived from
+ *         JBM 1.x ServerSessionEndpoint by
+ * 
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  * @version <tt>$Revision$</tt>
- *
+ * 
  * $Id$
  */
 public class ServerSessionEndpoint
 {
-   // Constants ------------------------------------------------------------------------------------
+   // Constants
+   // ------------------------------------------------------------------------------------
 
-   private static final Logger log = Logger.getLogger(ServerSessionEndpoint.class);
+   private static final Logger log = Logger
+         .getLogger(ServerSessionEndpoint.class);
 
-   static final String DUR_SUB_STATE_CONSUMERS = "C";
+   // Static
+   // ---------------------------------------------------------------------------------------
 
-   static final String TEMP_QUEUE_MESSAGECOUNTER_PREFIX = "TempQueue.";
+   // Attributes
+   // -----------------------------------------------------------------------------------
 
-   // Static ---------------------------------------------------------------------------------------
-
-   // Attributes -----------------------------------------------------------------------------------
-
    private SecurityAspect security = new SecurityAspect();
 
    private boolean trace = log.isTraceEnabled();
@@ -147,45 +152,36 @@
 
    private MessagingServer sp;
 
-   private Map consumers = new HashMap();
-   private Map browsers = new HashMap();
+   private Map<String, ServerConsumerEndpoint> consumers = new HashMap<String, ServerConsumerEndpoint>();
 
+   private Map<String, ServerBrowserEndpoint> browsers = new HashMap<String, ServerBrowserEndpoint>();
+
    private PostOffice postOffice;
-   private int defaultMaxDeliveryAttempts;
-   private long defaultRedeliveryDelay;
-   private Queue defaultDLQ;
-   private Queue defaultExpiryQueue;
 
    private volatile LinkedList<Delivery> deliveries = new LinkedList<Delivery>();
 
-   //private SynchronizedLong deliveryIdSequence;
-   
    private long deliveryIDSequence = 0;
 
-   //Temporary until we have our own NIO transport
+   // Temporary until we have our own NIO transport
    QueuedExecutor executor = new QueuedExecutor(new LinkedQueue());
 
    private Transaction tx;
-   
-   //private boolean transacted;
-   
-   private boolean xa;
-   
-   private PacketSender sender;
-   
-   //private boolean transactionalSends;
-   
+
    private boolean autoCommitSends;
-   
+
    private boolean autoCommitAcks;
-   
+
    private ResourceManager resourceManager;
 
-   // Constructors ---------------------------------------------------------------------------------
+   private boolean strict;
 
-   ServerSessionEndpoint(String sessionID, ServerConnectionEndpoint connectionEndpoint,
-                         boolean autoCommitSends, boolean autoCommitAcks, boolean xa,
-                         PacketSender sender, ResourceManager resourceManager) throws Exception
+   // Constructors
+   // ---------------------------------------------------------------------------------
+
+   ServerSessionEndpoint(String sessionID,
+         ServerConnectionEndpoint connectionEndpoint, boolean autoCommitSends,
+         boolean autoCommitAcks, boolean xa, ResourceManager resourceManager)
+         throws Exception
    {
       this.id = sessionID;
 
@@ -195,37 +191,23 @@
 
       postOffice = sp.getPostOffice();
 
-      defaultDLQ = sp.getDefaultDLQInstance();
-
-      defaultExpiryQueue = sp.getDefaultExpiryQueueInstance();
-
-      defaultMaxDeliveryAttempts = sp.getConfiguration().getDefaultMaxDeliveryAttempts();
-
-      defaultRedeliveryDelay = sp.getConfiguration().getDefaultRedeliveryDelay();
-
-      //this.transacted = transacted;
-      
-      this.xa = xa;
-      
       if (!xa)
       {
          tx = new TransactionImpl();
       }
-            
-      this.sender = sender;
-      
-      //this.transactionalSends = transactionalSends;
-      
+
       this.autoCommitSends = autoCommitSends;
-      
+
       this.autoCommitAcks = autoCommitAcks;
-      
+
       this.resourceManager = resourceManager;
+
+      strict = sp.getConfiguration().isStrictTck();
    }
-   
-   
-   // Public ---------------------------------------------------------------------------------------
 
+   // Public
+   // ---------------------------------------------------------------------------------------
+
    public ServerConnectionEndpoint getConnectionEndpoint()
    {
       return connectionEndpoint;
@@ -236,39 +218,49 @@
       return "SessionEndpoint[" + id + "]";
    }
 
-   // Package protected ----------------------------------------------------------------------------
+   // Package protected
+   // ----------------------------------------------------------------------------
 
-   void expireDelivery(MessageReference ref, Queue expiryQueue) throws Exception
+   void expireDelivery(MessageReference ref) throws Exception
    {
-      if (trace) { log.trace(this + " detected expired message " + ref); }
+      Queue expiryQueue = ref.getQueue().getExpiryQueue();
 
-//      if (expiryQueue != null)
-//      {
-//         if (trace) { log.trace(this + " sending expired message to expiry queue " + expiryQueue); }
-//
-//         Message copy = makeCopyForDLQOrExpiry(true, ref);
-//
-//         moveInTransaction(copy, ref, expiryQueue, true);
-//      }
-//      else
-//      {
-//         log.warn("No expiry queue has been configured so removing expired " + ref);
-//
-//         //TODO - tidy up these references - ugly
-//         ref.acknowledge(this.getConnectionEndpoint().getMessagingServer().getPersistenceManager());
-//      }
-      
-      //TODO
+      if (trace)
+      {
+         log.trace(this + " detected expired message " + ref);
+      }
+
+      if (expiryQueue != null)
+      {
+         if (trace)
+         {
+            log.trace(this + " sending expired message to expiry queue "
+                  + expiryQueue);
+         }
+
+         Message copy = makeCopyForDLQOrExpiry(true, ref);
+
+         moveInTransaction(copy, ref, expiryQueue, true);
+      }
+      else
+      {
+         log.warn("No expiry queue has been configured so removing expired "
+               + ref);
+
+         // TODO - tidy up these references - ugly
+         ref.acknowledge(this.getConnectionEndpoint().getMessagingServer()
+               .getPersistenceManager());
+      }
+
+      // TODO
    }
 
    void removeBrowser(String browserId) throws Exception
    {
       synchronized (browsers)
       {
-         if (browsers.remove(browserId) == null)
-         {
-            throw new IllegalStateException("Cannot find browser with id " + browserId + " to remove");
-         }
+         if (browsers.remove(browserId) == null) { throw new IllegalStateException(
+               "Cannot find browser with id " + browserId + " to remove"); }
       }
    }
 
@@ -276,61 +268,60 @@
    {
       synchronized (consumers)
       {
-         if (consumers.remove(consumerId) == null)
-         {
-            throw new IllegalStateException("Cannot find consumer with id " + consumerId + " to remove");
-         }         
+         if (consumers.remove(consumerId) == null) { throw new IllegalStateException(
+               "Cannot find consumer with id " + consumerId + " to remove"); }
       }
    }
 
    void localClose() throws Exception
    {
-      if (closed)
-      {
-         throw new IllegalStateException("Session is already closed");
-      }
+      if (closed) { throw new IllegalStateException("Session is already closed"); }
 
       if (trace) log.trace(this + " close()");
 
-      //We clone to avoid deadlock http://jira.jboss.org/jira/browse/JBMESSAGING-836
+      // We clone to avoid deadlock
+      // http://jira.jboss.org/jira/browse/JBMESSAGING-836
       Map consumersClone;
       synchronized (consumers)
       {
          consumersClone = new HashMap(consumers);
       }
 
-      for( Iterator i = consumersClone.values().iterator(); i.hasNext(); )
+      for (Iterator i = consumersClone.values().iterator(); i.hasNext();)
       {
-         ((ServerConsumerEndpoint)i.next()).localClose();
+         ((ServerConsumerEndpoint) i.next()).localClose();
       }
 
       consumers.clear();
 
-
-      //We clone to avoid deadlock http://jira.jboss.org/jira/browse/JBMESSAGING-836
+      // We clone to avoid deadlock
+      // http://jira.jboss.org/jira/browse/JBMESSAGING-836
       Map browsersClone;
       synchronized (browsers)
       {
          browsersClone = new HashMap(browsers);
       }
 
-      for( Iterator i = browsersClone.values().iterator(); i.hasNext(); )
+      for (Iterator i = browsersClone.values().iterator(); i.hasNext();)
       {
-         ((ServerBrowserEndpoint)i.next()).localClose();
+         ((ServerBrowserEndpoint) i.next()).localClose();
       }
 
       browsers.clear();
 
       rollback();
-      
-      //Close down the executor
 
-      //Note we need to wait for ALL tasks to complete NOT just one otherwise we can end up with the following situation
-      //prompter is queued and starts to execute
-      //prompter almost finishes executing then a message is cancelled due to this session closing
-      //this causes another prompter to be queued
-      //shutdownAfterProcessingCurrentTask is then called
-      //this means the second prompter never runs and the cancelled message doesn't get redelivered
+      // Close down the executor
+
+      // Note we need to wait for ALL tasks to complete NOT just one otherwise
+      // we can end up with the following situation
+      // prompter is queued and starts to execute
+      // prompter almost finishes executing then a message is cancelled due to
+      // this session closing
+      // this causes another prompter to be queued
+      // shutdownAfterProcessingCurrentTask is then called
+      // this means the second prompter never runs and the cancelled message
+      // doesn't get redelivered
       executor.shutdownAfterProcessingCurrentlyQueuedTasks();
 
       deliveries.clear();
@@ -339,17 +330,19 @@
 
       closed = true;
    }
-      
-   synchronized void handleDelivery(MessageReference ref, ServerConsumerEndpoint consumer,
-                                    PacketSender sender) throws Exception
-   { 
-       //FIXME - we shouldn't have to pass in the packet Sender - this should be creatable
-       //without the consumer having to call change rate first
-       Delivery delivery = new DeliveryImpl(ref, consumer.getID(), deliveryIDSequence++, sender);
-       
-       deliveries.add(delivery);       
-              
-       delivery.deliver();
+
+   synchronized void handleDelivery(MessageReference ref,
+         ServerConsumerEndpoint consumer, PacketSender sender) throws Exception
+   {
+      // FIXME - we shouldn't have to pass in the packet Sender - this should be
+      // creatable
+      // without the consumer having to call change rate first
+      Delivery delivery = new DeliveryImpl(ref, consumer.getID(),
+            deliveryIDSequence++, sender);
+
+      deliveries.add(delivery);
+
+      delivery.deliver();
    }
 
    /**
@@ -357,16 +350,17 @@
     */
    void setStarted(boolean s) throws Exception
    {
-      //We clone to prevent deadlock http://jira.jboss.org/jira/browse/JBMESSAGING-836
+      // We clone to prevent deadlock
+      // http://jira.jboss.org/jira/browse/JBMESSAGING-836
       Map consumersClone;
-      synchronized(consumers)
+      synchronized (consumers)
       {
          consumersClone = new HashMap(consumers);
       }
 
-      for(Iterator i = consumersClone.values().iterator(); i.hasNext(); )
+      for (Iterator i = consumersClone.values().iterator(); i.hasNext();)
       {
-         ServerConsumerEndpoint sce = (ServerConsumerEndpoint)i.next();
+         ServerConsumerEndpoint sce = (ServerConsumerEndpoint) i.next();
          if (s)
          {
             sce.start();
@@ -380,12 +374,21 @@
 
    void promptDelivery(final Queue queue)
    {
-      if (trace) { log.trace("Prompting delivery on " + queue); }
+      if (trace)
+      {
+         log.trace("Prompting delivery on " + queue);
+      }
 
       try
       {
-         //TODO - do we really need to prompt on a different thread?
-         this.executor.execute(new Runnable() { public void run() { queue.deliver();} } );
+         // TODO - do we really need to prompt on a different thread?
+         this.executor.execute(new Runnable()
+         {
+            public void run()
+            {
+               queue.deliver();
+            }
+         });
 
       }
       catch (Throwable t)
@@ -394,140 +397,38 @@
       }
    }
 
-   private CreateConsumerResponse createServerConsumer(Destination destination,
-                                                       String filterString,
-                                                       boolean noLocal,
-                                                       String subscriptionName,
-                                                       boolean isCC) throws JMSException
+   private void close() throws Exception
    {
+      localClose();
 
-      checkSecurityCreateConsumerDelegate(destination, subscriptionName);
+      connectionEndpoint.removeSession(id);
 
-      try
-      {
-      	return createConsumerDelegateInternal(destination, filterString, noLocal, subscriptionName);
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " createConsumerDelegate");
-      }
+      connectionEndpoint.getMessagingServer().getRemotingService()
+            .getDispatcher().unregister(id);
    }
 
-	private CreateBrowserResponse createServerBrowser(Destination destination,
-                                                     String filterString)
-      throws JMSException
-	{
-      security.check(destination, CheckType.READ, this.getConnectionEndpoint());
-
-      try
-      {
-         return createBrowserDelegateInternal(destination, filterString);
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " createBrowserDelegate");
-      }
-	}
-
-   private JBossQueue createQueue(String name) throws JMSException
+   private boolean send(String address, Message msg) throws Exception
    {
-      try
-      {
-         if (closed)
-         {
-            throw new IllegalStateException("Session is closed");
-         }
+      // Assign the message an internal id - this is used to key it in the store
 
-         //FIXME - this method should not exist on the server
+      msg.setMessageID(sp.getPersistenceManager().generateMessageID());
 
-         Condition condition = new ConditionImpl(DestinationType.QUEUE, name);
+      // This allows the no-local consumers to filter out the messages that come
+      // from the same
+      // connection.
 
-         if (!postOffice.containsCondition(condition))
-         {
-            throw new JMSException("There is no administratively defined queue with name:" + name);
-         }
+      msg.setConnectionID(connectionEndpoint.getConnectionID());
 
-         return new JBossQueue(name);
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " createQueue");
-      }
-   }
+      postOffice.route(address, msg);
 
-   private JBossTopic createTopic(String name) throws JMSException
-   {
-      try
+      if (msg.getReferences().isEmpty())
       {
-         if (closed)
-         {
-            throw new IllegalStateException("Session is closed");
-         }
+         // Didn't route anywhere
 
-         //FIXME - this method should not exist on the server
-
-         Condition condition = new ConditionImpl(DestinationType.TOPIC, name);
-
-         if (!postOffice.containsCondition(condition))
-         {
-            throw new JMSException("There is no administratively defined topic with name:" + name);
-         }
-
-         return new JBossTopic(name);
+         return false;
       }
-      catch (Throwable t)
+      else
       {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " createTopic");
-      }
-   }
-   
-   private void closing() throws JMSException
-   {      
-   }
-
-   private void close() throws JMSException
-   {
-      try
-      {
-         localClose();
-
-         connectionEndpoint.removeSession(id);
-
-         connectionEndpoint.getMessagingServer().getRemotingService().getDispatcher().unregister(id);
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " close");
-      }
-   }
-
-   private void send(Message msg) throws JMSException
-   {
-      try
-      {
-         Destination dest = (Destination)msg.getHeader(org.jboss.messaging.core.Message.TEMP_DEST_HEADER_NAME);
-
-         //Assign the message an internal id - this is used to key it in the store and also used to 
-         //handle delivery
-         
-         msg.setMessageID(sp.getPersistenceManager().generateMessageID());
-         
-         // This allows the no-local consumers to filter out the messages that come from the same
-         // connection.
-
-         msg.setConnectionID(connectionEndpoint.getConnectionID());
-
-         Condition condition = new ConditionImpl(dest.getType(), dest.getName());
-         
-         postOffice.route(condition, msg);
-         
-         //FIXME - this check belongs on the client side!!
-         
-         if (dest.getType() == DestinationType.QUEUE && msg.getReferences().isEmpty())
-         {
-            throw new InvalidDestinationException("Failed to route to queue " + dest.getName());
-         }
-         
          if (autoCommitSends)
          {
             if (msg.getNumDurableReferences() != 0)
@@ -540,1096 +441,692 @@
          else
          {
             tx.addMessage(msg);
-         }              	
+         }
+
+         return true;
       }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " send");
-      }
    }
 
-   private void addTemporaryDestination(Destination dest) throws JMSException
+   private synchronized void acknowledge(long deliveryID, boolean allUpTo)
+         throws Exception
    {
-      try
+      // Note that we do not consider it an error if the deliveries cannot be
+      // found to be acked.
+      // This can legitimately occur if a connection/session/consumer is closed
+      // from inside a MessageHandlers
+      // onMessage method. In this situation the close will cancel any unacked
+      // deliveries, but the subsequent
+      // call to delivered() will try and ack again and not find the last
+      // delivery on the server.
+      if (allUpTo)
       {
-         if (closed)
-         {
-            throw new IllegalStateException("Session is closed");
-         }
+         // Ack all deliveries up to and including the specified id
 
-         if (!dest.isTemporary())
+         for (Iterator<Delivery> iter = deliveries.iterator(); iter.hasNext();)
          {
-            throw new InvalidDestinationException("Destination:" + dest + " is not a temporary destination");
-         }
+            Delivery rec = iter.next();
 
-         connectionEndpoint.addTemporaryDestination(dest);
+            if (rec.getDeliveryID() <= deliveryID)
+            {
+               iter.remove();
 
-         Condition condition = new ConditionImpl(dest.getType(), dest.getName());
+               MessageReference ref = rec.getReference();
 
-         postOffice.addCondition(condition);
+               if (rec.getDeliveryID() > deliveryID)
+               {
+                  // This catches the case where the delivery has been cancelled
+                  // since it's expired
+                  // And we don't want to end up acking all deliveries!
+                  break;
+               }
 
-         //FIXME - comparisons like this do not belong on the server side
-         //They should be computed on the client side
-         if (dest.getType() == DestinationType.QUEUE)
-         {
+               if (autoCommitAcks)
+               {
+                  ref.acknowledge(sp.getPersistenceManager());
+               }
+               else
+               {
+                  tx.addAcknowledgement(ref);
+               }
 
-            postOffice.addQueue(condition, dest.getName(), null,
-                                false, true, sp.getConfiguration().isClustered());
-
+               if (rec.getDeliveryID() == deliveryID)
+               {
+                  break;
+               }
+            }
+            else
+            {
+               // Sanity check
+               throw new IllegalStateException("Failed to ack contiguently");
+            }
          }
       }
-      catch (Throwable t)
+      else
       {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " addTemporaryDestination");
-      }
-   }
+         // Ack a specific delivery
 
-   private void deleteTemporaryDestination(Destination dest) throws JMSException
-   {
-      try
-      {
-         if (closed)
+         for (Iterator<Delivery> iter = deliveries.iterator(); iter.hasNext();)
          {
-            throw new IllegalStateException("Session is closed");
-         }
+            Delivery rec = iter.next();
 
-         if (!dest.isTemporary())
-         {
-            throw new InvalidDestinationException("Destination:" + dest +
-                                                  " is not a temporary destination");
-         }
+            if (rec.getDeliveryID() == deliveryID)
+            {
+               iter.remove();
 
-         Condition condition = new ConditionImpl(dest.getType(), dest.getName());
+               MessageReference ref = rec.getReference();
 
-         //FIXME - comparisons like this should be done on the jms client not here
-         if (dest.getType() == DestinationType.QUEUE)
-         {
-            List<Binding> bindings = postOffice.getBindingsForQueueName(dest.getName());
+               if (autoCommitAcks)
+               {
+                  ref.acknowledge(sp.getPersistenceManager());
+               }
+               else
+               {
+                  tx.addAcknowledgement(ref);
+               }
 
-         	if (bindings.isEmpty())
-         	{
-         		throw new IllegalStateException("Cannot find binding for queue " + dest.getName());
-         	}
+               break;
+            }
+         }
+      }
+   }
 
-         	Binding binding = bindings.get(0);
+   private void rollback() throws Exception
+   {
+      if (tx == null)
+      {
+         // Might be null if XA
 
-         	if (binding.getQueue().getConsumerCount() != 0)
-         	{
-         		throw new IllegalStateException("Cannot delete temporary queue if it has consumer(s)");
-         	}
+         tx = new TransactionImpl();
+      }
 
-         	// temporary queues must be unbound on ALL nodes of the cluster
+      // Synchronize to prevent any new deliveries arriving during this recovery
+      synchronized (this)
+      {
+         // Add any unacked deliveries into the tx
+         // Doing this ensures all references are rolled back in the correct
+         // order
+         // in a single contiguous block
 
-         	postOffice.removeQueue(condition, dest.getName(), sp.getConfiguration().isClustered());
-         }
-         else
+         for (Delivery del : deliveries)
          {
-            //FIXME - this should be evaluated on the client side
-
-            List<Binding> bindings = postOffice.getBindingsForCondition(new ConditionImpl(dest.getType(), dest.getName()));
-
-            if (!bindings.isEmpty())
-         	{
-            	throw new IllegalStateException("Cannot delete temporary topic if it has consumer(s)");
-         	}
-
-            // There is no need to explicitly unbind the subscriptions for the temp topic, this is because we
-            // will not get here unless there are no bindings.
-            // Note that you cannot create surable subs on a temp topic
+            tx.addAcknowledgement(del.getReference());
          }
 
-         postOffice.removeCondition(condition);
+         deliveries.clear();
 
-         connectionEndpoint.removeTemporaryDestination(dest);
+         deliveryIDSequence -= tx.getAcknowledgementsCount();
       }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " deleteTemporaryDestination");
-      }
+
+      tx.rollback(sp.getPersistenceManager());
    }
 
-   private void unsubscribe(String subscriptionName) throws JMSException
+   private void cancel(long deliveryID, boolean expired) throws Exception
    {
-      log.trace(this + " unsubscribing " + subscriptionName);
-
-      try
+      if (deliveryID == -1)
       {
-         if (closed)
-         {
-            throw new IllegalStateException("Session is closed");
-         }
-         if (subscriptionName == null)
-         {
-            throw new InvalidDestinationException("Destination is null");
-         }
+         // Cancel all
 
-         String clientID = connectionEndpoint.getClientID();
+         Transaction cancelTx;
 
-         if (clientID == null)
+         synchronized (this)
          {
-            throw new JMSException("null clientID on connection");
-         }
+            cancelTx = new TransactionImpl();
 
-         //FIXME - this should be done on the client side
+            for (Delivery del : deliveries)
+            {
+               cancelTx.addAcknowledgement(del.getReference());
+            }
 
-         String queueName = MessageQueueNameHelper.createSubscriptionName(clientID, subscriptionName);
-
-         List<Binding> bindings = postOffice.getBindingsForQueueName(queueName);
-
-         if (bindings.isEmpty())
-         {
-            throw new InvalidDestinationException("Cannot find durable subscription with name " +
-                                                  subscriptionName + " to unsubscribe");
+            deliveries.clear();
          }
 
-         Queue sub = bindings.get(0).getQueue();
+         cancelTx.rollback(sp.getPersistenceManager());
+      }
+      else if (expired)
+      {
+         if (deliveryID == -1) { throw new IllegalArgumentException(
+               "Invalid delivery id"); }
 
-         //FIXME all this should be done on the jms client
+         // Expire a single reference
 
-         // Section 6.11. JMS 1.1.
-         // "It is erroneous for a client to delete a durable subscription while it has an active
-         // TopicSubscriber for it or while a message received by it is part of a current
-         // transaction or has not been acknowledged in the session."
-
-         if (sub.getConsumerCount() != 0)
+         for (Iterator<Delivery> iter = deliveries.iterator(); iter.hasNext();)
          {
-            throw new IllegalStateException("Cannot unsubscribe durable subscription " +
-                                            subscriptionName + " since it has active subscribers");
-         }
+            Delivery delivery = iter.next();
 
-         //Also if it is clustered we must disallow unsubscribing if it has active consumers on other nodes
+            if (delivery.getDeliveryID() == deliveryID)
+            {
+               // TODO - send to expiry queue
+               delivery.getReference().acknowledge(sp.getPersistenceManager());
 
-         //TODO - reimplement this for JBM2
-//         if (sub.isClustered() && sp.getConfiguration().isClustered())
-//         {
-//         	Replicator rep = (Replicator)postOffice;
-//
-//         	Map map = rep.get(sub.getName());
-//
-//         	if (!map.isEmpty())
-//         	{
-//         		throw new IllegalStateException("Cannot unsubscribe durable subscription " +
-//                     subscriptionName + " since it has active subscribers on other nodes");
-//         	}
-//         }
+               iter.remove();
 
-         //FIXME - again all this should be done on the client side jms client
-
-         Condition condition = bindings.get(0).getCondition();
-
-         postOffice.removeQueue(condition, sub.getName(), sub.isClustered() && sp.getConfiguration().isClustered());
-
-         sp.getPersistenceManager().deleteAllReferences(sub);
-
-         sub.removeAllReferences();
-
-         //TODO - message counters should be handled automatically by the destination
-
-//         String counterName = ManagedDestination.SUBSCRIPTION_MESSAGECOUNTER_PREFIX + sub.getName();
-//
-//         MessageCounter counter = sp.getMessageCounterManager().unregisterMessageCounter(counterName);
-//
-//         if (counter == null)
-//         {
-//            throw new IllegalStateException("Cannot find counter to remove " + counterName);
-//         }
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " unsubscribe");
-      }
-   }
-   
-   
-   private synchronized void acknowledge(long deliveryID, boolean allUpTo) throws JMSException
-   {
-      //Note that we do not consider it an error if the deliveries cannot be found to be acked.
-      //This can legitimately occur if a connection/session/consumer is closed from inside a MessageHandlers
-      //onMessage method. In this situation the close will cancel any unacked deliveries, but the subsequent
-      //call to delivered() will try and ack again and not find the last delivery on the server.
-      try
-      {
-         if (allUpTo)
-         {
-            //Ack all deliveries up to and including the specified id
-            
-            for (Iterator<Delivery> iter = deliveries.iterator(); iter.hasNext();)
-            {
-               Delivery rec = iter.next();
-               
-               if (rec.getDeliveryID() <= deliveryID)
-               {
-                  iter.remove();
-                  
-                  MessageReference ref = rec.getReference();
-                  
-                  if (rec.getDeliveryID() > deliveryID)
-                  {
-                     //This catches the case where the delivery has been cancelled since it's expired
-                     //And we don't want to end up acking all deliveries!
-                     break;
-                  }
-                  
-                  if (autoCommitAcks)
-                  {
-                     ref.acknowledge(sp.getPersistenceManager());
-                  }
-                  else
-                  {
-                     tx.addAcknowledgement(ref);
-                  }
-                  
-                  if (rec.getDeliveryID() == deliveryID)
-                  {
-                     break;
-                  }
-               }
-               else
-               {
-                  //Sanity check
-                  throw new IllegalStateException("Failed to ack contiguently");
-               }
+               break;
             }
          }
-         else
-         {
-            //Ack a specific delivery
-            
-            for (Iterator<Delivery> iter = deliveries.iterator(); iter.hasNext();)
-            {
-               Delivery rec = iter.next();
-               
-               if (rec.getDeliveryID() == deliveryID)
-               {
-                  iter.remove();
-                  
-                  MessageReference ref = rec.getReference();
-                  
-                  if (autoCommitAcks)
-                  {
-                     ref.acknowledge(sp.getPersistenceManager());
-                  }
-                  else
-                  {
-                     tx.addAcknowledgement(ref);
-                  }
-                   
-                  break;
-               }
-            }            
-         }
       }
-      catch (Throwable t)
+      else
       {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " acknowledge");
+         throw new IllegalArgumentException("Invalid delivery id " + deliveryID);
       }
    }
-      
-   private void rollback() throws JMSException
-   {     
-      try
-      {                        
-         if (tx == null)
-         {
-            //Might be null if XA
-            
-            tx = new TransactionImpl();
-         }
-         
-         //Synchronize to prevent any new deliveries arriving during this recovery
-         synchronized (this)
-         {                     
-            //Add any unacked deliveries into the tx
-            //Doing this ensures all references are rolled back in the correct order
-            //in a single contiguous block
-            
-            for (Delivery del: deliveries)
-            {
-               tx.addAcknowledgement(del.getReference());
-            }
-            
-            deliveries.clear();
-            
-            deliveryIDSequence -= tx.getAcknowledgementsCount();
-         }
-            
-         tx.rollback(sp.getPersistenceManager());          
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " commit");
-      }
-   }
-   
-   private void cancel(long deliveryID, boolean expired) throws JMSException
+
+   private void commit() throws Exception
    {
-      try
-      {
-         if (deliveryID == -1)
-         {
-            //Cancel all
-            
-            Transaction cancelTx;
-            
-            synchronized (this)
-            {
-               cancelTx = new TransactionImpl();
-               
-               for (Delivery del: deliveries)
-               {
-                  cancelTx.addAcknowledgement(del.getReference());
-               }
-               
-               deliveries.clear();
-            }
-            
-            cancelTx.rollback(sp.getPersistenceManager());
-         }
-         else
-         {
-            for (Iterator<Delivery> iter = deliveries.iterator(); iter.hasNext();)
-            {
-               Delivery delivery = iter.next();
-               
-               if (delivery.getDeliveryID() == deliveryID)
-               {
-                  //TODO - send to expiry queue
-                  delivery.getReference().acknowledge(sp.getPersistenceManager());
-               }
-               
-               iter.remove();
-               
-               break;                              
-            }
-         }
-      }
-      catch (Throwable t)
-      {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " commit");
-      }
+      tx.commit(true, sp.getPersistenceManager());
    }
-   
-   private void commit() throws JMSException
+
+   private SessionXAResponseMessage XACommit(boolean onePhase, Xid xid)
+         throws Exception
    {
-      try
+      if (tx != null)
       {
-         tx.commit(true, sp.getPersistenceManager());      
+         final String msg = "Cannot commit, session is currently doing work in a transaction "
+               + tx.getXid();
+
+         return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
       }
-      catch (Throwable t)
+
+      Transaction theTx = resourceManager.getTransaction(xid);
+
+      if (theTx == null)
       {
-         throw ExceptionUtil.handleJMSInvocation(t, this + " commit");
+         final String msg = "Cannot find xid in resource manager: " + xid;
+
+         return new SessionXAResponseMessage(true, XAException.XAER_NOTA, msg);
       }
-   }
-         
-   private SessionXAResponse XACommit(boolean onePhase, Xid xid)
-   {      
-      try
+
+      if (theTx.isSuspended()) { return new SessionXAResponseMessage(true,
+            XAException.XAER_PROTO,
+            "Cannot commit transaction, it is suspended " + xid); }
+
+      theTx.commit(onePhase, sp.getPersistenceManager());
+
+      boolean removed = resourceManager.removeTransaction(xid);
+
+      if (!removed)
       {
-         if (tx != null)
-         {
-            final String msg = "Cannot commit, session is currently doing work in a transaction " + tx.getXid();
-            
-            return new SessionXAResponse(true, XAException.XAER_PROTO, msg);            
-         }
-         
-         Transaction theTx = resourceManager.getTransaction(xid);
-         
-         if (theTx == null)
-         {
-            final String msg = "Cannot find xid in resource manager: " + xid;
-            
-            return new SessionXAResponse(true, XAException.XAER_NOTA, msg);
-         }
-         
-         if (theTx.isSuspended())
-         { 
-            return new SessionXAResponse(true, XAException.XAER_PROTO, "Cannot commit transaction, it is suspended " + xid);
-         }
-         
-         theTx.commit(onePhase, sp.getPersistenceManager());      
-         
-         boolean removed = resourceManager.removeTransaction(xid);
-         
-         if (!removed)
-         {
-            final String msg = "Failed to remove transaction: " + xid;
-            
-            return new SessionXAResponse(true, XAException.XAER_PROTO, msg);
-         }
-         
-         return new SessionXAResponse(false, XAResource.XA_OK, null);
+         final String msg = "Failed to remove transaction: " + xid;
+
+         return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
       }
-      catch (Exception e)
-      {
-         log.error("Failed to commit transaction branch", e);
-         
-         //Returning retry allows the tx manager to try again - otherwise heuristic action will
-         //be needed
-         return new SessionXAResponse(true, XAException.XA_RETRY, "Consult server logs for exception logging");
-      }
+
+      return new SessionXAResponseMessage(false, XAResource.XA_OK, null);
    }
-   
-   private SessionXAResponse XAEnd(Xid xid, boolean failed)
-   {  
+
+   private SessionXAResponseMessage XAEnd(Xid xid, boolean failed) throws Exception
+   {
       if (tx != null && tx.getXid().equals(xid))
       {
          if (tx.isSuspended())
          {
             final String msg = "Cannot end, transaction is suspended";
-            
-            return new SessionXAResponse(true, XAException.XAER_PROTO, msg);   
+
+            return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
          }
-         
+
          tx = null;
       }
       else
       {
-         //It's also legal for the TM to call end for a Xid in the suspended state
-         //See JTA 1.1 spec 3.4.4 - state diagram
-         //Although in practice TMs rarely do this.
+         // It's also legal for the TM to call end for a Xid in the suspended
+         // state
+         // See JTA 1.1 spec 3.4.4 - state diagram
+         // Although in practice TMs rarely do this.
          Transaction theTx = resourceManager.getTransaction(xid);
-         
+
          if (theTx == null)
          {
-            final String msg = "Cannot find suspended transaction to end " + xid;
-            
-            return new SessionXAResponse(true, XAException.XAER_NOTA, msg);
+            final String msg = "Cannot find suspended transaction to end "
+                  + xid;
+
+            return new SessionXAResponseMessage(true, XAException.XAER_NOTA, msg);
          }
-         
+
          if (!theTx.isSuspended())
          {
             final String msg = "Transaction is not suspended " + xid;
-            
-            return new SessionXAResponse(true, XAException.XAER_PROTO, msg);
+
+            return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
          }
-         
-         theTx.resume();                  
+
+         theTx.resume();
       }
 
-      return new SessionXAResponse(false, XAResource.XA_OK, null);
+      return new SessionXAResponseMessage(false, XAResource.XA_OK, null);
    }
-   
-   private SessionXAResponse XAForget(Xid xid)
-   {      
-      //Do nothing since we don't support heuristic commits / rollback from the resource manager
-      
-      return new SessionXAResponse(false, XAResource.XA_OK, null);
+
+   private SessionXAResponseMessage XAForget(Xid xid)
+   {
+      // Do nothing since we don't support heuristic commits / rollback from the
+      // resource manager
+
+      return new SessionXAResponseMessage(false, XAResource.XA_OK, null);
    }
-   
-   private SessionXAResponse XAJoin(Xid xid)
-   {   
-      try
+
+   private SessionXAResponseMessage XAJoin(Xid xid) throws Exception
+   {
+      Transaction theTx = resourceManager.getTransaction(xid);
+
+      if (theTx == null)
       {
-         Transaction theTx = resourceManager.getTransaction(xid);
-         
-         if (theTx == null)
-         {
-            final String msg = "Cannot find xid in resource manager: " + xid;
-            
-            return new SessionXAResponse(true, XAException.XAER_NOTA, msg);
-         }
-         
-         if (theTx.isSuspended())
-         {
-            return new SessionXAResponse(true, XAException.XAER_PROTO, "Cannot join tx, it is suspended " + xid);
-         }
-         
-         tx = theTx;
-         
-         return new SessionXAResponse(false, XAResource.XA_OK, null);
+         final String msg = "Cannot find xid in resource manager: " + xid;
+
+         return new SessionXAResponseMessage(true, XAException.XAER_NOTA, msg);
       }
-      catch (Exception e)
-      {
-         log.error("Failed to join transaction branch", e);
 
-         return new SessionXAResponse(true, XAException.XAER_RMERR, "Consult server logs for exception logging");
-      }          
+      if (theTx.isSuspended()) { return new SessionXAResponseMessage(true,
+            XAException.XAER_PROTO, "Cannot join tx, it is suspended " + xid); }
+
+      tx = theTx;
+
+      return new SessionXAResponseMessage(false, XAResource.XA_OK, null);
    }
-   
-   private SessionXAResponse XAPrepare(Xid xid)
-   {      
-      try
+
+   private SessionXAResponseMessage XAPrepare(Xid xid) throws Exception
+   {
+      if (tx != null)
       {
-         if (tx != null)
-         {
-            final String msg = "Cannot commit, session is currently doing work in a transaction " + tx.getXid();
-            
-            return new SessionXAResponse(true, XAException.XAER_PROTO, msg);            
-         }
-         
-         Transaction theTx = resourceManager.getTransaction(xid);
-         
-         if (theTx == null)
-         {
-            final String msg = "Cannot find xid in resource manager: " + xid;
-            
-            return new SessionXAResponse(true, XAException.XAER_NOTA, msg);
-         }
-         
-         if (theTx.isSuspended())
-         { 
-            return new SessionXAResponse(true, XAException.XAER_PROTO, "Cannot prepare transaction, it is suspended " + xid);
-         }
-         
-         if (theTx.isEmpty())
-         {
-            //Nothing to do - remove it
-            
-            boolean removed = resourceManager.removeTransaction(xid);
-            
-            if (!removed)
-            {
-               final String msg = "Failed to remove transaction: " + xid;
-               
-               return new SessionXAResponse(true, XAException.XAER_PROTO, msg);
-            }
-            
-            return new SessionXAResponse(false, XAResource.XA_RDONLY, null);
-         }
-         else
-         {         
-            theTx.prepare(sp.getPersistenceManager());
-            
-            return new SessionXAResponse(false, XAResource.XA_OK, null);
-         }
+         final String msg = "Cannot commit, session is currently doing work in a transaction "
+               + tx.getXid();
+
+         return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
       }
-      catch (Exception e)
+
+      Transaction theTx = resourceManager.getTransaction(xid);
+
+      if (theTx == null)
       {
-         log.error("Failed to prepare transaction branch", e);
-         
-         return new SessionXAResponse(true, XAException.XAER_RMERR, "Consult server logs for exception logging");
+         final String msg = "Cannot find xid in resource manager: " + xid;
+
+         return new SessionXAResponseMessage(true, XAException.XAER_NOTA, msg);
       }
-   }
-   
-   private SessionXAResponse XAResume(Xid xid)
-   {            
-      try
-      {
-         if (tx != null)
-         {
-            final String msg = "Cannot resume, session is currently doing work in a transaction " + tx.getXid();
-            
-            return new SessionXAResponse(true, XAException.XAER_PROTO, msg);            
-         }
-         
-         Transaction theTx = resourceManager.getTransaction(xid);
-         
-         if (theTx == null)
-         {
-            final String msg = "Cannot find xid in resource manager: " + xid;
-            
-            return new SessionXAResponse(true, XAException.XAER_NOTA, msg);
-         }
-         
-         if (!theTx.isSuspended())
-         { 
-            return new SessionXAResponse(true, XAException.XAER_PROTO, "Cannot resume transaction, it is not suspended " + xid);
-         }
-         
-         tx = theTx;
-         
-         tx.resume();
-         
-         return new SessionXAResponse(false, XAResource.XA_OK, null);
-      }
-      catch (Exception e)
-      {
-         log.error("Failed to join transaction branch", e);
 
-         return new SessionXAResponse(true, XAException.XAER_RMERR, "Consult server logs for exception logging");
-      }         
-   }
-    
-   private SessionXAResponse XARollback(Xid xid)
-   {      
-      try
+      if (theTx.isSuspended()) { return new SessionXAResponseMessage(true,
+            XAException.XAER_PROTO,
+            "Cannot prepare transaction, it is suspended " + xid); }
+
+      if (theTx.isEmpty())
       {
-         if (tx != null)
-         {
-            final String msg = "Cannot roll back, session is currently doing work in a transaction " + tx.getXid();
-            
-            return new SessionXAResponse(true, XAException.XAER_PROTO, msg);            
-         }
-         
-         Transaction theTx = resourceManager.getTransaction(xid);
-         
-         if (theTx == null)
-         {
-            final String msg = "Cannot find xid in resource manager: " + xid;
-            
-            return new SessionXAResponse(true, XAException.XAER_NOTA, msg);
-         }
-         
-         if (theTx.isSuspended())
-         { 
-            return new SessionXAResponse(true, XAException.XAER_PROTO, "Cannot rollback transaction, it is suspended " + xid);
-         }
-                  
-         theTx.rollback(sp.getPersistenceManager());
-         
+         // Nothing to do - remove it
+
          boolean removed = resourceManager.removeTransaction(xid);
-         
+
          if (!removed)
          {
             final String msg = "Failed to remove transaction: " + xid;
-            
-            return new SessionXAResponse(true, XAException.XAER_PROTO, msg);
+
+            return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
          }
-         
-         return new SessionXAResponse(false, XAResource.XA_OK, null);                  
+
+         return new SessionXAResponseMessage(false, XAResource.XA_RDONLY, null);
       }
-      catch (Exception e)
+      else
       {
-         log.error("Failed to roll back transaction branch", e);
+         theTx.prepare(sp.getPersistenceManager());
 
-         return new SessionXAResponse(true, XAException.XAER_RMERR, "Consult server logs for exception logging");
-      }         
-   }
-   
-   private SessionXAResponse XAStart(Xid xid)
-   {      
-      if (tx != null)
-      {
-         final String msg = "Cannot start, session is already doing work in a transaction " + tx.getXid();
-         
-         return new SessionXAResponse(true, XAException.XAER_PROTO, msg);            
+         return new SessionXAResponseMessage(false, XAResource.XA_OK, null);
       }
-      
-      tx = new TransactionImpl(xid);
-      
-      boolean added = resourceManager.putTransaction(xid, tx);
-      
-      if (!added)
-      {
-         final String msg = "Cannot start, there is already a xid " + tx.getXid();
-         
-         return new SessionXAResponse(true, XAException.XAER_DUPID, msg);          
-      }
-      
-      return new SessionXAResponse(false, XAResource.XA_OK, null);     
    }
-   
-   private SessionXAResponse XASuspend() throws JMSException
-   {      
-      if (tx == null)
-      {
-         final String msg = "Cannot suspend, session is not doing work in a transaction " + tx.getXid();
-         
-         return new SessionXAResponse(true, XAException.XAER_PROTO, msg);            
-      }  
-      
-      if (tx.isSuspended())
-      {
-         final String msg = "Cannot suspend, transaction is already suspended " + tx.getXid();
-         
-         return new SessionXAResponse(true, XAException.XAER_PROTO, msg);   
-      }
-      
-      tx.suspend();
-      
-      tx = null;
-      
-      return new SessionXAResponse(false, XAResource.XA_OK, null);   
-   }
-   
-   private List<Xid> getInDoubtXids() throws JMSException
-   {
-      return null;
-   }
-   
-   private int getXATimeout()
-   {
-      return resourceManager.getTimeoutSeconds();
-   }
-   
-   private boolean setXATimeout(int timeoutSeconds)
-   {
-      return resourceManager.setTimeoutSeconds(timeoutSeconds);
-   }
-      
-   // Protected ------------------------------------------------------------------------------------
 
-   // Private --------------------------------------------------------------------------------------
-
-//   private void cancelDeliveryInternal(Cancel cancel) throws Exception
-//   {
-//      DeliveryRecord rec = (DeliveryRecord)deliveries.remove(cancel.getDeliveryId());
-//
-//      if (rec == null)
-//      {
-//         //The delivery might not be found, if the session is not replicated (i.e. auto_ack or dups_ok)
-//      	//and has failed over since recoverDeliveries won't have been called
-//      	if (trace)
-//      	{
-//      		log.trace("Cannot find delivery to cancel, session probably failed over and is not replicated");
-//      	}
-//      	return;
-//      }
-//
-//      MessageReference ref = rec.ref;
-//
-//      //Note we check the flag *and* evaluate again, this is because the server and client clocks may
-//      //be out of synch and don't want to send back to the client a message it thought it has sent to
-//      //the expiry queue
-//      boolean expired = cancel.isExpired() || ref.getMessage().isExpired();
-//
-//      //Note we check the flag *and* evaluate again, this is because the server value of maxDeliveries
-//      //might get changed after the client has sent the cancel - and we don't want to end up cancelling
-//      //back to the original queue
-//      boolean reachedMaxDeliveryAttempts =
-//         cancel.isReachedMaxDeliveryAttempts() || cancel.getDeliveryCount() >= rec.maxDeliveryAttempts;
-//
-//      if (!expired && !reachedMaxDeliveryAttempts)
-//      {
-//         //Normal cancel back to the queue
-//
-//         ref.setDeliveryCount(cancel.getDeliveryCount());
-//
-//         //Do we need to set a redelivery delay?
-//
-//         if (rec.redeliveryDelay != 0)
-//         {
-//            ref.setScheduledDeliveryTime(System.currentTimeMillis() + rec.redeliveryDelay);
-//         }
-//
-//         if (trace) { log.trace("Cancelling delivery " + cancel.getDeliveryId()); }
-//
-//         ref.cancel(sp.getPersistenceManager());
-//
-//      }
-//      else
-//      {
-//         if (expired)
-//         {
-//            //Sent to expiry queue
-//
-//            Message copy = makeCopyForDLQOrExpiry(true, ref);
-//
-//            moveInTransaction(copy, ref, rec.expiryQueue, false);
-//         }
-//         else
-//         {
-//            //Send to DLQ
-//
-//            Message copy = makeCopyForDLQOrExpiry(false, ref);
-//
-//            moveInTransaction(copy, ref, rec.dlq, true);
-//         }
-//      }
-//   }
-
-   private Message makeCopyForDLQOrExpiry(boolean expiry, MessageReference ref) throws Exception
+   private SessionXAResponseMessage XAResume(Xid xid) throws Exception
    {
-      //We copy the message and send that to the dlq/expiry queue - this is because
-      //otherwise we may end up with a ref with the same message id in the queue more than once
-      //which would barf - this might happen if the same message had been expire from multiple
-      //subscriptions of a topic for example
-      //We set headers that hold the original message destination, expiry time and original message id
+      if (tx != null)
+      {
+         final String msg = "Cannot resume, session is currently doing work in a transaction "
+               + tx.getXid();
 
-   	if (trace) { log.trace("Making copy of message for DLQ or expiry " + ref); }
+         return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
+      }
 
-      Message msg = ref.getMessage();
+      Transaction theTx = resourceManager.getTransaction(xid);
 
-      Message copy = msg.copy();
+      if (theTx == null)
+      {
+         final String msg = "Cannot find xid in resource manager: " + xid;
 
-      long newMessageId = sp.getPersistenceManager().generateMessageID();
+         return new SessionXAResponseMessage(true, XAException.XAER_NOTA, msg);
+      }
 
-      copy.setMessageID(newMessageId);
+      if (!theTx.isSuspended()) { return new SessionXAResponseMessage(true,
+            XAException.XAER_PROTO,
+            "Cannot resume transaction, it is not suspended " + xid); }
 
-      //reset expiry
-      copy.setExpiration(0);
+      tx = theTx;
 
+      tx.resume();
 
-      //TODO
-// http://jira.jboss.org/jira/browse/JBMESSAGING-1202
-//      String origMessageId = msg.getJMSMessageID();
-//
-//      String origDest = msg.getJMSDestination().toString();
-//
-//      copy.setStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_MESSAGE_ID, origMessageId);
-//
-//      copy.setStringProperty(JBossMessage.JBOSS_MESSAGING_ORIG_DESTINATION, origDest);
-//
-//      if (expiry)
-//      {
-//         long actualExpiryTime = System.currentTimeMillis();
-//
-//         copy.setLongProperty(JBossMessage.JBOSS_MESSAGING_ACTUAL_EXPIRY_TIME, actualExpiryTime);
-//      }
-
-      return copy;
+      return new SessionXAResponseMessage(false, XAResource.XA_OK, null);
    }
 
-//   private void moveInTransaction(Message msg, MessageReference ref, Queue queue, boolean dlq) throws Exception
-//   {
-//      List<Message> msgs = new ArrayList<Message>();
-//
-//      msgs.add(msg);
-//
-//      List<MessageReference> refs = new ArrayList<MessageReference>();
-//
-//      refs.add(ref);
-//
-//      Transaction tx = new TransactionImpl(msgs, refs, msg.isDurable());
-//
-//      //FIXME - clear up these ugly refs to the pm
-//      tx.commit(getConnectionEndpoint().getMessagingServer().getPersistenceManager());
-//
-////      MessageReference ref = msg.createReference();
-////
-////      try
-////      {
-////         if (queue != null)
-////         {
-////            queue.handle(null, ref, tx);
-////            del.acknowledge(tx);
-////         }
-////         else
-////         {
-////            log.warn("No " + (dlq ? "DLQ" : "expiry queue") + " has been specified so the message will be removed");
-////
-////            del.acknowledge(tx);
-////         }
-////
-////         tx.commit();
-////      }
-////      catch (Throwable t)
-////      {
-////         tx.rollback();
-////         throw t;
-////      }
-//   }
-
-   private CreateConsumerResponse createConsumerDelegateInternal(Destination destination,
-                                                                 String filterString,
-                                                                 boolean noLocal,
-                                                                 String subscriptionName)
-      throws Exception
+   private SessionXAResponseMessage XARollback(Xid xid) throws Exception
    {
-      if (closed)
+      if (tx != null)
       {
-         throw new IllegalStateException("Session is closed");
-      }
+         final String msg = "Cannot roll back, session is currently doing work in a transaction "
+               + tx.getXid();
 
-      if ("".equals(filterString))
-      {
-         filterString = null;
+         return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
       }
 
-      if (trace)
+      Transaction theTx = resourceManager.getTransaction(xid);
+
+      if (theTx == null)
       {
-         log.trace(this + " creating consumer for " + destination +
-            (filterString == null ? "" : ", filter '" + filterString + "'") +
-            (subscriptionName == null ? "" : ", subscription '" + subscriptionName + "'") +
-            (noLocal ? ", noLocal" : ""));
+         final String msg = "Cannot find xid in resource manager: " + xid;
+
+         return new SessionXAResponseMessage(true, XAException.XAER_NOTA, msg);
       }
 
-      Condition condition = new ConditionImpl(destination.getType(), destination.getName());
+      if (theTx.isSuspended()) { return new SessionXAResponseMessage(true,
+            XAException.XAER_PROTO,
+            "Cannot rollback transaction, it is suspended " + xid); }
 
-      if (!postOffice.containsCondition(condition))
+      theTx.rollback(sp.getPersistenceManager());
+
+      boolean removed = resourceManager.removeTransaction(xid);
+
+      if (!removed)
       {
-         throw new InvalidDestinationException("No such destination: " + destination.getName() + " has it been deployed?");
+         final String msg = "Failed to remove transaction: " + xid;
+
+         return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
       }
 
-      if (destination.isTemporary())
+      return new SessionXAResponseMessage(false, XAResource.XA_OK, null);
+   }
+
+   private SessionXAResponseMessage XAStart(Xid xid)
+   {
+      if (tx != null)
       {
-         // Can only create a consumer for a temporary destination on the same connection
-         // that created it
-         if (!connectionEndpoint.hasTemporaryDestination(destination))
-         {
-            String msg = "Cannot create a message consumer on a different connection " +
-                         "to that which created the temporary destination";
-            throw new IllegalStateException(msg);
-         }
+         final String msg = "Cannot start, session is already doing work in a transaction "
+               + tx.getXid();
+
+         return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
       }
 
-      String consumerID = UUID.randomUUID().toString();
+      tx = new TransactionImpl(xid);
 
-      // Always validate the filter first
-      Filter filter = null;
+      boolean added = resourceManager.putTransaction(xid, tx);
 
-      if (filterString != null)
+      if (!added)
       {
-         try
-         {
-            filter = new FilterImpl(filterString);
-         }
-         catch (Exception e)
-         {
-            throw new InvalidSelectorException("Invalid selector " + filterString);
-         }
+         final String msg = "Cannot start, there is already a xid "
+               + tx.getXid();
+
+         return new SessionXAResponseMessage(true, XAException.XAER_DUPID, msg);
       }
 
-      Queue queue;
+      return new SessionXAResponseMessage(false, XAResource.XA_OK, null);
+   }
 
-      //FIXME - all this logic belongs on the jms client side
-
-      if (destination.getType() == DestinationType.TOPIC)
+   private SessionXAResponseMessage XASuspend() throws Exception
+   {
+      if (tx == null)
       {
-         if (subscriptionName == null)
-         {
-            // non-durable subscription
-            if (log.isTraceEnabled()) { log.trace(this + " creating new non-durable subscription on " + destination); }
+         final String msg = "Cannot suspend, session is not doing work in a transaction "
+               + tx.getXid();
 
-            queue = postOffice.addQueue(condition, UUID.randomUUID().toString(), filter, false, false, false);
+         return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
+      }
 
-            //TODO - message counters should be applied by the queue configurator factory
+      if (tx.isSuspended())
+      {
+         final String msg = "Cannot suspend, transaction is already suspended "
+               + tx.getXid();
 
-         }
-         else
-         {
-            if (destination.isTemporary())
-            {
-               throw new InvalidDestinationException("Cannot create a durable subscription on a temporary topic");
-            }
+         return new SessionXAResponseMessage(true, XAException.XAER_PROTO, msg);
+      }
 
-            // We have a durable subscription, look it up
-            String clientID = connectionEndpoint.getClientID();
-            if (clientID == null)
-            {
-               throw new JMSException("Cannot create durable subscriber without a valid client ID");
-            }
+      tx.suspend();
 
-            // See if there any bindings with the same client_id.subscription_name name
+      tx = null;
 
-            String name = MessageQueueNameHelper.createSubscriptionName(clientID, subscriptionName);
+      return new SessionXAResponseMessage(false, XAResource.XA_OK, null);
+   }
 
-            List<Binding> bindings = postOffice.getBindingsForQueueName(name);
+   private List<Xid> getInDoubtXids() throws Exception
+   {
+      return null;
+   }
 
-            Binding binding = null;
+   private int getXATimeout()
+   {
+      return resourceManager.getTimeoutSeconds();
+   }
 
-            if (!bindings.isEmpty())
-            {
-               binding = bindings.get(0);
-            }
+   private boolean setXATimeout(int timeoutSeconds)
+   {
+      return resourceManager.setTimeoutSeconds(timeoutSeconds);
+   }
 
-            if (binding == null)
-            {
-               // Does not already exist
+   // Protected
+   // ------------------------------------------------------------------------------------
 
-               if (trace) { log.trace(this + " creating new durable subscription on " + destination); }
+   // Private
+   // --------------------------------------------------------------------------------------
 
-               queue = postOffice.addQueue(condition, name, filter, true, false,
-                                           sp.getConfiguration().isClustered());
+   // private void cancelDeliveryInternal(Cancel cancel) throws Exception
+   // {
+   // DeliveryRecord rec =
+   // (DeliveryRecord)deliveries.remove(cancel.getDeliveryId());
+   //
+   // if (rec == null)
+   // {
+   // //The delivery might not be found, if the session is not replicated (i.e.
+   // auto_ack or dups_ok)
+   // //and has failed over since recoverDeliveries won't have been called
+   // if (trace)
+   // {
+   // log.trace("Cannot find delivery to cancel, session probably failed over
+   // and is not replicated");
+   // }
+   // return;
+   // }
+   //
+   // MessageReference ref = rec.ref;
+   //
+   // //Note we check the flag *and* evaluate again, this is because the server
+   // and client clocks may
+   // //be out of synch and don't want to send back to the client a message it
+   // thought it has sent to
+   // //the expiry queue
+   // boolean expired = cancel.isExpired() || ref.getMessage().isExpired();
+   //
+   // //Note we check the flag *and* evaluate again, this is because the server
+   // value of maxDeliveries
+   // //might get changed after the client has sent the cancel - and we don't
+   // want to end up cancelling
+   // //back to the original queue
+   // boolean reachedMaxDeliveryAttempts =
+   // cancel.isReachedMaxDeliveryAttempts() || cancel.getDeliveryCount() >=
+   // rec.maxDeliveryAttempts;
+   //
+   // if (!expired && !reachedMaxDeliveryAttempts)
+   // {
+   // //Normal cancel back to the queue
+   //
+   // ref.setDeliveryCount(cancel.getDeliveryCount());
+   //
+   // //Do we need to set a redelivery delay?
+   //
+   // if (rec.redeliveryDelay != 0)
+   // {
+   // ref.setScheduledDeliveryTime(System.currentTimeMillis() +
+   // rec.redeliveryDelay);
+   // }
+   //
+   // if (trace) { log.trace("Cancelling delivery " + cancel.getDeliveryId()); }
+   //
+   // ref.cancel(sp.getPersistenceManager());
+   //
+   // }
+   // else
+   // {
+   // if (expired)
+   // {
+   // //Sent to expiry queue
+   //
+   // Message copy = makeCopyForDLQOrExpiry(true, ref);
+   //
+   // moveInTransaction(copy, ref, rec.expiryQueue, false);
+   // }
+   // else
+   // {
+   // //Send to DLQ
+   //
+   // Message copy = makeCopyForDLQOrExpiry(false, ref);
+   //
+   // moveInTransaction(copy, ref, rec.dlq, true);
+   // }
+   // }
+   // }
 
-               //TODO message counters handled by queue configurator
+   private Message makeCopyForDLQOrExpiry(boolean expiry, MessageReference ref)
+         throws Exception
+   {
+      // We copy the message and send that to the dlq/expiry queue - this is
+      // because
+      // otherwise we may end up with a ref with the same message id in the
+      // queue more than once
+      // which would barf - this might happen if the same message had been
+      // expire from multiple
+      // subscriptions of a topic for example
+      // We set headers that hold the original message destination, expiry time
+      // and original message id
 
-            }
-            else
-            {
-               //Durable sub already exists
+      if (trace)
+      {
+         log.trace("Making copy of message for DLQ or expiry " + ref);
+      }
 
-            	queue = binding.getQueue();
+      Message msg = ref.getMessage();
 
-               if (trace) { log.trace(this + " subscription " + subscriptionName + " already exists"); }
+      Message copy = msg.copy();
 
-            	//Check if it is already has a subscriber
-            	//We can't have more than one subscriber at a time on the durable sub
+      long newMessageId = sp.getPersistenceManager().generateMessageID();
 
-               if (queue.getConsumerCount() > 0)
-               {
-               	throw new IllegalStateException("Cannot create a subscriber on the durable subscription since it already has subscriber(s)");
-               }
+      copy.setMessageID(newMessageId);
 
-               //TODO - apply message counters on the queue configurator
+      // reset expiry
+      copy.setExpiration(0);
 
-               // From javax.jms.Session Javadoc (and also JMS 1.1 6.11.1):
-               // A client can change an existing durable subscription by creating a durable
-               // TopicSubscriber with the same name and a new topic and/or message selector.
-               // Changing a durable subscriber is equivalent to unsubscribing (deleting) the old
-               // one and creating a new one.
+      if (expiry)
+      {
+         long actualExpiryTime = System.currentTimeMillis();
 
-               String oldFilterString = queue.getFilter() != null ? queue.getFilter().getFilterString() : null;
+         copy.putHeader(Message.HDR_ACTUAL_EXPIRY_TIME, actualExpiryTime);
+      }
 
-               boolean selectorChanged =
-                  (filterString == null && oldFilterString != null) ||
-                  (oldFilterString == null && filterString != null) ||
-                  (oldFilterString != null && filterString != null &&
-                           !oldFilterString.equals(filterString));
+      return copy;
+   }
 
-               if (trace) { log.trace("selector " + (selectorChanged ? "has" : "has NOT") + " changed"); }
+   private void moveInTransaction(Message msg, MessageReference ref,
+         Queue queue, boolean dlq) throws Exception
+   {
+      Transaction tx = new TransactionImpl();
 
-               //FIXME - all this needs to be on the jms client
+      tx.addMessage(msg);
 
-               String oldTopicName = binding.getCondition().getKey();
+      tx.addAcknowledgement(ref);
 
-               boolean topicChanged = !oldTopicName.equals(destination.getName());
+      tx.commit(true, getConnectionEndpoint().getMessagingServer()
+            .getPersistenceManager());
+   }
 
-               if (log.isTraceEnabled()) { log.trace("topic " + (topicChanged ? "has" : "has NOT") + " changed"); }
+   private void addAddress(String address) throws Exception
+   {
+      if (postOffice.containsAllowableAddress(address)) { throw new MessagingException(
+            MessagingException.ADDRESS_EXISTS, "Address already exists: "
+                  + address); }
+      postOffice.addAllowableAddress(address);
+   }
 
-               if (selectorChanged || topicChanged)
-               {
-                  if (trace) { log.trace("topic or selector changed so deleting old subscription"); }
+   private void removeAddress(String address) throws Exception
+   {
+      if (!postOffice.removeAllowableAddress(address)) { throw new MessagingException(
+            MessagingException.ADDRESS_DOES_NOT_EXIST,
+            "Address does not exist: " + address); }
+   }
 
-                  // Unbind the durable subscription
+   private void createQueue(String address, String queueName,
+         String filterString, boolean durable, boolean temporary)
+         throws Exception
+   {
+      Binding binding = postOffice.getBinding(queueName);
 
-                  // Durable subs must be unbound on ALL nodes of the cluster
+      if (binding != null) { throw new MessagingException(
+            MessagingException.QUEUE_EXISTS); }
 
-                  postOffice.removeQueue(binding.getCondition(), queue.getName(), sp.getConfiguration().isClustered());
+      if (temporary)
+      {
+         durable = false;
+      }
 
-                  sp.getPersistenceManager().deleteAllReferences(queue);
+      Filter filter = null;
 
-                  queue.removeAllReferences();
+      if (filterString != null)
+      {
+         filter = new FilterImpl(filterString);
+      }
 
-                  queue = postOffice.addQueue(condition, name, filter, true, false, sp.getConfiguration().isClustered());
+      binding = postOffice.addBinding(address, queueName, filter, durable,
+            temporary);
 
-               }
+      if (temporary)
+      {
+         Queue queue = binding.getQueue();
 
-               //TODO counter creation is handled in the queue configurator
-
-            }
-         }
+         connectionEndpoint.addTemporaryQueue(queue);
       }
-      else
-      {
-         // ClientConsumer on a jms queue
+   }
 
-      	List<Binding> bindings = postOffice.getBindingsForQueueName(destination.getName());
+   private void deleteQueue(String queueName) throws Exception
+   {
+      Binding binding = postOffice.removeBinding(queueName);
 
-         if (bindings.isEmpty())
-         {
-            throw new IllegalStateException("Cannot find queue: " + destination.getName());
-         }
+      if (binding == null) { throw new MessagingException(MessagingException.QUEUE_DOES_NOT_EXIST); }
 
-         queue = bindings.get(0).getQueue();
+      Queue queue = binding.getQueue();
+
+      if (queue.isDurable())
+      {
+         sp.getPersistenceManager().deleteAllReferences(binding.getQueue());
       }
 
-      int prefetchSize = connectionEndpoint.getPrefetchSize();
+      if (queue.isTemporary())
+      {
+         connectionEndpoint.removeTemporaryQueue(queue);
+      }
+   }
 
-      Queue dlqToUse = queue.getDLQ() == null ? defaultDLQ : queue.getDLQ();
+   private SessionCreateConsumerResponseMessage createConsumer(String queueName,  String filterString,
+                                                 boolean noLocal, boolean autoDeleteQueue) throws Exception
+   {
+      Binding binding = postOffice.getBinding(queueName);
 
-      Queue expiryQueueToUse = queue.getExpiryQueue() == null ? defaultExpiryQueue : queue.getExpiryQueue();
+      if (binding == null) { throw new MessagingException(MessagingException.QUEUE_DOES_NOT_EXIST); }
 
-      int maxDeliveryAttemptsToUse = queue.getMaxDeliveryAttempts() == -1 ? defaultMaxDeliveryAttempts : queue.getMaxDeliveryAttempts();
+      int prefetchSize = connectionEndpoint.getPrefetchSize();
 
-      long redeliveryDelayToUse = queue.getRedeliveryDelay() == -1 ? defaultRedeliveryDelay : queue.getRedeliveryDelay();
+      String consumerID = UUID.randomUUID().toString();
 
-      ServerConsumerEndpoint ep =
-         new ServerConsumerEndpoint(sp, consumerID, queue,
-                                    queue.getName(), this, filter, noLocal,
-                                    destination, dlqToUse, expiryQueueToUse, redeliveryDelayToUse,
-                                    maxDeliveryAttemptsToUse, prefetchSize);
+      Filter filter = null;
 
-      //TODO implements this for JBM2
+      if (filterString != null)
+      {
+         filter = new FilterImpl(filterString);
+      }
 
-//      if (queue.isClustered() && sp.getConfiguration().isClustered() && jmsDestination.isTopic() && subscriptionName != null)
-//      {
-//      	//Clustered durable sub consumer created - we need to add this info in the replicator - it is needed by other nodes
-//
-//      	//This is also used to prevent a possible race condition where a clustered durable sub is bound on all nodes
-//      	//but then unsubscribed before the bind is complete on all nodes, leaving it bound on some nodes and not on others
-//      	//The bind all is synchronous so by the time we add the x to the replicator we know it is bound on all nodes
-//      	//and same to unsubscribe
-//
-//      	Replicator rep = (Replicator)postOffice;
-//
-//      	rep.put(queue.getName(), DUR_SUB_STATE_CONSUMERS);
-//      }
-      connectionEndpoint.getMessagingServer().getRemotingService().getDispatcher().register(ep.newHandler());
+      ServerConsumerEndpoint ep = new ServerConsumerEndpoint(sp, consumerID,
+            binding.getQueue(), this, filter, noLocal, prefetchSize, autoDeleteQueue);
 
-      CreateConsumerResponse response = new CreateConsumerResponse(consumerID, prefetchSize,
-                                                                   maxDeliveryAttemptsToUse, redeliveryDelayToUse );
+      connectionEndpoint.getMessagingServer().getRemotingService()
+            .getDispatcher().register(ep.newHandler());
 
+      SessionCreateConsumerResponseMessage response = new SessionCreateConsumerResponseMessage(consumerID,
+            prefetchSize);
+
       synchronized (consumers)
       {
          consumers.put(consumerID, ep);
@@ -1640,81 +1137,106 @@
       return response;
    }
 
-   private CreateBrowserResponse createBrowserDelegateInternal(Destination destination,
-                                                         String selector) throws Exception
-   {
-      if (closed)
+   public SessionQueueQueryResponseMessage executeQueueQuery(SessionQueueQueryMessage request) throws Exception
+   {      
+      if (request.getQueueName() == null)
       {
-         throw new IllegalStateException("Session is closed");
+         throw new IllegalArgumentException("Queue name is null");
       }
+      
+      Binding binding = postOffice.getBinding(request.getQueueName());
 
-      if (destination == null)
+      SessionQueueQueryResponseMessage response;
+      
+      if (binding != null)
       {
-         throw new InvalidDestinationException("null destination");
-      }
+         Queue queue = binding.getQueue();
+         
+         Filter filter = queue.getFilter();
 
-      //FIXME - this belongs in JMS client - not here
-
-      if (destination.getType() == DestinationType.TOPIC)
+         String filterString = filter == null ? null : filter.getFilterString();
+         
+         response = new SessionQueueQueryResponseMessage(queue.isDurable(), queue.isTemporary(), queue.getMaxSize(),
+                                           queue.getConsumerCount(), queue.getMessageCount(),
+                                           filterString, binding.getAddress());
+      }
+      else
       {
-         throw new IllegalStateException("Cannot browse a topic");
+         response = new SessionQueueQueryResponseMessage();
+      }      
+      
+      return response;
+   }
+   
+   public SessionBindingQueryResponseMessage executeBindingQuery(SessionBindingQueryMessage request) throws Exception
+   {      
+      if (request.getAddress() == null)
+      {
+         throw new IllegalArgumentException("Address is null");
       }
+      
+      boolean exists = postOffice.containsAllowableAddress(request.getAddress());
 
-      Condition condition = new ConditionImpl(DestinationType.QUEUE, destination.getName());
-
-      List<Binding> bindings = this.postOffice.getBindingsForCondition(condition);
-
-      if (bindings.isEmpty())
+      List<String> queueNames = new ArrayList<String>();
+      
+      if (exists)
       {
-         throw new InvalidDestinationException("No such destination: " + destination);
+         List<Binding> bindings = postOffice.getBindingsForAddress(request.getAddress());
+         
+         for (Binding binding: bindings)
+         {
+            queueNames.add(binding.getQueue().getName());
+         }
       }
+      
+      return new SessionBindingQueryResponseMessage(exists, queueNames);
+   }
 
-      log.trace(this + " creating browser for " + destination +
-         (selector == null ? "" : ", selector '" + selector + "'"));
+   private SessionCreateBrowserResponseMessage createBrowser(String queueName, String selector)
+         throws Exception
+   {
+      if (closed) { throw new IllegalStateException("Session is closed"); }
 
-      Binding binding = bindings.get(0);
+      Binding binding = postOffice.getBinding(queueName);
 
+      if (binding == null) { throw new MessagingException(
+            MessagingException.QUEUE_DOES_NOT_EXIST); }
+
       String browserID = UUID.randomUUID().toString();
 
-      ServerBrowserEndpoint ep = new ServerBrowserEndpoint(this, browserID, binding.getQueue(), selector);
+      ServerBrowserEndpoint ep = new ServerBrowserEndpoint(this, browserID,
+            binding.getQueue(), selector);
 
-      // still need to synchronized since close() can come in on a different thread
+      // still need to synchronized since close() can come in on a different
+      // thread
       synchronized (browsers)
       {
          browsers.put(browserID, ep);
       }
 
-      connectionEndpoint.getMessagingServer().getRemotingService().getDispatcher().register(ep.newHandler());
+      connectionEndpoint.getMessagingServer().getRemotingService()
+            .getDispatcher().register(ep.newHandler());
 
-      
       log.trace(this + " created and registered " + ep);
 
-      return new CreateBrowserResponse(browserID);
+      return new SessionCreateBrowserResponseMessage(browserID);
    }
-   
-   private void checkSecurityCreateConsumerDelegate(Destination dest, String subscriptionName ) throws JMSException
-   {
-      security.check(dest, CheckType.READ, this.getConnectionEndpoint());
 
-      // if creating a durable subscription then need create permission
-
-      if (subscriptionName != null)
-      {
-         // durable
-         security.check(dest, CheckType.CREATE, this.getConnectionEndpoint());
-      }
+   private void checkSecurityCreateConsumerDelegate(String address,
+         String subscriptionName) throws Exception
+   {
+      security.check(address, CheckType.READ, this.getConnectionEndpoint());
    }
-    
 
    public PacketHandler newHandler()
    {
       return new SessionAdvisedPacketHandler();
    }
 
-   
-   // Inner classes --------------------------------------------------------------------------------   
+   // Inner classes
+   // --------------------------------------------------------------------------------
 
-   private class SessionAdvisedPacketHandler implements PacketHandler
+   private class SessionAdvisedPacketHandler extends ServerPacketHandlerSupport
    {
       public SessionAdvisedPacketHandler()
       {
@@ -1725,180 +1247,178 @@
          return ServerSessionEndpoint.this.id;
       }
 
-      public void handle(Packet packet, PacketSender sender)
+      public Packet doHandle(Packet packet, PacketSender sender)
+            throws Exception
       {
-         try
+         Packet response = null;
+
+         PacketType type = packet.getType();
+
+         // TODO use a switch for this
+         if (type == SESS_SEND)
          {
-            Packet response = null;
+            SessionSendMessage message = (SessionSendMessage) packet;
 
-            PacketType type = packet.getType();
-            
-            //TODO use a switch for this
-            if (type == MSG_SENDMESSAGE)
-            {
-               SessionSendMessage message = (SessionSendMessage) packet;
-              
-               send(message.getMessage());
+            send(message.getAddress(), message.getMessage());
+         }
+         else if (type == SESS_CREATECONSUMER)
+         {
+            SessionCreateConsumerMessage request = (SessionCreateConsumerMessage) packet;
 
-               if (message.getMessage().isDurable())
-               {
-                  response = new NullPacket();
-               }
+            response = createConsumer(request.getQueueName(), request
+                  .getFilterString(), request.isNoLocal(), request.isAutoDeleteQueue());
+         }
+         else if (type == SESS_CREATEQUEUE)
+         {
+            SessionCreateQueueMessage request = (SessionCreateQueueMessage) packet;
 
-            } else if (type == REQ_CREATECONSUMER)
-            {
-               CreateConsumerRequest request = (CreateConsumerRequest) packet;
-               response = createServerConsumer(
-                                request.getDestination(), request.getSelector(), request
-                           .isNoLocal(), request.getSubscriptionName(), request
-                           .isConnectionConsumer());
-            } else if (type == REQ_CREATEDESTINATION)
-            {
-               CreateDestinationRequest request = (CreateDestinationRequest) packet;
-               JBossDestination destination;
-               if (request.isQueue())
-               {
-                  destination = createQueue(request.getName());
-               } else
-               {
-                  destination = createTopic(request.getName());
-               }
+            createQueue(request.getAddress(), request.getQueueName(), request
+                  .getFilterString(), request.isDurable(), request
+                  .isTemporary());
+         }
+         else if (type == SESS_DELETE_QUEUE)
+         {
+            SessionDeleteQueueMessage request = (SessionDeleteQueueMessage) packet;
 
-               response = new CreateDestinationResponse(destination);
-            } else if (type == REQ_CREATEBROWSER)
-            {
-               CreateBrowserRequest request = (CreateBrowserRequest) packet;
-               response = createServerBrowser(
-                     request.getDestination(), request.getSelector());
-            }
-            else if (type == PacketType.MSG_CLOSING)
-            {
-               closing();
-            } else if (type == MSG_CLOSE)
-            {
-               close();
-            } else if (type == MSG_UNSUBSCRIBE)
-            {
-               UnsubscribeMessage message = (UnsubscribeMessage) packet;
-               unsubscribe(message.getSubscriptionName());
-            } else if (type == MSG_ADDTEMPORARYDESTINATION)
-            {
-               AddTemporaryDestinationMessage message = (AddTemporaryDestinationMessage) packet;
-               addTemporaryDestination(message.getDestination());
-            } else if (type == MSG_DELETETEMPORARYDESTINATION)
-            {
-               DeleteTemporaryDestinationMessage message = (DeleteTemporaryDestinationMessage) packet;
-               deleteTemporaryDestination(message.getDestination());
-            }            
-            else if (type == PacketType.MSG_ACKNOWLEDGE)
-            {
-               SessionAcknowledgeMessage message = (SessionAcknowledgeMessage)packet;
-               acknowledge(message.getDeliveryID(), message.isAllUpTo());
-            }
-            else if (type == PacketType.MSG_COMMIT)
-            {
-               commit();
-            }
-            else if (type == PacketType.MSG_ROLLBACK)
-            {
-               rollback();
-            }
-            else if (type == PacketType.MSG_CANCEL)
-            {
-               SessionCancelMessage message = (SessionCancelMessage)packet;
-               cancel(message.getDeliveryID(), message.isExpired());
-            }
-            else if (type == PacketType.MSG_XA_COMMIT)
-            {
-               SessionXACommitMessage message = (SessionXACommitMessage)packet;
-               
-               response = XACommit(message.isOnePhase(), message.getXid());
-            }
-            else if (type == PacketType.MSG_XA_END)
-            { 
-               SessionXAEndMessage message = (SessionXAEndMessage)packet;
-               
-               response = XAEnd(message.getXid(), message.isFailed());
-            }
-            else if (type == PacketType.MSG_XA_FORGET)
-            {
-               SessionXAForgetMessage message = (SessionXAForgetMessage)packet;
-               
-               response = XAForget(message.getXid());
-            }
-            else if (type == PacketType.MSG_XA_JOIN)
-            {
-               SessionXAJoinMessage message = (SessionXAJoinMessage)packet;
-               
-               response = XAJoin(message.getXid());
-            }
-            else if (type == PacketType.MSG_XA_RESUME)
-            {
-               SessionXAResumeMessage message = (SessionXAResumeMessage)packet;
-               
-               response = XAResume(message.getXid());
-            }
-            else if (type == PacketType.MSG_XA_ROLLBACK)
-            {
-               SessionXARollbackMessage message = (SessionXARollbackMessage)packet;
-               
-               response = XARollback(message.getXid());
-            }
-            else if (type == PacketType.MSG_XA_START)
-            {
-               SessionXAStartMessage message = (SessionXAStartMessage)packet;
-               
-               response = XAStart(message.getXid());
-            }
-            else if (type == PacketType.MSG_XA_SUSPEND)
-            {
-               response = XASuspend();
-            }   
-            else if (type == PacketType.REQ_XA_PREPARE)
-            {
-               SessionXAPrepareMessage message = (SessionXAPrepareMessage)packet;
-               
-               response = XAPrepare(message.getXid());
-            }
-            else if (type == PacketType.REQ_XA_INDOUBT_XIDS)
-            {
-               List<Xid> xids = getInDoubtXids();
-               
-               response = new SessionXAGetInDoubtXidsResponse(xids);
-            }
-            else if (type == PacketType.MSG_XA_GET_TIMEOUT)
-            {
-               response = new SessionXAGetTimeoutResponse(getXATimeout());
-            }
-            else if (type == PacketType.MSG_XA_SET_TIMEOUT)
-            {
-               SessionXASetTimeoutMessage message = (SessionXASetTimeoutMessage)packet;
-               
-               response = new SessionXASetTimeoutResponse(setXATimeout(message.getTimeoutSeconds()));
-            }
-            else
-            {
-               response = new JMSExceptionMessage(new MessagingJMSException(
-                     "Unsupported packet for browser: " + packet));
-            }
+            deleteQueue(request.getQueueName());
+         }
+         else if (type == SESS_QUEUEQUERY)
+         {
+            SessionQueueQueryMessage request = (SessionQueueQueryMessage) packet;
 
-            // reply if necessary
-            if (response == null && packet.isOneWay() == false)
-            {
-               response = new NullPacket();               
-            }
+            response = executeQueueQuery(request);
+         }
+         else if (type == SESS_BINDINGQUERY)
+         {
+            SessionBindingQueryMessage request = (SessionBindingQueryMessage)packet;
             
-            if (response != null)
-            {
-               response.normalize(packet);
-               sender.send(response);
-            }
-         } catch (JMSException e)
+            response = executeBindingQuery(request);
+         }
+         else if (type == SESS_CREATEBROWSER)
          {
-            JMSExceptionMessage message = new JMSExceptionMessage(e);
-            message.normalize(packet);
-            sender.send(message);
+            SessionCreateBrowserMessage request = (SessionCreateBrowserMessage) packet;
+
+            response = createBrowser(request.getQueueName(), request
+                  .getFilterString());
          }
+         else if (type == CLOSE)
+         {
+            close();
+         }
+         else if (type == SESS_ACKNOWLEDGE)
+         {
+            SessionAcknowledgeMessage message = (SessionAcknowledgeMessage) packet;
+
+            acknowledge(message.getDeliveryID(), message.isAllUpTo());
+         }
+         else if (type == SESS_COMMIT)
+         {
+            commit();
+         }
+         else if (type == SESS_ROLLBACK)
+         {
+            rollback();
+         }
+         else if (type == SESS_CANCEL)
+         {
+            SessionCancelMessage message = (SessionCancelMessage) packet;
+
+            cancel(message.getDeliveryID(), message.isExpired());
+         }
+         else if (type == SESS_XA_COMMIT)
+         {
+            SessionXACommitMessage message = (SessionXACommitMessage) packet;
+
+            response = XACommit(message.isOnePhase(), message.getXid());
+         }
+         else if (type == SESS_XA_END)
+         {
+            SessionXAEndMessage message = (SessionXAEndMessage) packet;
+
+            response = XAEnd(message.getXid(), message.isFailed());
+         }
+         else if (type == SESS_XA_FORGET)
+         {
+            SessionXAForgetMessage message = (SessionXAForgetMessage) packet;
+
+            response = XAForget(message.getXid());
+         }
+         else if (type == SESS_XA_JOIN)
+         {
+            SessionXAJoinMessage message = (SessionXAJoinMessage) packet;
+
+            response = XAJoin(message.getXid());
+         }
+         else if (type == SESS_XA_RESUME)
+         {
+            SessionXAResumeMessage message = (SessionXAResumeMessage) packet;
+
+            response = XAResume(message.getXid());
+         }
+         else if (type == SESS_XA_ROLLBACK)
+         {
+            SessionXARollbackMessage message = (SessionXARollbackMessage) packet;
+
+            response = XARollback(message.getXid());
+         }
+         else if (type == SESS_XA_START)
+         {
+            SessionXAStartMessage message = (SessionXAStartMessage) packet;
+
+            response = XAStart(message.getXid());
+         }
+         else if (type == SESS_XA_SUSPEND)
+         {
+            response = XASuspend();
+         }
+         else if (type == SESS_XA_PREPARE)
+         {
+            SessionXAPrepareMessage message = (SessionXAPrepareMessage) packet;
+
+            response = XAPrepare(message.getXid());
+         }
+         else if (type == SESS_XA_INDOUBT_XIDS)
+         {
+            List<Xid> xids = getInDoubtXids();
+
+            response = new SessionXAGetInDoubtXidsResponseMessage(xids);
+         }
+         else if (type == SESS_XA_GET_TIMEOUT)
+         {
+            response = new SessionXAGetTimeoutResponseMessage(getXATimeout());
+         }
+         else if (type == SESS_XA_SET_TIMEOUT)
+         {
+            SessionXASetTimeoutMessage message = (SessionXASetTimeoutMessage) packet;
+
+            response = new SessionXASetTimeoutResponseMessage(setXATimeout(message
+                  .getTimeoutSeconds()));
+         }
+         else if (type == PacketType.SESS_ADD_ADDRESS)
+         {
+            SessionAddAddressMessage message = (SessionAddAddressMessage) packet;
+
+            addAddress(message.getAddress());
+         }
+         else if (type == PacketType.SESS_REMOVE_ADDRESS)
+         {
+            SessionRemoveAddressMessage message = (SessionRemoveAddressMessage) packet;
+
+            removeAddress(message.getAddress());
+         }
+         else
+         {
+            throw new MessagingException(MessagingException.UNSUPPORTED_PACKET,
+                  "Unsupported packet " + type);
+         }
+
+         // reply if necessary
+         if (response == null && packet.isOneWay() == false)
+         {
+            response = new NullPacket();
+         }
+
+         return response;
       }
 
       @Override
@@ -1907,7 +1427,5 @@
          return "SessionAdvisedPacketHandler[id=" + id + "]";
       }
    }
-   
-   
 
 }

Modified: trunk/src/main/org/jboss/jms/server/recovery/MessagingXAResourceWrapper.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/recovery/MessagingXAResourceWrapper.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/server/recovery/MessagingXAResourceWrapper.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -61,7 +61,7 @@
    /** The connection */
    private XAConnection connection;
    
-   /** The delegate XAResource */
+   /** The connectionFactory XAResource */
    private XAResource delegate;
    
    private String username;
@@ -236,14 +236,14 @@
 
    public void onException(JMSException exception)
    {
-      log.warn("Notified of connection failure in recovery delegate for provider " + providerName, exception);
+      log.warn("Notified of connection failure in recovery connectionFactory for provider " + providerName, exception);
       close();
    }
    
    /**
-    * Get the delegate XAResource
+    * Get the connectionFactory XAResource
     * 
-    * @return the delegate
+    * @return the connectionFactory
     * @throws XAException for any problem
     */
    public XAResource getDelegate() throws XAException
@@ -266,7 +266,7 @@
          xae.errorCode = XAException.XAER_RMERR;
          if (error != null)
             xae.initCause(error);
-         log.debug("Cannot get delegate XAResource", xae);
+         log.debug("Cannot get connectionFactory XAResource", xae);
          throw xae;
       }
       
@@ -276,12 +276,12 @@
    /**
     * Connect to the server if not already done so
     * 
-    * @return the delegate XAResource
+    * @return the connectionFactory XAResource
     * @throws Exception for any problem
     */
    protected XAResource connect() throws Exception
    {
-      // Do we already have a valid delegate?
+      // Do we already have a valid connectionFactory?
       synchronized (lock)
       {
          if (delegate != null)
@@ -305,7 +305,7 @@
          connection = xaConnection;
       }
 
-      // Retrieve the delegate XAResource
+      // Retrieve the connectionFactory XAResource
       try
       {
          XASession session = connection.createXASession();

Modified: trunk/src/main/org/jboss/jms/server/security/SecurityMetadataStore.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/security/SecurityMetadataStore.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/jms/server/security/SecurityMetadataStore.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,22 +21,21 @@
   */
 package org.jboss.jms.server.security;
 
+import java.security.Principal;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+
 import org.jboss.jms.server.SecurityStore;
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.DestinationType;
 import org.jboss.messaging.core.MessagingServer;
 import org.jboss.messaging.util.HierarchicalRepository;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 import org.jboss.security.AuthenticationManager;
 import org.jboss.security.RealmMapping;
 import org.jboss.security.SimplePrincipal;
 
-import javax.jms.JMSSecurityException;
-import javax.security.auth.Subject;
-import java.security.Principal;
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * A security metadate store for JMS. Stores security information for destinations and delegates
  * authentication and authorization to a JaasSecurityManager.
@@ -56,8 +55,6 @@
 
    private static final Logger log = Logger.getLogger(SecurityMetadataStore.class);
 
-   public static final String SUCKER_USER = "JBM.SUCKER";
-
    public static final String DEFAULT_SUCKER_USER_PASSWORD = "CHANGE ME!!";
 
    // Attributes ----------------------------------------------------
@@ -84,7 +81,7 @@
    // SecurityManager implementation --------------------------------
 
 
-   public Subject authenticate(String user, String password) throws JMSSecurityException
+   public Subject authenticate(String user, String password) throws MessagingException
    {
       if (trace) { log.trace("authenticating user " + user); }
 
@@ -97,23 +94,8 @@
 
       Subject subject = new Subject();
 
-      boolean authenticated = false;
-
-      if (SUCKER_USER.equals(user))
-      {
-      	if (trace) { log.trace("Authenticating sucker user"); }
-
-      	checkDefaultSuckerPassword(password);
-
-      	// The special user SUCKER_USER is used for creating internal connections that suck messages between nodes
-
-      	authenticated = suckerPassword.equals(password);
-      }
-      else
-      {
-      	authenticated = authenticationManager.isValid(principal, passwordChars, subject);
-      }
-
+      boolean authenticated = authenticationManager.isValid(principal, passwordChars, subject);
+      
       if (authenticated)
       {
          // Warning! This "taints" thread local. Make sure you pop it off the stack as soon as
@@ -123,25 +105,16 @@
       }
       else
       {
-         throw new JMSSecurityException("User " + user + " is NOT authenticated");
+         throw new MessagingException(MessagingException.SECURITY_EXCEPTION, "User " + user + " is NOT authenticated");
       }
    }
 
-   public boolean authorize(String user, Destination destination, CheckType checkType)
+   public boolean authorize(String user, String destination, CheckType checkType)
    {
-      if (trace) { log.trace("authorizing user " + user + " for destination " + destination.getName()); }
+      if (trace) { log.trace("authorizing user " + user + " for destination " + destination); }
 
-      if (SUCKER_USER.equals(user))
-      {
-      	//The special user SUCKER_USER is used for creating internal connections that suck messages between nodes
-      	//It has automatic read/write access to all destinations
-      	return (checkType.equals(CheckType.READ) || checkType.equals(CheckType.WRITE));
-      }
-      StringBuilder match = new StringBuilder(destination.getType().equals(DestinationType.QUEUE) ? "queues/" : "topics/")
-              .append(destination.getName());
+      HashSet<Role> roles = securityRepository.getMatch(destination);
 
-      HashSet<Role> roles = securityRepository.getMatch(match.toString());
-
       Principal principal = user == null ? null : new SimplePrincipal(user);
       Set rolePrincipals = getRolePrincipals(checkType, roles);
       boolean hasRole = realmMapping.doesUserHaveRole(principal, rolePrincipals);

Modified: trunk/src/main/org/jboss/messaging/core/Binding.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/Binding.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/Binding.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -33,9 +33,7 @@
 {
    int getNodeID();
    
-   Condition getCondition();
+   String getAddress();
    
    Queue getQueue();
-   
-   boolean isAllNodes();
 }

Deleted: trunk/src/main/org/jboss/messaging/core/Condition.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/Condition.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/Condition.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,38 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.messaging.core;
-
-import org.jboss.messaging.util.Streamable;
-
-/**
- * 
- * A Condition
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface Condition extends Streamable
-{
-   DestinationType getType();
-   
-   String getKey();
-}

Modified: trunk/src/main/org/jboss/messaging/core/Configuration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/Configuration.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/Configuration.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -60,14 +60,7 @@
    protected String _securityDomain;
    protected HashSet<Role> _securityConfig;
    protected List<String> defaultInterceptors = new ArrayList<String>();
-   protected String _defaultDLQ;
-   // The default maximum number of delivery attempts before sending to DLQ - can be overridden on
-   // the destination
-   protected Integer _defaultMaxDeliveryAttempts = 10;
-   protected String _defaultExpiryQueue;
 
-   protected Long _defaultRedeliveryDelay = (long) 0;
-
    protected Long _messageCounterSamplePeriod = (long) 10000;// Default is 1 minute
 
    protected Integer _defaultMessageCounterHistoryDayLimit = 1;
@@ -165,46 +158,6 @@
       _securityConfig = securityConfig;
    }
 
-   public  String getDefaultDLQ()
-   {
-      return _defaultDLQ;
-   }
-
-   public  void setDefaultDLQ(String defaultDLQ)
-   {
-      _defaultDLQ = defaultDLQ;
-   }
-
-   public  Integer getDefaultMaxDeliveryAttempts()
-   {
-      return _defaultMaxDeliveryAttempts;
-   }
-
-   public  void setDefaultMaxDeliveryAttempts(Integer defaultMaxDeliveryAttempts)
-   {
-      _defaultMaxDeliveryAttempts = defaultMaxDeliveryAttempts;
-   }
-
-   public  String getDefaultExpiryQueue()
-   {
-      return _defaultExpiryQueue;
-   }
-
-   public  void setDefaultExpiryQueue(String defaultExpiryQueue)
-   {
-      _defaultExpiryQueue = defaultExpiryQueue;
-   }
-
-   public  long getDefaultRedeliveryDelay()
-   {
-      return _defaultRedeliveryDelay;
-   }
-
-   public  void setDefaultRedeliveryDelay(long defaultRedeliveryDelay)
-   {
-      _defaultRedeliveryDelay = defaultRedeliveryDelay;
-   }
-
    public  long getMessageCounterSamplePeriod()
    {
       return _messageCounterSamplePeriod;

Modified: trunk/src/main/org/jboss/messaging/core/Delivery.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/Delivery.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/Delivery.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -34,5 +34,5 @@
    
    long getDeliveryID();
    
-   void deliver();
+   void deliver() throws Exception;
 }

Deleted: trunk/src/main/org/jboss/messaging/core/Destination.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/Destination.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/Destination.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,40 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.messaging.core;
-
-import org.jboss.messaging.util.Streamable;
-
-/**
- * 
- * A Destination
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface Destination extends Streamable
-{
-   DestinationType getType();
-   
-   String getName();
-   
-   boolean isTemporary();
-}

Modified: trunk/src/main/org/jboss/messaging/core/FileConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/FileConfiguration.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/FileConfiguration.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,17 +21,16 @@
    */
 package org.jboss.messaging.core;
 
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.jboss.messaging.util.XMLUtil;
-import org.jboss.messaging.core.remoting.TransportType;
-import org.jboss.jms.server.security.Role;
-
 import java.net.URL;
-import java.util.HashSet;
 import java.util.ArrayList;
-import java.beans.PropertyChangeSupport;
+import java.util.HashSet;
 
+import org.jboss.jms.server.security.Role;
+import org.jboss.messaging.core.remoting.TransportType;
+import org.jboss.messaging.util.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
 /**
  * This class allows the Configuration class to be configured via a config file.
  *
@@ -57,10 +56,6 @@
       _defaultQueueJNDIContext = getString(e, "default-queue-jndi-context", _defaultQueueJNDIContext);
       _defaultTopicJNDIContext = getString(e, "default-topic-jndi-context", _defaultTopicJNDIContext);
       _securityDomain = getString(e, "security-domain", _securityDomain);
-      _defaultDLQ = getString(e, "default-dlq", _defaultDLQ);
-      _defaultMaxDeliveryAttempts = getInteger(e, "default-max-delivery-attempts", _defaultMaxDeliveryAttempts);
-      _defaultExpiryQueue = getString(e, "default-expiry-queue", _defaultExpiryQueue);
-      _defaultRedeliveryDelay = getLong(e, "default-redelivery-delay", _defaultRedeliveryDelay);
       _messageCounterSamplePeriod = getLong(e, "message-counter-sample-period", _messageCounterSamplePeriod);
       _defaultMessageCounterHistoryDayLimit = getInteger(e, "default-message-counter-history-day-limit", _defaultMessageCounterHistoryDayLimit);
       _strictTck = getBoolean(e, "strict-tck", _strictTck);

Modified: trunk/src/main/org/jboss/messaging/core/Message.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/Message.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/Message.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -39,8 +39,7 @@
  */
 public interface Message extends Streamable
 {
-   //FIXME - temp
-   public static final String TEMP_DEST_HEADER_NAME = "JMSDestination";
+   public static final String HDR_ACTUAL_EXPIRY_TIME = "JBMActualExpiryTime";
    
    /**    
     * @return The unique id of the message

Modified: trunk/src/main/org/jboss/messaging/core/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/MessagingServer.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/MessagingServer.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -27,7 +27,6 @@
 
 import org.jboss.jms.server.ConnectionManager;
 import org.jboss.jms.server.SecurityStore;
-import org.jboss.jms.server.TransactionRepository;
 import org.jboss.jms.server.endpoint.ServerSessionEndpoint;
 import org.jboss.jms.server.plugin.contract.JMSUserManager;
 import org.jboss.jms.server.security.Role;
@@ -75,18 +74,12 @@
 
    void removeSession(String id);
 
-   Queue getDefaultDLQInstance() throws Exception;
-   
-   Queue getDefaultExpiryQueueInstance() throws Exception;
-
    SecurityStore getSecurityManager();
 
    ConnectionManager getConnectionManager();
 
    MemoryManager getMemoryManager();
 
-   TransactionRepository getTransactionRepository();
-   
    PersistenceManager getPersistenceManager();
 
    void setPersistenceManager(PersistenceManager persistenceManager);

Modified: trunk/src/main/org/jboss/messaging/core/MessagingServerManagement.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/MessagingServerManagement.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/MessagingServerManagement.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -33,26 +33,26 @@
  */
 public interface MessagingServerManagement
 {
-   String getServerVersion();
-   
-   Configuration getConfiguration();
-   
+//   String getServerVersion();
+//   
+//   Configuration getConfiguration();
+//   
    int getMessageCountForQueue(String queue) throws Exception;
-   
+//   
    void removeAllMessagesForQueue(String queueName) throws Exception;
-   
+//   
    void removeAllMessagesForTopic(String topicName) throws Exception;
-   
+//   
    List<SubscriptionInfo> listAllSubscriptionsForTopic(String topicName) throws Exception;
-   
+//   
    void createQueue(String name) throws Exception;
-   
+//   
    void createTopic(String name) throws Exception;
-   
+//   
    void destroyQueue(String name) throws Exception;
-   
+//   
    void destroyTopic(String name) throws Exception;
-   
+//   
    boolean isStarted();
 //
 //   /**

Modified: trunk/src/main/org/jboss/messaging/core/PostOffice.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/PostOffice.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/PostOffice.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -26,35 +26,43 @@
 
 /**
  * 
- * PostOffice maintains bindings of conditions to Queue instances
- * and knows how to route messages to queues based on a Condition.
+ * A PostOffice instance maintains a mapping of a String address to a Queue. Multiple Queue instances can be bound
+ * with the same String address.
  * 
- * Conditions can also be added without queues.
+ * Given a message and an address a PostOffice instance will route that message to all the Queue instances that are
+ * registered with that address.
  * 
+ * Addresses can be any String instance.
+ * 
+ * A Queue instance can only be bound against a single address in the post office.
+ * 
+ * The PostOffice also maintains a set of "allowable addresses". These are the addresses that it is legal to
+ * route to.
+ *  
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  *
  */
 public interface PostOffice extends MessagingComponent
-{
-   Queue addQueue(Condition condition, String name, Filter filter,
-                  boolean durable, boolean temporary, boolean allNodes) throws Exception;
+{   
+   void addAllowableAddress(String address);
    
-   void addCondition(Condition condition);
+   boolean removeAllowableAddress(String address);
    
-   boolean removeCondition(Condition condition);
-   
-   boolean containsCondition(Condition condition);
+   boolean containsAllowableAddress(String address);
 
-   boolean removeQueue(Condition condition, String name, boolean allNodes) throws Exception;
+   Binding addBinding(String address, String queueName, Filter filter,
+                      boolean durable, boolean temporary) throws Exception;
    
-   void route(Condition condition, Message message) throws Exception;
+   Binding removeBinding(String queueName) throws Exception;
    
-   void routeFromCluster(Condition condition, Message message) throws Exception;
+   List<Binding> getBindingsForAddress(String address) throws Exception;
    
-   List<Binding> getBindingsForQueueName(String name) throws Exception;
+   Binding getBinding(String queueName) throws Exception;
+      
+   void route(String address, Message message) throws Exception;
    
-   List<Binding> getBindingsForCondition(Condition condition) throws Exception;
-   
-   //For testing
-   Map<Condition, List<Binding>> getMappings();
+   void routeFromCluster(String address, Message message) throws Exception;
+     
+   //For testing only
+   Map<String, List<Binding>> getMappings();
 }

Modified: trunk/src/main/org/jboss/messaging/core/Queue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/Queue.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/Queue.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -71,7 +71,7 @@
    
    int getDeliveringCount();
    
-   void referenceAcknowledged();
+   void decrementDeliveringCount();
    
    int getScheduledCount();
           

Modified: trunk/src/main/org/jboss/messaging/core/impl/BindingImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/BindingImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/BindingImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -22,7 +22,6 @@
 package org.jboss.messaging.core.impl;
 
 import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
 import org.jboss.messaging.core.Queue;
 
 /**
@@ -36,30 +35,26 @@
 {
    private int nodeID;
    
-   private Condition condition;
+   private String address;
    
    private Queue queue;
    
-   private boolean allNodes;
-   
    private boolean hashAssigned;
    
    private int hash;
       
-   public BindingImpl(int nodeID, Condition condition, Queue queue, boolean allNodes)
+   public BindingImpl(int nodeID, String address, Queue queue)
    {
       this.nodeID = nodeID;
       
-      this.condition = condition;
+      this.address = address;
       
       this.queue = queue;
-      
-      this.allNodes = allNodes;
    }
    
-   public Condition getCondition()
+   public String getAddress()
    {
-      return condition;
+      return address;
    }
 
    public int getNodeID()
@@ -72,11 +67,6 @@
       return queue;
    }
 
-   public boolean isAllNodes()
-   {
-      return allNodes;
-   }
-     
    public boolean equals(Object other)
    {
       if (this == other)
@@ -85,8 +75,8 @@
       }
       Binding bother = (Binding)other;
       
-      return (this.nodeID == bother.getNodeID()) && (this.allNodes == bother.isAllNodes()) &&
-              this.condition.equals(bother.getCondition()) &&
+      return (this.nodeID == bother.getNodeID()) &&
+              this.address.equals(bother.getAddress()) &&
               this.queue.equals(bother.getQueue());
    }
    
@@ -96,10 +86,9 @@
       {
          hash = 17;
          hash = 37 * hash + nodeID;
-         hash = 37 * hash + condition.hashCode();
+         hash = 37 * hash + address.hashCode();
          hash = 37 * hash + queue.hashCode();
-         hash = 37 * hash + (allNodes ? 0 : 1);
-         
+                
          hashAssigned = true;
       }
 

Deleted: trunk/src/main/org/jboss/messaging/core/impl/ConditionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/ConditionImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/ConditionImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,110 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.messaging.core.impl;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-
-import org.jboss.messaging.core.Condition;
-import org.jboss.messaging.core.DestinationType;
-
-/**
- * 
- * A ConditionImpl
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class ConditionImpl implements Condition
-{
-   private DestinationType type;
-   
-   private String key;
-   
-   private boolean hashAssigned;
-   
-   private int hash;
-   
-   public ConditionImpl()
-   {      
-   }
-   
-   public ConditionImpl(DestinationType type, String key)
-   {
-      this.type = type;
-      
-      this.key = key;
-   }
-         
-   public DestinationType getType()
-   {
-      return type;
-   }
-
-   public String getKey()
-   {
-      return key;
-   }
-   
-   public boolean equals(Object other)
-   {
-      if (this == other)
-      {
-         return true;
-      }
-      
-      Condition cond = (Condition)other;
-
-      return ((cond.getType() == this.type) && (cond.getKey().equals(this.key)));
-   }
-
-   public int hashCode()
-   {
-      if (!hashAssigned)
-      {
-         hash = 17;
-         hash = 37 * hash + DestinationType.toInt(type);
-         hash = 37 * hash + key.hashCode();
-         
-         hashAssigned = true;
-      }
-
-      return hash;
-   }
-   
-   public void read(DataInputStream in) throws Exception
-   {
-      int i = in.readInt();
-      
-      type = DestinationType.fromInt(i);
-      
-      key = in.readUTF();
-   }
-
-   public void write(DataOutputStream out) throws Exception
-   {
-      out.writeInt(DestinationType.toInt(type));
-      
-      out.writeUTF(key);
-   }
-
-}

Modified: trunk/src/main/org/jboss/messaging/core/impl/DeliveryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/DeliveryImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/DeliveryImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -65,7 +65,7 @@
       return deliveryID;
    }
    
-   public void deliver()
+   public void deliver() throws Exception
    {
       DeliverMessage message = new DeliverMessage(reference.getMessage(),
                                                   deliveryID,

Deleted: trunk/src/main/org/jboss/messaging/core/impl/DestinationImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/DestinationImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/DestinationImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,130 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.messaging.core.impl;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.Serializable;
-
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.DestinationType;
-
-/**
- * 
- * A DestinationImpl
- * 
- * TODO remove serializable once SendPacket has destination and scheduled delivery time
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class DestinationImpl implements Destination, Serializable
-{
-   private static final long serialVersionUID = -1892654472409037939L;
-
-   private DestinationType type;
-   
-   private String name;
-   
-   private boolean temporary;
-   
-   private int hash;
-   
-   private boolean hashAssigned;
-   
-   public DestinationImpl()
-   {      
-   }
-   
-   public DestinationImpl(DestinationType type, String name, boolean temporary)
-   {
-      this.type = type;
-      
-      this.name = name;
-      
-      this.temporary = temporary;
-   }
-      
-   public DestinationType getType()
-   {
-      return type;
-   }
-   
-   public String getName()
-   {
-      return name;
-   }
-   
-   public boolean isTemporary()
-   {
-      return temporary;
-   }
-   
-   public void read(DataInputStream in) throws Exception
-   {
-      int i = in.readInt();
-      
-      type = DestinationType.fromInt(i);
-      
-      name = in.readUTF();
-      
-      temporary = in.readBoolean();
-   }
-
-   public void write(DataOutputStream out) throws Exception
-   {
-      out.writeInt(DestinationType.toInt(type));
-      
-      out.writeUTF(name);
-      
-      out.writeBoolean(temporary);
-   }
-   
-   public boolean equals(Object other)
-   {
-      if (this == other)
-      {
-         return true;
-      }
-      
-      Destination dother = (Destination)other;
-      
-      return dother.getType() == this.type && dother.getName().equals(this.name) &&
-             dother.isTemporary() == this.temporary;
-   }
-   
-   public int hashCode()
-   {
-      if (!hashAssigned)
-      {
-         hash = 17;
-         hash = 37 * hash + DestinationType.toInt(type);
-         hash = 37 * hash + name.hashCode();
-         hash = 37 * hash + (temporary ? 1 : 0);
-         
-         hashAssigned = true;
-      }
-
-      return hash;
-   }
-
-}

Modified: trunk/src/main/org/jboss/messaging/core/impl/MessageReferenceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/MessageReferenceImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/MessageReferenceImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -123,7 +123,7 @@
          persistenceManager.deleteReference(this);
       }
       
-      queue.referenceAcknowledged();
+      queue.decrementDeliveringCount();
    }
    
    public void cancel(PersistenceManager persistenceManager) throws Exception
@@ -135,7 +135,7 @@
          persistenceManager.updateDeliveryCount(queue, this);
       }
             
-      queue.referenceAcknowledged();
+      queue.decrementDeliveringCount();
    }
    
    // Public --------------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/impl/PriorityLinkedListImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/PriorityLinkedListImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/PriorityLinkedListImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -211,13 +211,16 @@
          {
             return true;
          }
+         
          while (index >= 0)
          {                 
             if (index == 0 || currentIter.hasNext())
             {
                break;
             }                 
+            
             index--;
+            
             currentIter = linkedLists.get(index).listIterator();
          }
          return currentIter.hasNext();      

Modified: trunk/src/main/org/jboss/messaging/core/impl/QueueImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/QueueImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/QueueImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -344,7 +344,7 @@
       return deliveringCount.get();
    }
 
-   public void referenceAcknowledged()
+   public void decrementDeliveringCount()
    {
       deliveringCount.decrementAndGet();
    }

Modified: trunk/src/main/org/jboss/messaging/core/impl/TransactionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/TransactionImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/TransactionImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -144,7 +144,7 @@
       
       for (MessageReference reference: acknowledgements)
       {
-         reference.getQueue().referenceAcknowledged();
+         reference.getQueue().decrementDeliveringCount();
       }
       
       callSynchronizations(SyncType.AFTER_COMMIT);
@@ -263,7 +263,6 @@
          
          for (MessageReference ref: refs)
          {
-            //Need to update delivery counts
             ref.cancel(persistenceManager);
          }
                   

Modified: trunk/src/main/org/jboss/messaging/core/impl/bdbje/BDBJEPersistenceManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/bdbje/BDBJEPersistenceManager.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/bdbje/BDBJEPersistenceManager.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -35,7 +35,6 @@
 import javax.transaction.xa.Xid;
 
 import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
 import org.jboss.messaging.core.Filter;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.MessageReference;
@@ -43,7 +42,6 @@
 import org.jboss.messaging.core.Queue;
 import org.jboss.messaging.core.QueueFactory;
 import org.jboss.messaging.core.impl.BindingImpl;
-import org.jboss.messaging.core.impl.ConditionImpl;
 import org.jboss.messaging.core.impl.MessageImpl;
 import org.jboss.messaging.core.impl.filter.FilterImpl;
 import org.jboss.messaging.util.Logger;
@@ -388,7 +386,7 @@
          * Office name
          * Node id
          * Queue name
-         * Condition string
+         * Address string
          * All nodes?
          * Filter string
      */
@@ -405,10 +403,8 @@
       
       daos.writeUTF(queue.getName());
       
-      binding.getCondition().write(daos);
+      daos.writeUTF(binding.getAddress());
       
-      daos.writeBoolean(binding.isAllNodes());
-      
       Filter filter = queue.getFilter();
       
       daos.writeBoolean(filter != null);
@@ -466,12 +462,8 @@
             
             String queueName = dais.readUTF();
             
-            Condition condition = new ConditionImpl();
-            
-            condition.read(dais);
-            
-            boolean allNodes = dais.readBoolean();
-            
+            String address = dais.readUTF();
+               
             Filter filter = null;
             
             if (dais.readBoolean())
@@ -483,7 +475,7 @@
             
             maxChannelID = Math.max(maxChannelID, queueID);
             
-            Binding binding = new BindingImpl(nodeID, condition, queue, allNodes);
+            Binding binding = new BindingImpl(nodeID, address, queue);
             
             bindings.put(queueID, binding);            
          }
@@ -738,7 +730,12 @@
       {
          if (ref.getQueue().isDurable())
          {
-            buff.putLong(ref.getQueue().getPersistenceID());
+            long queueID = ref.getQueue().getPersistenceID();
+            if (queueID == -1)
+            {
+               throw new IllegalStateException("Cannot persist - queue binding hasn't been persisted!");
+            }
+            buff.putLong(queueID);
             buff.putInt(ref.getDeliveryCount());
             buff.putLong(ref.getScheduledDeliveryTime());   
          }

Modified: trunk/src/main/org/jboss/messaging/core/impl/filter/FilterImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/filter/FilterImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/filter/FilterImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -27,6 +27,7 @@
 import org.jboss.messaging.core.Filter;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
 * This class implements a JBoss Messaging filter
@@ -68,7 +69,7 @@
   
   private FilterParser parser = new FilterParser();
   
-  public FilterImpl(String filterString) throws Exception
+  public FilterImpl(String filterString) throws MessagingException
   {
      this.filterString = filterString;
 
@@ -78,7 +79,7 @@
      }
      catch (Throwable e)
      {
-        throw new IllegalArgumentException("Invalid filter: " + filterString);
+        throw new MessagingException(MessagingException.INVALID_FILTER_EXPRESSION, "Invalid filter: " + filterString);
      }
   }
   

Modified: trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessageRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessageRequest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/postoffice/MessageRequest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -24,10 +24,8 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 
-import org.jboss.messaging.core.Condition;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.PostOffice;
-import org.jboss.messaging.core.impl.ConditionImpl;
 import org.jboss.messaging.core.impl.MessageImpl;
 
 /**
@@ -43,7 +41,7 @@
  */
 public class MessageRequest extends ClusterRequest
 {
-   private Condition condition;   
+   private String address;   
    
    private Message message;
    
@@ -53,9 +51,9 @@
    {      
    }
    
-   MessageRequest(Condition condition, Message message)//, Set queueNames)
+   MessageRequest(String address, Message message)//, Set queueNames)
    {
-      this.condition = condition;
+      this.address = address;
       
       this.message = message;
       
@@ -64,7 +62,7 @@
    
    Object execute(PostOffice office) throws Exception
    {
-      office.routeFromCluster(condition, message);    
+      office.routeFromCluster(address, message);    
       
       return null;
    }  
@@ -76,10 +74,8 @@
    
    public void read(DataInputStream in) throws Exception
    {
-      condition = new ConditionImpl();
+      address = in.readUTF();
       
-      condition.read(in);
-      
       message = new MessageImpl();
       
       message.read(in);  
@@ -103,7 +99,7 @@
    
    public void write(DataOutputStream out) throws Exception
    {
-      condition.write(out);
+      out.writeUTF(address);
       
       message.write(out);
       

Modified: trunk/src/main/org/jboss/messaging/core/impl/postoffice/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/postoffice/PostOfficeImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/postoffice/PostOfficeImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -27,10 +27,10 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
 import org.jboss.messaging.core.Filter;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.MessageReference;
@@ -38,10 +38,10 @@
 import org.jboss.messaging.core.PostOffice;
 import org.jboss.messaging.core.Queue;
 import org.jboss.messaging.core.QueueFactory;
-import org.jboss.messaging.core.TransactionSynchronization;
 import org.jboss.messaging.core.impl.BindingImpl;
 import org.jboss.messaging.util.ConcurrentHashSet;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * 
@@ -56,23 +56,28 @@
    
    private int nodeID;
    
-  // private Map<Integer, Map<String, Queue>> queues = new HashMap<Integer, Map<String, Queue>>();
+   private ConcurrentMap<String, List<Binding>> mappings = new ConcurrentHashMap<String, List<Binding>>();
    
-   private Map<Condition, List<Binding>> mappings = new ConcurrentHashMap<Condition, List<Binding>>();
+   private Set<String> allowableAddresses = new ConcurrentHashSet<String>();
    
-   private Set<Condition> conditions = new ConcurrentHashSet<Condition>();
+   private ConcurrentMap<String, Binding> nameMap = new ConcurrentHashMap<String, Binding>();
    
    private PersistenceManager persistenceManager;
    
    private QueueFactory queueFactory;
+   
+   private boolean checkAllowable;
     
-   public PostOfficeImpl(int nodeID, PersistenceManager persistenceManager, QueueFactory queueFactory)
+   public PostOfficeImpl(int nodeID, PersistenceManager persistenceManager, QueueFactory queueFactory,
+                         boolean checkAllowable)
    {
       this.nodeID = nodeID;
       
       this.persistenceManager = persistenceManager;
       
       this.queueFactory = queueFactory;
+      
+      this.checkAllowable = checkAllowable;
    }
       
    // MessagingComponent implementation ---------------------------------------
@@ -86,65 +91,92 @@
    {
       mappings.clear();
       
-      conditions.clear();
+      allowableAddresses.clear();
    }
    
    // PostOffice implementation -----------------------------------------------
 
-   public Queue addQueue(Condition condition, String name, Filter filter, 
-                         boolean durable, boolean temporary, boolean allNodes) throws Exception
+   public void addAllowableAddress(String address)
+   {      
+      allowableAddresses.add(address);
+   }
+   
+   public boolean removeAllowableAddress(String address)
+   {      
+      return allowableAddresses.remove(address);
+   }
+   
+   public boolean containsAllowableAddress(String address)
    {
-      Binding binding = createBinding(condition, name, filter, durable, temporary, allNodes);
-      
+      return allowableAddresses.contains(address);
+   }
+   
+   public Binding addBinding(String address, String queueName, Filter filter, 
+                             boolean durable, boolean temporary) throws Exception
+   {
+      Binding binding = createBinding(address, queueName, filter, durable, temporary);
+
       addBindingInMemory(binding);
-       
+      
       if (durable)
       {
          persistenceManager.addBinding(binding);
       }
       
-      return binding.getQueue();
+      return binding;      
    }
          
-   public boolean removeQueue(Condition condition, String name, boolean allNodes) throws Exception
+   public Binding removeBinding(String queueName) throws Exception
    {
-      Binding binding = removeQueueInMemory(condition, name);
+      Binding binding = removeQueueInMemory(queueName);
       
-      if (binding != null)
+      if (binding.getQueue().isDurable())
       {
-         if (binding.getQueue().isDurable())
+         persistenceManager.deleteBinding(binding);
+      }
+      
+      return binding;
+   }
+   
+   public List<Binding> getBindingsForAddress(String address)
+   {
+      List<Binding> list = new ArrayList<Binding>();
+      
+      List<Binding> bindings = mappings.get(address);
+      
+      if (bindings != null)
+      {
+         for (Binding binding: bindings)
          {
-            persistenceManager.deleteBinding(binding);
+            if (binding.getNodeID() == nodeID)
+            {
+               list.add(binding);
+            }
          }
+      }         
          
-         return true;
-      }
-      else
-      {
-         return false;
-      }            
+      return list;
    }
    
-   public void addCondition(Condition condition)
-   {      
-      conditions.add(condition);
-   }
-   
-   public boolean removeCondition(Condition condition)
-   {      
-      return conditions.remove(condition);
-   }
-   
-   public boolean containsCondition(Condition condition)
+   public Binding getBinding(String queueName)
    {
-      return conditions.contains(condition);
+      return nameMap.get(queueName);
    }
-    
-   public void route(Condition condition, Message message) throws Exception
+         
+   public void route(String address, Message message) throws Exception
    {
      // boolean routeRemote = false;
+      
+      if (checkAllowable)
+      {
+         if (!allowableAddresses.contains(address))
+         {
+            throw new MessagingException(MessagingException.ADDRESS_DOES_NOT_EXIST,
+                                         "Cannot route to address " + address);
+         }
+      }
            
-      List<Binding> bindings = mappings.get(condition);
+      List<Binding> bindings = mappings.get(address);
       
       if (bindings != null)
       {
@@ -177,13 +209,13 @@
       
 //      if (routeRemote)
 //      {
-//         tx.addSynchronization(new CastMessageCallback(new MessageRequest(condition, message)));
+//         tx.addSynchronization(new CastMessageCallback(new MessageRequest(address, message)));
 //      }
    }
    
-   public void routeFromCluster(Condition condition, Message message) throws Exception
+   public void routeFromCluster(String address, Message message) throws Exception
    {     
-      List<Binding> bindings = mappings.get(condition);
+      List<Binding> bindings = mappings.get(address);
       
       for (Binding binding: bindings)
       {
@@ -203,105 +235,60 @@
       }
    }
 
-   public Map<Condition, List<Binding>> getMappings()
+   public Map<String, List<Binding>> getMappings()
    {
       return mappings;
    }
    
-   public List<Binding> getBindingsForQueueName(String queueName)
-   {
-      List<Binding> list = new ArrayList<Binding>();
-      
-      for (List<Binding> bindings: mappings.values())
-      {
-         for (Binding binding: bindings)
-         {
-            if (binding.getQueue().getName().equals(queueName) && binding.getNodeID() == nodeID)
-            {
-               list.add(binding);
-            }
-         }
-      }
-      return list;
-   }
    
-   public List<Binding> getBindingsForCondition(Condition condition)
-   {
-      List<Binding> list = new ArrayList<Binding>();
-      
-      List<Binding> bindings = mappings.get(condition);
-      
-      if (bindings != null)
-      {
-         for (Binding binding: bindings)
-         {
-            if (binding.getNodeID() == nodeID)
-            {
-               list.add(binding);
-            }
-         }
-      }         
-         
-      return list;
-   }
    
    // Private -----------------------------------------------------------------
    
-   private Binding createBinding(Condition condition, String name, Filter filter,
-                                 boolean durable, boolean temporary, boolean allNodes)
+   private Binding createBinding(String address, String name, Filter filter,
+                                 boolean durable, boolean temporary)
    {
       Queue queue = queueFactory.createQueue(-1, name, filter, durable, temporary);
       
-      Binding binding = new BindingImpl(this.nodeID, condition, queue, allNodes);
+      Binding binding = new BindingImpl(this.nodeID, address, queue);
       
       return binding;
    }
    
-   private void addBindingInMemory(Binding binding) throws Exception
-   {      
-      List<Binding> bindings = mappings.get(binding.getCondition());
+   private void addBindingInMemory(Binding binding)
+   {              
+      List<Binding> bindings = new CopyOnWriteArrayList<Binding>();
       
-      if (bindings == null)
+      List<Binding> prevBindings = mappings.putIfAbsent(binding.getAddress(), bindings);
+      
+      if (prevBindings != null)
       {
-         bindings = new CopyOnWriteArrayList<Binding>();
-         
-         mappings.put(binding.getCondition(), bindings);
+         bindings = prevBindings;
       }
-      
-      bindings.add(binding);
-      
-   //      Map<String, Queue> nameMap = queues.get(nodeID);
-   //      
-   //      if (nameMap == null)
-   //      {
-   //         nameMap = new HashMap<String, Queue>();
-   //         
-   //         queues.put(nodeID, nameMap);
-   //      }
-   //      
-   //      nameMap.put(name, queue);
+                     
+      bindings.add(binding);  
+
+      if (nameMap.putIfAbsent(binding.getQueue().getName(), binding) != null)
+      {
+         throw new IllegalStateException("Binding already exists " + binding);
+      }     
    }
    
-   private Binding removeQueueInMemory(Condition condition, String name) throws Exception
+   private Binding removeQueueInMemory(String queueName) throws Exception
    {
-      Binding binding = null;
+      Binding binding = nameMap.remove(queueName);
       
-   //      Map<String, Queue> nameMap = queues.get(nodeID);
-   //      
-   //      nameMap.remove(name);
-   //      
-   //      if (nameMap.isEmpty())
-   //      {
-   //         queues.remove(nodeID);
-   //      }
-             
-      List<Binding> bindings = mappings.get(condition);
+      if (binding == null)
+      {
+         throw new IllegalStateException("Queue is not bound " + queueName);
+      }
                   
+      List<Binding> bindings = mappings.get(binding.getAddress());
+                  
       for (Iterator<Binding> iter = bindings.iterator(); iter.hasNext();)
       {
          Binding b = iter.next();
          
-         if (b.getQueue().getName().equals(name))
+         if (b.getQueue().getName().equals(queueName))
          {
             binding = b;
                                           
@@ -309,16 +296,18 @@
          }
       }
       
-      if (binding != null)
+      if (binding == null)
       {
-         bindings.remove(binding);
+         throw new IllegalStateException("Cannot find binding " + queueName);
       }
       
+      bindings.remove(binding);      
+      
       if (bindings.isEmpty())
       {
-         mappings.remove(condition);
+         mappings.remove(binding.getAddress());
       }
-         
+               
       return binding;
    }
    
@@ -331,36 +320,5 @@
          addBindingInMemory(binding);                    
       }
    }
-   
-   private void deleteMappingsForNode(int theNodeID)
-   {
-      
-   }
-   
-   private class CastMessageCallback implements TransactionSynchronization
-   {
-      private ClusterRequest request;
-      
-      CastMessageCallback(ClusterRequest request)
-      {
-         this.request = request;
-      }
-      
-      public void afterCommit() throws Exception
-      {
-         //TODO - cast request
-      }
 
-      public void afterRollback() throws Exception
-      { 
-      }
-
-      public void beforeCommit() throws Exception
-      {
-      }
-
-      public void beforeRollback() throws Exception
-      {
-      } 
-   }
 }

Modified: trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -30,12 +30,14 @@
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.jms.destination.JBossDestination;
+import org.jboss.jms.destination.JBossQueue;
+import org.jboss.jms.destination.JBossTopic;
 import org.jboss.jms.server.ConnectionManager;
 import org.jboss.jms.server.MessagingTimeoutFactory;
 import org.jboss.jms.server.SecurityStore;
-import org.jboss.jms.server.TransactionRepository;
 import org.jboss.jms.server.connectionmanager.SimpleConnectionManager;
-import org.jboss.jms.server.endpoint.ConnectionFactoryAdvisedPacketHandler;
+import org.jboss.jms.server.endpoint.MessagingServerPacketHandler;
 import org.jboss.jms.server.endpoint.ServerSessionEndpoint;
 import org.jboss.jms.server.plugin.NullUserManager;
 import org.jboss.jms.server.plugin.contract.JMSUserManager;
@@ -44,9 +46,7 @@
 import org.jboss.jms.server.security.SecurityMetadataStore;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
 import org.jboss.messaging.core.Configuration;
-import org.jboss.messaging.core.DestinationType;
 import org.jboss.messaging.core.MemoryManager;
 import org.jboss.messaging.core.MessagingServer;
 import org.jboss.messaging.core.NullPersistenceManager;
@@ -56,7 +56,6 @@
 import org.jboss.messaging.core.QueueFactory;
 import org.jboss.messaging.core.QueueSettings;
 import org.jboss.messaging.core.ResourceManager;
-import org.jboss.messaging.core.impl.ConditionImpl;
 import org.jboss.messaging.core.impl.QueueFactoryImpl;
 import org.jboss.messaging.core.impl.ResourceManagerImpl;
 import org.jboss.messaging.core.impl.memory.SimpleMemoryManager;
@@ -111,7 +110,6 @@
    private SimpleConnectionManager connectionManager;
    private MemoryManager memoryManager = new SimpleMemoryManager();
    private MessageCounterManager messageCounterManager;
-   private TransactionRepository transactionRepository = new TransactionRepository();
    private PostOffice postOffice;
    private SecurityDeployer securityDeployer;
    private QueueSettingsDeployer queueSettingsDeployer;
@@ -201,7 +199,7 @@
             }
          });
          postOffice = new PostOfficeImpl(configuration.getMessagingServerID(),
-                                         persistenceManager, queueFactory);
+                                         persistenceManager, queueFactory, configuration.isStrictTck());
 
          if(createTransport)
          {
@@ -214,9 +212,8 @@
          remotingService.addConnectionExceptionListener(connectionManager);
          memoryManager.start();
          postOffice.start();
-         ConnectionFactoryAdvisedPacketHandler connectionFactoryAdvisedPacketHandler =
-                 new ConnectionFactoryAdvisedPacketHandler(this);
-         getRemotingService().getDispatcher().register(connectionFactoryAdvisedPacketHandler);
+         MessagingServerPacketHandler serverPacketHandler =  new MessagingServerPacketHandler(this);
+         getRemotingService().getDispatcher().register(serverPacketHandler);
          
          ClassLoader loader = Thread.currentThread().getContextClassLoader();
          for (String interceptorClass: configuration.getDefaultInterceptors())
@@ -337,44 +334,6 @@
       }
    }
 
-   public synchronized Queue getDefaultDLQInstance() throws Exception
-   {
-      if (configuration.getDefaultDLQ() != null)
-      {
-         List<Binding> bindings = postOffice.getBindingsForQueueName(configuration.getDefaultDLQ());
-
-         if (bindings.isEmpty())
-         {
-            throw new IllegalStateException("Cannot find binding for queue " + configuration.getDefaultDLQ());
-         }
-
-         return bindings.get(0).getQueue();
-      }
-      else
-      {
-         return null;
-      }
-   }
-
-   public synchronized Queue getDefaultExpiryQueueInstance() throws Exception
-   {
-      if (configuration.getDefaultExpiryQueue() != null)
-      {
-         List<Binding> bindings = postOffice.getBindingsForQueueName(configuration.getDefaultExpiryQueue());
-
-         if (bindings.isEmpty())
-         {
-            throw new IllegalStateException("Cannot find binding for queue " + configuration.getDefaultExpiryQueue());
-         }
-
-         return bindings.get(0).getQueue();
-      }
-      else
-      {
-         return null;
-      }
-   }
-
    public void enableMessageCounters()
    {
       messageCounterManager.start();
@@ -391,13 +350,17 @@
 
    public void createQueue(String name) throws Exception
    {
-      Condition queueCond = new ConditionImpl(DestinationType.QUEUE, name);
-
-      if (!getPostOffice().containsCondition(queueCond))
+      JBossQueue queue = new JBossQueue(name);
+      
+      if (getPostOffice().getBinding(queue.getAddress()) == null)
       {
-         getPostOffice().addQueue(queueCond, name, null, true, false, false);
-         getPostOffice().addCondition(queueCond);
+         getPostOffice().addBinding(queue.getAddress(), queue.getAddress(), null, true, false);         
       }
+      
+      if (!getPostOffice().containsAllowableAddress(queue.getAddress()))
+      {
+         getPostOffice().addAllowableAddress(queue.getAddress());
+      }
    }
 
    public void destroyQueue(String name) throws Exception
@@ -407,10 +370,11 @@
 
    public void createTopic(String name) throws Exception
    {
-      Condition topicCond = new ConditionImpl(DestinationType.TOPIC, name);
-      if (!getPostOffice().containsCondition(topicCond));
+      JBossTopic topic = new JBossTopic(name);
+   
+      if (!getPostOffice().containsAllowableAddress(topic.getAddress()));
       {
-         getPostOffice().addCondition(topicCond);
+         getPostOffice().addAllowableAddress(topic.getAddress());
       }
    }
 
@@ -431,10 +395,10 @@
 
    public void removeAllMessagesForQueue(String queueName) throws Exception
    {
-      Condition condition = new ConditionImpl(DestinationType.QUEUE, queueName);
+      JBossQueue jbq = new JBossQueue(queueName);
+      
+      List<Binding> bindings = postOffice.getBindingsForAddress(jbq.getAddress());
 
-      List<Binding> bindings = postOffice.getBindingsForCondition(condition);
-
       if (!bindings.isEmpty())
       {
          Queue queue = bindings.get(0).getQueue();
@@ -447,10 +411,10 @@
 
    public void removeAllMessagesForTopic(String queueName) throws Exception
    {
-      Condition condition = new ConditionImpl(DestinationType.QUEUE, queueName);
+      JBossTopic jbt = new JBossTopic(queueName);
+      
+      List<Binding> bindings = postOffice.getBindingsForAddress(jbt.getAddress());
 
-      List<Binding> bindings = postOffice.getBindingsForCondition(condition);
-
       for (Binding binding: bindings)
       {
          Queue queue = binding.getQueue();
@@ -479,11 +443,6 @@
       return memoryManager;
    }
 
-   public TransactionRepository getTransactionRepository()
-   {
-      return transactionRepository;
-   }
-
    public PersistenceManager getPersistenceManager()
    {
       return persistenceManager;
@@ -551,9 +510,18 @@
 
    private boolean destroyDestination(boolean isQueue, String name) throws Exception
    {
-      Condition condition = new ConditionImpl(isQueue ? DestinationType.QUEUE : DestinationType.TOPIC, name);
+      JBossDestination dest;
+      
+      if (isQueue)
+      {
+         dest = new JBossQueue(name);
+      }
+      else
+      {
+         dest = new JBossTopic(name);
+      }
 
-      List<Binding> bindings = getPostOffice().getBindingsForCondition(condition);
+      List<Binding> bindings = getPostOffice().getBindingsForAddress(dest.getAddress());
 
       boolean destroyed = false;
 
@@ -565,15 +533,12 @@
 
          queue.removeAllReferences();
 
-         //Durable subs need to be removed on all nodes
-         boolean all = !isQueue && queue.isDurable();
+         getPostOffice().removeBinding(queue.getName());
 
-         getPostOffice().removeQueue(condition, queue.getName(), all);
-
          destroyed = true;
       }
 
-      getPostOffice().removeCondition(condition);
+      getPostOffice().removeAllowableAddress(dest.getAddress());
 
       return destroyed;
    }

Modified: trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerManagementImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerManagementImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerManagementImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,22 +21,18 @@
    */
 package org.jboss.messaging.core.impl.server;
 
-import org.jboss.aop.microcontainer.aspects.jmx.JMX;
-import org.jboss.jms.client.SelectorTranslator;
-import org.jboss.jms.server.endpoint.ServerConnectionEndpoint;
-import org.jboss.messaging.core.*;
-import org.jboss.messaging.core.impl.ConditionImpl;
-import org.jboss.messaging.core.impl.filter.FilterImpl;
-import org.jboss.messaging.core.impl.messagecounter.MessageCounter;
-import org.jboss.messaging.util.MessageQueueNameHelper;
-
-import java.io.CharArrayWriter;
-import java.io.PrintWriter;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import java.util.StringTokenizer;
 
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.jms.destination.JBossQueue;
+import org.jboss.jms.destination.JBossTopic;
+import org.jboss.messaging.core.Binding;
+import org.jboss.messaging.core.MessagingServer;
+import org.jboss.messaging.core.MessagingServerManagement;
+import org.jboss.messaging.core.Queue;
+import org.jboss.messaging.util.MessageQueueNameHelper;
+
 /**
  * This interface describes the properties and operations that comprise the management interface of the
  * Messaging Server.
@@ -58,16 +54,16 @@
       this.messagingServer = messagingServer;
    }
 
-   public String getServerVersion()
-   {      
-      return messagingServer.getVersion().getProviderVersion();
-   }
-
-   public Configuration getConfiguration()
-   {
-      return messagingServer.getConfiguration();
-   }
-   
+//   public String getServerVersion()
+//   {      
+//      return messagingServer.getVersion().getProviderVersion();
+//   }
+//
+//   public Configuration getConfiguration()
+//   {
+//      return messagingServer.getConfiguration();
+//   }
+//   
    public boolean isStarted()
    {
       return messagingServer.isStarted();
@@ -112,742 +108,744 @@
    {
       return listAllSubscriptions(topicName);
    }
-
-//   public int getDeliveringCountForQueue(String queue) throws Exception
+//
+////   public int getDeliveringCountForQueue(String queue) throws Exception
+////   {
+////      return getQueue(queue).getDeliveringCount();
+////   }
+//
+//   public int getScheduledMessageCountForQueue(String queue) throws Exception
 //   {
-//      return getQueue(queue).getDeliveringCount();
+//      return getQueue(queue).getScheduledCount();
 //   }
-
-   public int getScheduledMessageCountForQueue(String queue) throws Exception
-   {
-      return getQueue(queue).getScheduledCount();
-   }
-
-//   public MessageCounter getMessageCounterForQueue(String queue) throws Exception
+//
+////   public MessageCounter getMessageCounterForQueue(String queue) throws Exception
+////   {
+////      return getQueue(queue).getMessageCounter();
+////   }
+//
+////   public MessageStatistics getMessageStatisticsForQueue(String queue) throws Exception
+////   {
+////      List counters = new ArrayList();
+////      counters.add(getQueue(queue).getMessageCounter());
+////
+////      List stats = MessageCounter.getMessageStatistics(counters);
+////
+////      return (MessageStatistics)stats.get(0);
+////   }
+//
+//   public int getConsumerCountForQueue(String queue) throws Exception
 //   {
-//      return getQueue(queue).getMessageCounter();
+//      return getQueue(queue).getConsumerCount();
 //   }
-
-//   public MessageStatistics getMessageStatisticsForQueue(String queue) throws Exception
+//
+////   public void resetMessageCounterForQueue(String queue) throws Exception
+////   {
+////      getMessageCounterForQueue(queue).resetCounter();
+////   }
+////
+////   public void resetMessageCounterHistoryForQueue(String queue) throws Exception
+////   {
+////      getMessageCounterForQueue(queue).resetHistory();
+////   }
+//
+////   public List<Message> listAllMessagesForQueue(String queue) throws Exception
+////   {
+////      return getQueue(queue).listAllMessages(null);
+////   }
+//
+//   public List<Message> listAllMessagesForQueue(String queue, String selector) throws Exception
 //   {
-//      List counters = new ArrayList();
-//      counters.add(getQueue(queue).getMessageCounter());
+//      return listAllMessages(getQueue(queue), selector);
+//   }
 //
-//      List stats = MessageCounter.getMessageStatistics(counters);
+//   public List<Message> listDurableMessagesForQueue(String queue) throws Exception
+//   {
+//      return listDurableMessages(getQueue(queue), null);
+//   }
 //
-//      return (MessageStatistics)stats.get(0);
+//   public List<Message> listDurableMessagesForQueue(String queue, String selector) throws Exception
+//   {
+//      return listDurableMessages(getQueue(queue), selector);
 //   }
-
-   public int getConsumerCountForQueue(String queue) throws Exception
-   {
-      return getQueue(queue).getConsumerCount();
-   }
-
-//   public void resetMessageCounterForQueue(String queue) throws Exception
+//
+//   public List<Message> listNonDurableMessagesForQueue(String queue) throws Exception
 //   {
-//      getMessageCounterForQueue(queue).resetCounter();
+//      return listNonDurableMessages(getQueue(queue), null);
 //   }
 //
-//   public void resetMessageCounterHistoryForQueue(String queue) throws Exception
+//   public List<Message> listNonDurableMessagesForQueue(String queue, String selector) throws Exception
 //   {
-//      getMessageCounterForQueue(queue).resetHistory();
+//      return listNonDurableMessages(getQueue(queue), selector);
 //   }
-
-//   public List<Message> listAllMessagesForQueue(String queue) throws Exception
+//
+////   public String listMessageCounterAsHTMLForQueue(String queue) throws Exception
+////   {
+////      return listMessageCounterAsHTML(new MessageCounter[] { getMessageCounterForQueue(queue) });
+////   }
+////
+////   public String listMessageCounterHistoryAsHTMLForQueue(String queue) throws Exception
+////   {
+////      return listMessageCounterHistoryAsHTML(new MessageCounter[] {getMessageCounterForQueue(queue)});
+////   }
+//
+//   public int getAllMessageCountForTopic(String topicName) throws Exception
 //   {
-//      return getQueue(queue).listAllMessages(null);
+//      return getAllMessageCountForTopic(topicName);
 //   }
-
-   public List<Message> listAllMessagesForQueue(String queue, String selector) throws Exception
-   {
-      return listAllMessages(getQueue(queue), selector);
-   }
-
-   public List<Message> listDurableMessagesForQueue(String queue) throws Exception
-   {
-      return listDurableMessages(getQueue(queue), null);
-   }
-
-   public List<Message> listDurableMessagesForQueue(String queue, String selector) throws Exception
-   {
-      return listDurableMessages(getQueue(queue), selector);
-   }
-
-   public List<Message> listNonDurableMessagesForQueue(String queue) throws Exception
-   {
-      return listNonDurableMessages(getQueue(queue), null);
-   }
-
-   public List<Message> listNonDurableMessagesForQueue(String queue, String selector) throws Exception
-   {
-      return listNonDurableMessages(getQueue(queue), selector);
-   }
-
-//   public String listMessageCounterAsHTMLForQueue(String queue) throws Exception
+//
+//   public int getDurableMessageCountForTopic(String topicName) throws Exception
 //   {
-//      return listMessageCounterAsHTML(new MessageCounter[] { getMessageCounterForQueue(queue) });
+//      return getDurableMessageCountForTopic(topicName);
 //   }
 //
-//   public String listMessageCounterHistoryAsHTMLForQueue(String queue) throws Exception
+//   public int getNonDurableMessageCountForTopic(String topicName) throws Exception
 //   {
-//      return listMessageCounterHistoryAsHTML(new MessageCounter[] {getMessageCounterForQueue(queue)});
+//      return getNonDurableMessageCountForTopic(topicName);
 //   }
-
-   public int getAllMessageCountForTopic(String topicName) throws Exception
-   {
-      return getAllMessageCountForTopic(topicName);
-   }
-
-   public int getDurableMessageCountForTopic(String topicName) throws Exception
-   {
-      return getDurableMessageCountForTopic(topicName);
-   }
-
-   public int getNonDurableMessageCountForTopic(String topicName) throws Exception
-   {
-      return getNonDurableMessageCountForTopic(topicName);
-   }
-
-   public int getAllSubscriptionsCountForTopic(String topicName) throws Exception
-   {
-      return getAllSubscriptionsCountForTopic(topicName);
-   }
-
-   public int getDurableSubscriptionsCountForTopic(String topicName) throws Exception
-   {
-      return getDurableSubscriptionsCountForTopic(topicName);
-   }
-
-   public int getNonDurableSubscriptionsCountForTopic(String topicName) throws Exception
-   {
-      return getNonDurableSubscriptionsCountForTopic(topicName);
-   }
-
-
-
-
-   public List<SubscriptionInfo> listDurableSubscriptionsForTopic(String topicName) throws Exception
-   {
-      return listDurableSubscriptions(topicName);
-   }
-
-   public List<SubscriptionInfo> listNonDurableSubscriptionsForTopic(String topicName) throws Exception
-   {
-      return listNonDurableSubscriptions(topicName);
-   }
-
-   public String listAllSubscriptionsAsHTMLForTopic(String topicName) throws Exception
-   {
-      return listAllSubscriptionsAsHTML(topicName);
-   }
-
-   public String listDurableSubscriptionsAsHTMLForTopic(String topicName) throws Exception
-   {
-      return listDurableSubscriptionsAsHTML(topicName);
-   }
-
-   public String listNonDurableSubscriptionsAsHTMLForTopic(String topicName) throws Exception
-   {
-      return listNonDurableSubscriptionsAsHTML(topicName);
-   }
-
-//   public List<Message> listAllMessagesForSubscription(String subscriptionId) throws Exception
+//
+//   public int getAllSubscriptionsCountForTopic(String topicName) throws Exception
 //   {
-//      return listAllMessagesForSubscription(subscriptionId, null);
+//      return getAllSubscriptionsCountForTopic(topicName);
 //   }
 //
-//   public List<Message> listAllMessagesForSubscription(String subscriptionId, String selector) throws Exception
+//   public int getDurableSubscriptionsCountForTopic(String topicName) throws Exception
 //   {
-//      return listAllMessages(subscriptionId, selector);
+//      return getDurableSubscriptionsCountForTopic(topicName);
 //   }
 //
-//   public List<Message> listDurableMessagesForSubscription(String subscriptionId) throws Exception
+//   public int getNonDurableSubscriptionsCountForTopic(String topicName) throws Exception
 //   {
-//      return listDurableMessages(subscriptionId, null);
+//      return getNonDurableSubscriptionsCountForTopic(topicName);
 //   }
 //
-//   public List<Message> listDurableMessagesForTopic(String topicName, String subscriptionId, String selector) throws Exception
+//
+//
+//
+//   public List<SubscriptionInfo> listDurableSubscriptionsForTopic(String topicName) throws Exception
 //   {
-//      return listDurableMessages(topicName, subscriptionId, selector);
+//      return listDurableSubscriptions(topicName);
 //   }
 //
-//   public List<Message> listNonDurableMessagesForTopic(String topicName, String subscriptionId) throws Exception
+//   public List<SubscriptionInfo> listNonDurableSubscriptionsForTopic(String topicName) throws Exception
 //   {
-//      return listNonDurableMessages(subscriptionId, null);
+//      return listNonDurableSubscriptions(topicName);
 //   }
 //
-//   public List<Message> listNonDurableMessagesForTopic(String topicName, String subscriptionId, String selector) throws Exception
+//   public String listAllSubscriptionsAsHTMLForTopic(String topicName) throws Exception
 //   {
-//      return listNonDurableMessages(subscriptionId, selector);
+//      return listAllSubscriptionsAsHTML(topicName);
 //   }
-
-   public List<MessageCounter> getMessageCountersForTopic(String topicName) throws Exception
+//
+//   public String listDurableSubscriptionsAsHTMLForTopic(String topicName) throws Exception
+//   {
+//      return listDurableSubscriptionsAsHTML(topicName);
+//   }
+//
+//   public String listNonDurableSubscriptionsAsHTMLForTopic(String topicName) throws Exception
+//   {
+//      return listNonDurableSubscriptionsAsHTML(topicName);
+//   }
+//
+////   public List<Message> listAllMessagesForSubscription(String subscriptionId) throws Exception
+////   {
+////      return listAllMessagesForSubscription(subscriptionId, null);
+////   }
+////
+////   public List<Message> listAllMessagesForSubscription(String subscriptionId, String selector) throws Exception
+////   {
+////      return listAllMessages(subscriptionId, selector);
+////   }
+////
+////   public List<Message> listDurableMessagesForSubscription(String subscriptionId) throws Exception
+////   {
+////      return listDurableMessages(subscriptionId, null);
+////   }
+////
+////   public List<Message> listDurableMessagesForTopic(String topicName, String subscriptionId, String selector) throws Exception
+////   {
+////      return listDurableMessages(topicName, subscriptionId, selector);
+////   }
+////
+////   public List<Message> listNonDurableMessagesForTopic(String topicName, String subscriptionId) throws Exception
+////   {
+////      return listNonDurableMessages(subscriptionId, null);
+////   }
+////
+////   public List<Message> listNonDurableMessagesForTopic(String topicName, String subscriptionId, String selector) throws Exception
+////   {
+////      return listNonDurableMessages(subscriptionId, selector);
+////   }
+//
+//   public List<MessageCounter> getMessageCountersForTopic(String topicName) throws Exception
+//   {
+//      return getMessageCounters(topicName);
+//   }
+//
+//   public String showActiveClientsAsHTML() throws Exception
+//   {
+//      CharArrayWriter charArray = new CharArrayWriter();
+//      PrintWriter out = new PrintWriter(charArray);
+//
+//      List endpoints = messagingServer.getConnectionManager().getActiveConnections();
+//
+//      out.println("<table><tr><td>ID</td><td>Host</td><td>User</td><td>#Sessions</td></tr>");
+//      for (Iterator iter = endpoints.iterator(); iter.hasNext();)
+//      {
+//         ServerConnectionEndpoint endpoint = (ServerConnectionEndpoint) iter.next();
+//
+//         out.println("<tr>");
+//         out.println("<td>" + endpoint.toString() + "</td>");
+//         // FIXME display URI of client
+//         out.println("<td>" + endpoint.getUsername() + "</td>");
+//         out.println("<td>" + endpoint.getSessions().size() + "</td>");
+//         out.println("</tr>");
+//      }
+//
+//      out.println("</table>");
+//
+//
+//      return charArray.toString();
+//   }
+//   
+////   public String showPreparedTransactionsAsHTML()
+////   {
+////      List txs = messagingServer.getTxRepository().getPreparedTransactions();
+////      JBossStringBuilder buffer = new JBossStringBuilder();
+////      buffer.append("<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">");
+////      buffer.append("<tr><th>Xid</th></tr>");
+////      for (Iterator i = txs.iterator(); i.hasNext();)
+////      {
+////         Xid xid = (Xid) i.next();
+////         if (xid != null)
+////         {
+////            buffer.append("<tr><td>");
+////            buffer.append(xid);
+////            buffer.append("</td></tr>");
+////         }
+////      }
+////      buffer.append("</table>");
+////      return buffer.toString();
+////   }
+//
+////   public String listMessageCountersAsHTML() throws Exception
+////   {
+////      List counters = messagingServer.getMessageCounters();
+////
+////      Collections.sort(counters, new Comparator()
+////      {
+////         public int compare(Object o1, Object o2)
+////         {
+////            MessageCounter m1 = (MessageCounter) o1;
+////            MessageCounter m2 = (MessageCounter) o2;
+////            return m1.getDestinationName().compareTo(m2.getDestinationName());
+////         }
+////      });
+////
+////      String ret =
+////              "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">"
+////                      + "<tr>"
+////                      + "<th>Type</th>"
+////                      + "<th>Name</th>"
+////                      + "<th>Subscription</th>"
+////                      + "<th>Durable</th>"
+////                      + "<th>Count</th>"
+////                      + "<th>CountDelta</th>"
+////                      + "<th>Depth</th>"
+////                      + "<th>DepthDelta</th>"
+////                      + "<th>Last Add</th>"
+////                      + "</tr>";
+////
+////      String strNameLast = null;
+////      String strTypeLast = null;
+////      String strDestLast = null;
+////
+////      String destData = "";
+////      int destCount = 0;
+////
+////      int countTotal = 0;
+////      int countDeltaTotal = 0;
+////      int depthTotal = 0;
+////      int depthDeltaTotal = 0;
+////
+////      int i = 0; // define outside of for statement, so variable
+////      // still exists after for loop, because it is
+////      // needed during output of last module data string
+////
+////      Iterator iter = counters.iterator();
+////
+////      while (iter.hasNext())
+////      {
+////         MessageCounter counter = (MessageCounter) iter.next();
+////
+////         // get counter data
+////         StringTokenizer tokens = new StringTokenizer(counter.getCounterAsString(), ",");
+////
+////         String strType = tokens.nextToken();
+////         String strName = tokens.nextToken();
+////         String strSub = tokens.nextToken();
+////         String strDurable = tokens.nextToken();
+////
+////         String strDest = strType + "-" + strName;
+////
+////         String strCount = tokens.nextToken();
+////         String strCountDelta = tokens.nextToken();
+////         String strDepth = tokens.nextToken();
+////         String strDepthDelta = tokens.nextToken();
+////         String strDate = tokens.nextToken();
+////
+////         // update total count / depth values
+////         countTotal += Integer.parseInt(strCount);
+////         depthTotal += Integer.parseInt(strDepth);
+////
+////         countDeltaTotal += Integer.parseInt(strCountDelta);
+////         depthDeltaTotal += Integer.parseInt(strDepthDelta);
+////
+////         if (strCountDelta.equalsIgnoreCase("0"))
+////            strCountDelta = "-"; // looks better
+////
+////         if (strDepthDelta.equalsIgnoreCase("0"))
+////            strDepthDelta = "-"; // looks better
+////
+////         // output destination counter data as HTML table row
+////         // ( for topics with multiple subscriptions output
+////         //   type + name field as rowspans, looks better )
+////         if (strDestLast != null && strDestLast.equals(strDest))
+////         {
+////            // still same destination -> append destination subscription data
+////            destData += "<tr bgcolor=\"#" + ((i % 2) == 0 ? "FFFFFF" : "F0F0F0") + "\">";
+////            destCount += 1;
+////         }
+////         else
+////         {
+////            // startnew destination data
+////            if (strDestLast != null)
+////            {
+////               // store last destination data string
+////               ret += "<tr bgcolor=\"#"
+////                       + ((i % 2) == 0 ? "FFFFFF" : "F0F0F0")
+////                       + "\"><td rowspan=\""
+////                       + destCount
+////                       + "\">"
+////                       + strTypeLast
+////                       + "</td><td rowspan=\""
+////                       + destCount
+////                       + "\">"
+////                       + strNameLast
+////                       + "</td>"
+////                       + destData;
+////
+////               destData = "";
+////            }
+////
+////            destCount = 1;
+////         }
+////
+////         // counter data row
+////         destData += "<td>"
+////                 + strSub
+////                 + "</td>"
+////                 + "<td>"
+////                 + strDurable
+////                 + "</td>"
+////                 + "<td>"
+////                 + strCount
+////                 + "</td>"
+////                 + "<td>"
+////                 + strCountDelta
+////                 + "</td>"
+////                 + "<td>"
+////                 + strDepth
+////                 + "</td>"
+////                 + "<td>"
+////                 + strDepthDelta
+////                 + "</td>"
+////                 + "<td>"
+////                 + strDate
+////                 + "</td>";
+////
+////         // store current destination data for change detection
+////         strTypeLast = strType;
+////         strNameLast = strName;
+////         strDestLast = strDest;
+////      }
+////
+////      if (strDestLast != null)
+////      {
+////         // store last module data string
+////         ret += "<tr bgcolor=\"#"
+////                 + ((i % 2) == 0 ? "FFFFFF" : "F0F0F0")
+////                 + "\"><td rowspan=\""
+////                 + destCount
+////                 + "\">"
+////                 + strTypeLast
+////                 + "</td><td rowspan=\""
+////                 + destCount
+////                 + "\">"
+////                 + strNameLast
+////                 + "</td>"
+////                 + destData;
+////      }
+////
+////      // append summation info
+////      ret += "<tr>"
+////              + "<td><![CDATA[ ]]></td><td><![CDATA[ ]]></td>"
+////              + "<td><![CDATA[ ]]></td><td><![CDATA[ ]]></td><td>"
+////              + countTotal
+////              + "</td><td>"
+////              + (countDeltaTotal == 0 ? "-" : Integer.toString(countDeltaTotal))
+////              + "</td><td>"
+////              + depthTotal
+////              + "</td><td>"
+////              + (depthDeltaTotal == 0 ? "-" : Integer.toString(depthDeltaTotal))
+////              + "</td><td>Total</td></tr></table>";
+////
+////      return ret;
+////   }
+//
+//
+//
+//   public List<Message> listAllMessages(Queue queue, String selector) throws Exception
+//   {
+//      return listMessages(queue, ListType.ALL, selector);
+//   }
+//   
+//   public List<Message> listDurableMessages(Queue queue, String selector) throws Exception
+//   {
+//      return listMessages(queue, ListType.DURABLE, selector);
+//   }
+//   
+//   public List<Message> listNonDurableMessages(Queue queue, String selector) throws Exception
+//   {
+//      return listMessages(queue, ListType.NON_DURABLE, selector);
+//   }
+//         
+   public List<SubscriptionInfo> listAllSubscriptions(String topicName) throws Exception
    {
-      return getMessageCounters(topicName);
+      return listSubscriptions(topicName, ListType.ALL);
    }
-
-   public String showActiveClientsAsHTML() throws Exception
+//   
+//   public List<SubscriptionInfo> listDurableSubscriptions(String topicName) throws Exception
+//   {
+//      return listSubscriptions(topicName, ListType.DURABLE);
+//   }
+//   
+//   public List<SubscriptionInfo> listNonDurableSubscriptions(String topicName) throws Exception
+//   {
+//      return listSubscriptions(topicName, ListType.NON_DURABLE);
+//   }
+//   
+//   public String listAllSubscriptionsAsHTML(String topicName) throws Exception
+//   {
+//      return listSubscriptionsAsHTML(topicName, ListType.ALL);
+//   }
+//   
+//   public String listDurableSubscriptionsAsHTML(String topicName) throws Exception
+//   {
+//      return listSubscriptionsAsHTML(topicName, ListType.DURABLE);
+//   }
+//   
+//   public String listNonDurableSubscriptionsAsHTML(String topicName) throws Exception
+//   {
+//      return listSubscriptionsAsHTML(topicName, ListType.NON_DURABLE);
+//   }
+//      
+//   public List<Message> listDurableMessagesForSubscription(String subId, String selector) throws Exception
+//   {
+//      return listMessagesForSubscription(ListType.DURABLE, subId, selector);
+//   }
+//   
+//   public List<Message> listNonDurableMessagesForSubscription(String subId, String selector) throws Exception
+//   {
+//      return listMessagesForSubscription(ListType.NON_DURABLE, subId, selector);
+//   }
+//   
+//   public List<MessageCounter> getMessageCounters(String topicName) throws Exception
+//   {
+//      List<MessageCounter> counters = new ArrayList<MessageCounter>();
+//      
+//      Condition condition = new ConditionImpl(DestinationType.TOPIC, topicName);
+//      
+//      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForCondition(condition);
+//      
+//      for (Binding binding: bindings)
+//      {
+//         Queue queue = binding.getQueue();
+//         
+//         //TODO - get message counters
+//         
+////         String counterName = SUBSCRIPTION_MESSAGECOUNTER_PREFIX + queue.getName();
+////         
+////         MessageCounter counter = messagingServer.getMessageCounterManager().getMessageCounter(counterName);
+////         
+////         if (counter == null)
+////         {
+////            throw new IllegalStateException("Cannot find counter with name " + counterName);
+////         }
+////         
+////         counters.add(counter);
+//      }
+//      
+//      return counters; 
+//   }
+//   
+//   
+////   public void setMessageCounterHistoryDayLimit(String topicName, int limit) throws Exception
+////   {
+////      Condition condition = new ConditionImpl(DestinationType.TOPIC, topicName);
+////      
+////      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForCondition(condition);
+////         
+////      for (Binding binding: bindings)
+////      {
+////         Queue queue = binding.getQueue();
+////         
+////         queue.setMessageCounterHistoryDayLimit(limit);
+////      }      
+////   }
+//   
+//   // Private ---------------------------------------------------------------------------
+//   
+   private Queue getQueue(String queueName) throws Exception
    {
-      CharArrayWriter charArray = new CharArrayWriter();
-      PrintWriter out = new PrintWriter(charArray);
-
-      List endpoints = messagingServer.getConnectionManager().getActiveConnections();
-
-      out.println("<table><tr><td>ID</td><td>Host</td><td>User</td><td>#Sessions</td></tr>");
-      for (Iterator iter = endpoints.iterator(); iter.hasNext();)
+      JBossQueue jbq = new JBossQueue(queueName);
+      
+      Binding binding = messagingServer.getPostOffice().getBinding(jbq.getAddress());
+      
+      if (binding == null)
       {
-         ServerConnectionEndpoint endpoint = (ServerConnectionEndpoint) iter.next();
-
-         out.println("<tr>");
-         out.println("<td>" + endpoint.toString() + "</td>");
-         // FIXME display URI of client
-         out.println("<td>" + endpoint.getUsername() + "</td>");
-         out.println("<td>" + endpoint.getSessions().size() + "</td>");
-         out.println("</tr>");
+         throw new IllegalArgumentException("No queue with name " + queueName);
       }
-
-      out.println("</table>");
-
-
-      return charArray.toString();
+      
+      return binding.getQueue();
    }
-   
-//   public String showPreparedTransactionsAsHTML()
-//   {
-//      List txs = messagingServer.getTxRepository().getPreparedTransactions();
-//      JBossStringBuilder buffer = new JBossStringBuilder();
-//      buffer.append("<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">");
-//      buffer.append("<tr><th>Xid</th></tr>");
-//      for (Iterator i = txs.iterator(); i.hasNext();)
+//   
+//    
+//   
+//   private List<Message> listMessages(Queue queue, ListType type, String jmsSelector) throws Exception
+//   {                        
+//      if (jmsSelector != null && "".equals(jmsSelector.trim()))
 //      {
-//         Xid xid = (Xid) i.next();
-//         if (xid != null)
+//         jmsSelector = null;
+//      }
+//      
+//      Filter filter = null;
+//            
+//      if (jmsSelector != null)
+//      {        
+//         filter = new FilterImpl(SelectorTranslator.convertToJBMFilterString(jmsSelector));
+//      }
+//      
+//      List<Message> msgs = new ArrayList<Message>();
+//      
+//      List<MessageReference> allRefs = queue.list(filter);
+//        
+//      for (MessageReference ref: allRefs)
+//      {
+//         Message msg = ref.getMessage();
+//         
+//         if (type == ListType.ALL ||
+//            (type == ListType.DURABLE && msg.isDurable()) ||
+//            (type == ListType.NON_DURABLE && !msg.isDurable()))
 //         {
-//            buffer.append("<tr><td>");
-//            buffer.append(xid);
-//            buffer.append("</td></tr>");
+//            msgs.add(msg);
 //         }
 //      }
-//      buffer.append("</table>");
-//      return buffer.toString();
+//      
+//      return msgs;
 //   }
-
-//   public String listMessageCountersAsHTML() throws Exception
+//   
+//   
+//   private String listMessageCounterAsHTML(MessageCounter[] counters)
 //   {
-//      List counters = messagingServer.getMessageCounters();
+//      if (counters == null)
+//         return null;
 //
-//      Collections.sort(counters, new Comparator()
+//      String ret = "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">"  +
+//                   "<tr>"                  +
+//                   "<th>Type</th>"         +
+//                   "<th>Name</th>"         +
+//                   "<th>Subscription</th>" +
+//                   "<th>Durable</th>"      +
+//                   "<th>Count</th>"        +
+//                   "<th>CountDelta</th>"   +
+//                   "<th>Depth</th>"        +
+//                   "<th>DepthDelta</th>"   +
+//                   "<th>Last Add</th>"     +
+//                   "</tr>";
+//
+//      for( int i=0; i<counters.length; i++ )
 //      {
-//         public int compare(Object o1, Object o2)
-//         {
-//            MessageCounter m1 = (MessageCounter) o1;
-//            MessageCounter m2 = (MessageCounter) o2;
-//            return m1.getDestinationName().compareTo(m2.getDestinationName());
-//         }
-//      });
+//         String            data = counters[i].getCounterAsString();
+//         StringTokenizer token = new StringTokenizer( data, ",");
+//         String            value;
 //
-//      String ret =
-//              "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">"
-//                      + "<tr>"
-//                      + "<th>Type</th>"
-//                      + "<th>Name</th>"
-//                      + "<th>Subscription</th>"
-//                      + "<th>Durable</th>"
-//                      + "<th>Count</th>"
-//                      + "<th>CountDelta</th>"
-//                      + "<th>Depth</th>"
-//                      + "<th>DepthDelta</th>"
-//                      + "<th>Last Add</th>"
-//                      + "</tr>";
+//         ret += "<tr bgcolor=\"#" + ( (i%2)==0 ? "FFFFFF" : "F0F0F0") + "\">";
 //
-//      String strNameLast = null;
-//      String strTypeLast = null;
-//      String strDestLast = null;
+//         ret += "<td>" + token.nextToken() + "</td>"; // type
+//         ret += "<td>" + token.nextToken() + "</td>"; // name
+//         ret += "<td>" + token.nextToken() + "</td>"; // subscription
+//         ret += "<td>" + token.nextToken() + "</td>"; // durable
 //
-//      String destData = "";
-//      int destCount = 0;
+//         ret += "<td>" + token.nextToken() + "</td>"; // count
 //
-//      int countTotal = 0;
-//      int countDeltaTotal = 0;
-//      int depthTotal = 0;
-//      int depthDeltaTotal = 0;
+//         value = token.nextToken(); // countDelta
 //
-//      int i = 0; // define outside of for statement, so variable
-//      // still exists after for loop, because it is
-//      // needed during output of last module data string
+//         if( value.equalsIgnoreCase("0") )
+//             value = "-";
 //
-//      Iterator iter = counters.iterator();
+//         ret += "<td>" + value + "</td>";
 //
-//      while (iter.hasNext())
-//      {
-//         MessageCounter counter = (MessageCounter) iter.next();
+//         ret += "<td>" + token.nextToken() + "</td>"; // depth
 //
-//         // get counter data
-//         StringTokenizer tokens = new StringTokenizer(counter.getCounterAsString(), ",");
+//         value = token.nextToken(); // depthDelta
 //
-//         String strType = tokens.nextToken();
-//         String strName = tokens.nextToken();
-//         String strSub = tokens.nextToken();
-//         String strDurable = tokens.nextToken();
+//         if( value.equalsIgnoreCase("0") )
+//             value = "-";
 //
-//         String strDest = strType + "-" + strName;
+//         ret += "<td>" + value + "</td>";
 //
-//         String strCount = tokens.nextToken();
-//         String strCountDelta = tokens.nextToken();
-//         String strDepth = tokens.nextToken();
-//         String strDepthDelta = tokens.nextToken();
-//         String strDate = tokens.nextToken();
+//         ret += "<td>" + token.nextToken() + "</td>"; // date last add
 //
-//         // update total count / depth values
-//         countTotal += Integer.parseInt(strCount);
-//         depthTotal += Integer.parseInt(strDepth);
+//         ret += "</tr>";
+//      }
 //
-//         countDeltaTotal += Integer.parseInt(strCountDelta);
-//         depthDeltaTotal += Integer.parseInt(strDepthDelta);
+//      ret += "</table>";
 //
-//         if (strCountDelta.equalsIgnoreCase("0"))
-//            strCountDelta = "-"; // looks better
+//      return ret;
+//   }
 //
-//         if (strDepthDelta.equalsIgnoreCase("0"))
-//            strDepthDelta = "-"; // looks better
+//   private String listMessageCounterHistoryAsHTML(MessageCounter[] counters)
+//   {
+//      if (counters == null)
+//         return null;
 //
-//         // output destination counter data as HTML table row
-//         // ( for topics with multiple subscriptions output
-//         //   type + name field as rowspans, looks better )
-//         if (strDestLast != null && strDestLast.equals(strDest))
+//      String           ret = "";
+//
+//      for( int i=0; i<counters.length; i++ )
+//      {
+//         // destination name
+//         ret += ( counters[i].getDestinationTopic() ? "Topic '" : "Queue '" );
+//         ret += counters[i].getDestinationName() + "'";
+//
+//         if( counters[i].getDestinationSubscription() != null )
+//            ret += "Subscription '" + counters[i].getDestinationSubscription() + "'";
+//
+//
+//         // table header
+//         ret += "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">"  +
+//                "<tr>"                  +
+//                "<th>Date</th>";
+//
+//         for( int j = 0; j < 24; j++ )
+//            ret += "<th width=\"4%\">" + j + "</th>";
+//
+//         ret += "<th>Total</th></tr>";
+//
+//         // get history data as CSV string
+//         StringTokenizer tokens = new StringTokenizer( counters[i].getHistoryAsString(), ",\n");
+//
+//         // get history day count
+//         int days = Integer.parseInt( tokens.nextToken() );
+//
+//         for( int j=0; j<days; j++ )
 //         {
-//            // still same destination -> append destination subscription data
-//            destData += "<tr bgcolor=\"#" + ((i % 2) == 0 ? "FFFFFF" : "F0F0F0") + "\">";
-//            destCount += 1;
-//         }
-//         else
-//         {
-//            // startnew destination data
-//            if (strDestLast != null)
+//            // next day counter row
+//            ret += "<tr bgcolor=\"#" + ((j%2)==0 ? "FFFFFF" : "F0F0F0") + "\">";
+//
+//            // date
+//            ret += "<td>" + tokens.nextToken() + "</td>";
+//
+//            // 24 hour counters
+//            int total = 0;
+//
+//            for( int k=0; k<24; k++ )
 //            {
-//               // store last destination data string
-//               ret += "<tr bgcolor=\"#"
-//                       + ((i % 2) == 0 ? "FFFFFF" : "F0F0F0")
-//                       + "\"><td rowspan=\""
-//                       + destCount
-//                       + "\">"
-//                       + strTypeLast
-//                       + "</td><td rowspan=\""
-//                       + destCount
-//                       + "\">"
-//                       + strNameLast
-//                       + "</td>"
-//                       + destData;
+//               int value = Integer.parseInt( tokens.nextToken().trim() );
 //
-//               destData = "";
+//               if( value == -1 )
+//               {
+//                    ret += "<td></td>";
+//               }
+//               else
+//               {
+//                    ret += "<td>" + value + "</td>";
+//
+//                    total += value;
+//               }
 //            }
 //
-//            destCount = 1;
+//            ret += "<td>" + total + "</td></tr>";
 //         }
 //
-//         // counter data row
-//         destData += "<td>"
-//                 + strSub
-//                 + "</td>"
-//                 + "<td>"
-//                 + strDurable
-//                 + "</td>"
-//                 + "<td>"
-//                 + strCount
-//                 + "</td>"
-//                 + "<td>"
-//                 + strCountDelta
-//                 + "</td>"
-//                 + "<td>"
-//                 + strDepth
-//                 + "</td>"
-//                 + "<td>"
-//                 + strDepthDelta
-//                 + "</td>"
-//                 + "<td>"
-//                 + strDate
-//                 + "</td>";
-//
-//         // store current destination data for change detection
-//         strTypeLast = strType;
-//         strNameLast = strName;
-//         strDestLast = strDest;
+//         ret += "</table><br><br>";
 //      }
 //
-//      if (strDestLast != null)
-//      {
-//         // store last module data string
-//         ret += "<tr bgcolor=\"#"
-//                 + ((i % 2) == 0 ? "FFFFFF" : "F0F0F0")
-//                 + "\"><td rowspan=\""
-//                 + destCount
-//                 + "\">"
-//                 + strTypeLast
-//                 + "</td><td rowspan=\""
-//                 + destCount
-//                 + "\">"
-//                 + strNameLast
-//                 + "</td>"
-//                 + destData;
-//      }
-//
-//      // append summation info
-//      ret += "<tr>"
-//              + "<td><![CDATA[ ]]></td><td><![CDATA[ ]]></td>"
-//              + "<td><![CDATA[ ]]></td><td><![CDATA[ ]]></td><td>"
-//              + countTotal
-//              + "</td><td>"
-//              + (countDeltaTotal == 0 ? "-" : Integer.toString(countDeltaTotal))
-//              + "</td><td>"
-//              + depthTotal
-//              + "</td><td>"
-//              + (depthDeltaTotal == 0 ? "-" : Integer.toString(depthDeltaTotal))
-//              + "</td><td>Total</td></tr></table>";
-//
 //      return ret;
 //   }
-
-
-
-   public List<Message> listAllMessages(Queue queue, String selector) throws Exception
+//   
+   private enum ListType
    {
-      return listMessages(queue, ListType.ALL, selector);
+      ALL, DURABLE, NON_DURABLE;
    }
-   
-   public List<Message> listDurableMessages(Queue queue, String selector) throws Exception
-   {
-      return listMessages(queue, ListType.DURABLE, selector);
-   }
-   
-   public List<Message> listNonDurableMessages(Queue queue, String selector) throws Exception
-   {
-      return listMessages(queue, ListType.NON_DURABLE, selector);
-   }
-         
-   public List<SubscriptionInfo> listAllSubscriptions(String topicName) throws Exception
-   {
-      return listSubscriptions(topicName, ListType.ALL);
-   }
-   
-   public List<SubscriptionInfo> listDurableSubscriptions(String topicName) throws Exception
-   {
-      return listSubscriptions(topicName, ListType.DURABLE);
-   }
-   
-   public List<SubscriptionInfo> listNonDurableSubscriptions(String topicName) throws Exception
-   {
-      return listSubscriptions(topicName, ListType.NON_DURABLE);
-   }
-   
-   public String listAllSubscriptionsAsHTML(String topicName) throws Exception
-   {
-      return listSubscriptionsAsHTML(topicName, ListType.ALL);
-   }
-   
-   public String listDurableSubscriptionsAsHTML(String topicName) throws Exception
-   {
-      return listSubscriptionsAsHTML(topicName, ListType.DURABLE);
-   }
-   
-   public String listNonDurableSubscriptionsAsHTML(String topicName) throws Exception
-   {
-      return listSubscriptionsAsHTML(topicName, ListType.NON_DURABLE);
-   }
-      
-   public List<Message> listDurableMessagesForSubscription(String subId, String selector) throws Exception
-   {
-      return listMessagesForSubscription(ListType.DURABLE, subId, selector);
-   }
-   
-   public List<Message> listNonDurableMessagesForSubscription(String subId, String selector) throws Exception
-   {
-      return listMessagesForSubscription(ListType.NON_DURABLE, subId, selector);
-   }
-   
-   public List<MessageCounter> getMessageCounters(String topicName) throws Exception
-   {
-      List<MessageCounter> counters = new ArrayList<MessageCounter>();
-      
-      Condition condition = new ConditionImpl(DestinationType.TOPIC, topicName);
-      
-      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForCondition(condition);
-      
-      for (Binding binding: bindings)
-      {
-         Queue queue = binding.getQueue();
-         
-         //TODO - get message counters
-         
-//         String counterName = SUBSCRIPTION_MESSAGECOUNTER_PREFIX + queue.getName();
+//   
+//  
+//   private List<Message> listMessagesForSubscription(ListType type, String subId, String jmsSelector) throws Exception
+//   { 
+//      List<Message> msgs = new ArrayList<Message>();
+//      
+//      if (subId == null || "".equals(subId.trim()))
+//      {
+//         return msgs;
+//      }
+//      
+//      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForQueueName(subId);
+//      
+//      if (bindings.isEmpty())
+//      {
+//         throw new IllegalArgumentException("Cannot find subscription with id " + subId);
+//      }
+//      
+//      
+//      if (jmsSelector != null && "".equals(jmsSelector.trim()))
+//      {
+//         jmsSelector = null;
+//      }
+//      
+//      Filter sel = null;
+//               
+//      if (jmsSelector != null)
+//      {  
+//         sel = new FilterImpl(SelectorTranslator.convertToJBMFilterString(jmsSelector));
+//      }
+//      
+//      Binding binding = bindings.get(0);
+//      
+//      List<MessageReference> allRefs = binding.getQueue().list(sel);
 //         
-//         MessageCounter counter = messagingServer.getMessageCounterManager().getMessageCounter(counterName);
-//         
-//         if (counter == null)
+//      for (MessageReference ref: allRefs)
+//      {
+//         Message msg = ref.getMessage();
+//     
+//         if (type == ListType.ALL || (type == ListType.DURABLE && msg.isDurable()) || (type == ListType.NON_DURABLE && !msg.isDurable()))
 //         {
-//            throw new IllegalStateException("Cannot find counter with name " + counterName);
+//            msgs.add(msg);
 //         }
-//         
-//         counters.add(counter);
-      }
-      
-      return counters; 
-   }
-   
-   
-//   public void setMessageCounterHistoryDayLimit(String topicName, int limit) throws Exception
-//   {
-//      Condition condition = new ConditionImpl(DestinationType.TOPIC, topicName);
+//      }
 //      
-//      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForCondition(condition);
-//         
-//      for (Binding binding: bindings)
-//      {
-//         Queue queue = binding.getQueue();
-//         
-//         queue.setMessageCounterHistoryDayLimit(limit);
-//      }      
+//      return msgs;
 //   }
-   
-   // Private ---------------------------------------------------------------------------
-   
-   private Queue getQueue(String queueName) throws Exception
-   {
-      Condition condition = new ConditionImpl(DestinationType.QUEUE, queueName);
-      
-      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForCondition(condition);
-      
-      if (bindings.isEmpty())
-      {
-         throw new IllegalArgumentException("No queue with name " + queueName);
-      }
-      
-      return bindings.get(0).getQueue();
-   }
-   
-    
-   
-   private List<Message> listMessages(Queue queue, ListType type, String jmsSelector) throws Exception
-   {                        
-      if (jmsSelector != null && "".equals(jmsSelector.trim()))
-      {
-         jmsSelector = null;
-      }
-      
-      Filter filter = null;
-            
-      if (jmsSelector != null)
-      {        
-         filter = new FilterImpl(SelectorTranslator.convertToJBMFilterString(jmsSelector));
-      }
-      
-      List<Message> msgs = new ArrayList<Message>();
-      
-      List<MessageReference> allRefs = queue.list(filter);
-        
-      for (MessageReference ref: allRefs)
-      {
-         Message msg = ref.getMessage();
-         
-         if (type == ListType.ALL ||
-            (type == ListType.DURABLE && msg.isDurable()) ||
-            (type == ListType.NON_DURABLE && !msg.isDurable()))
-         {
-            msgs.add(msg);
-         }
-      }
-      
-      return msgs;
-   }
-   
-   
-   private String listMessageCounterAsHTML(MessageCounter[] counters)
-   {
-      if (counters == null)
-         return null;
-
-      String ret = "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">"  +
-                   "<tr>"                  +
-                   "<th>Type</th>"         +
-                   "<th>Name</th>"         +
-                   "<th>Subscription</th>" +
-                   "<th>Durable</th>"      +
-                   "<th>Count</th>"        +
-                   "<th>CountDelta</th>"   +
-                   "<th>Depth</th>"        +
-                   "<th>DepthDelta</th>"   +
-                   "<th>Last Add</th>"     +
-                   "</tr>";
-
-      for( int i=0; i<counters.length; i++ )
-      {
-         String            data = counters[i].getCounterAsString();
-         StringTokenizer token = new StringTokenizer( data, ",");
-         String            value;
-
-         ret += "<tr bgcolor=\"#" + ( (i%2)==0 ? "FFFFFF" : "F0F0F0") + "\">";
-
-         ret += "<td>" + token.nextToken() + "</td>"; // type
-         ret += "<td>" + token.nextToken() + "</td>"; // name
-         ret += "<td>" + token.nextToken() + "</td>"; // subscription
-         ret += "<td>" + token.nextToken() + "</td>"; // durable
-
-         ret += "<td>" + token.nextToken() + "</td>"; // count
-
-         value = token.nextToken(); // countDelta
-
-         if( value.equalsIgnoreCase("0") )
-             value = "-";
-
-         ret += "<td>" + value + "</td>";
-
-         ret += "<td>" + token.nextToken() + "</td>"; // depth
-
-         value = token.nextToken(); // depthDelta
-
-         if( value.equalsIgnoreCase("0") )
-             value = "-";
-
-         ret += "<td>" + value + "</td>";
-
-         ret += "<td>" + token.nextToken() + "</td>"; // date last add
-
-         ret += "</tr>";
-      }
-
-      ret += "</table>";
-
-      return ret;
-   }
-
-   private String listMessageCounterHistoryAsHTML(MessageCounter[] counters)
-   {
-      if (counters == null)
-         return null;
-
-      String           ret = "";
-
-      for( int i=0; i<counters.length; i++ )
-      {
-         // destination name
-         ret += ( counters[i].getDestinationTopic() ? "Topic '" : "Queue '" );
-         ret += counters[i].getDestinationName() + "'";
-
-         if( counters[i].getDestinationSubscription() != null )
-            ret += "Subscription '" + counters[i].getDestinationSubscription() + "'";
-
-
-         // table header
-         ret += "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">"  +
-                "<tr>"                  +
-                "<th>Date</th>";
-
-         for( int j = 0; j < 24; j++ )
-            ret += "<th width=\"4%\">" + j + "</th>";
-
-         ret += "<th>Total</th></tr>";
-
-         // get history data as CSV string
-         StringTokenizer tokens = new StringTokenizer( counters[i].getHistoryAsString(), ",\n");
-
-         // get history day count
-         int days = Integer.parseInt( tokens.nextToken() );
-
-         for( int j=0; j<days; j++ )
-         {
-            // next day counter row
-            ret += "<tr bgcolor=\"#" + ((j%2)==0 ? "FFFFFF" : "F0F0F0") + "\">";
-
-            // date
-            ret += "<td>" + tokens.nextToken() + "</td>";
-
-            // 24 hour counters
-            int total = 0;
-
-            for( int k=0; k<24; k++ )
-            {
-               int value = Integer.parseInt( tokens.nextToken().trim() );
-
-               if( value == -1 )
-               {
-                    ret += "<td></td>";
-               }
-               else
-               {
-                    ret += "<td>" + value + "</td>";
-
-                    total += value;
-               }
-            }
-
-            ret += "<td>" + total + "</td></tr>";
-         }
-
-         ret += "</table><br><br>";
-      }
-
-      return ret;
-   }
-   
-   private enum ListType
-   {
-      ALL, DURABLE, NON_DURABLE;
-   }
-   
-  
-   private List<Message> listMessagesForSubscription(ListType type, String subId, String jmsSelector) throws Exception
-   { 
-      List<Message> msgs = new ArrayList<Message>();
-      
-      if (subId == null || "".equals(subId.trim()))
-      {
-         return msgs;
-      }
-      
-      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForQueueName(subId);
-      
-      if (bindings.isEmpty())
-      {
-         throw new IllegalArgumentException("Cannot find subscription with id " + subId);
-      }
-      
-      
-      if (jmsSelector != null && "".equals(jmsSelector.trim()))
-      {
-         jmsSelector = null;
-      }
-      
-      Filter sel = null;
-               
-      if (jmsSelector != null)
-      {  
-         sel = new FilterImpl(SelectorTranslator.convertToJBMFilterString(jmsSelector));
-      }
-      
-      Binding binding = bindings.get(0);
-      
-      List<MessageReference> allRefs = binding.getQueue().list(sel);
-         
-      for (MessageReference ref: allRefs)
-      {
-         Message msg = ref.getMessage();
-     
-         if (type == ListType.ALL || (type == ListType.DURABLE && msg.isDurable()) || (type == ListType.NON_DURABLE && !msg.isDurable()))
-         {
-            msgs.add(msg);
-         }
-      }
-      
-      return msgs;
-   }
-   
+//   
    private List<SubscriptionInfo> listSubscriptions(String topicName, ListType type) throws Exception
    {      
       List<SubscriptionInfo> subs = new ArrayList<SubscriptionInfo>();
    
-      Condition condition = new ConditionImpl(DestinationType.TOPIC, topicName);
+      JBossTopic topic = new JBossTopic(topicName);
       
-      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForCondition(condition);
+      String address = topic.getAddress();
       
+      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForAddress(address);
+      
       for (Binding binding: bindings)
       {
          Queue queue = binding.getQueue();
@@ -873,103 +871,103 @@
       
       return subs;
    }
+//   
+//   private int getMessageCount(String topicName, ListType type) throws Exception
+//   {
+//      Condition condition = new ConditionImpl(DestinationType.TOPIC, topicName);
+//      
+//      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForCondition(condition);
+//      
+//      int count = 0;
+//      
+//      for (Binding binding: bindings)
+//      {
+//         Queue queue = binding.getQueue();
+//         
+//         if (type == ListType.ALL || (type == ListType.DURABLE && queue.isDurable())
+//             || (type == ListType.NON_DURABLE && !queue.isDurable()))
+//         {            
+//            count += queue.getMessageCount();
+//         }
+//      }
+//
+//      return count;
+//   }  
+//   
+//   private int getSubscriptionsCount(String topicName, boolean durable) throws Exception
+//   {
+//      Condition condition = new ConditionImpl(DestinationType.TOPIC, topicName);
+//      
+//      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForCondition(condition);
+//      
+//      int count = 0;
+//      
+//      for (Binding binding: bindings)
+//      {
+//         Queue queue = binding.getQueue();
+//                  
+//         if ((queue.isDurable() && durable) || (!queue.isDurable() && !durable))
+//         {
+//            count++;
+//         }
+//      }
+//
+//      return count;
+//   }
+//   
+//   
+//   private String listSubscriptionsAsHTML(String topicName, ListType type) throws Exception
+//   {
+//      Condition condition = new ConditionImpl(DestinationType.TOPIC, topicName);
+//      
+//      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForCondition(condition);
+//      
+//      StringBuffer sb = new StringBuffer();
+//      
+//      sb.append("<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">"  +
+//                  "<tr>"                  +
+//                  "<th>Id</th>"         +
+//                  "<th>Durable</th>" +
+//                  "<th>Subscription Name</th>"      +
+//                  "<th>Client ID</th>"        +
+//                  "<th>Selector</th>"   +
+//                  "<th>Message Count</th>"        +
+//                  "<th>Max Size</th>"   +
+//                  "</tr>");
+//      
+//      for (Binding binding: bindings)
+//      {
+//         Queue queue = binding.getQueue();
+//
+//         if (type == ListType.ALL || (type == ListType.DURABLE && queue.isDurable())
+//                  || (type == ListType.NON_DURABLE && !queue.isDurable()))
+//         {            
+//            String filterString = queue.getFilter() != null ? queue.getFilter().getFilterString() : null;
+//                     
+//            String subName = null;
+//            String clientID = null;
+//            
+//            if (queue.isDurable())
+//            {
+//               MessageQueueNameHelper helper = MessageQueueNameHelper.createHelper(queue.getName());
+//               subName = helper.getSubName();
+//               clientID = helper.getClientId();
+//            }
+//            
+//            sb.append("<tr><td>").append(queue.getName()).append("</td>");
+//            sb.append("<td>").append(queue.isDurable() ? "Durable" : "Non Durable").append("</td>");
+//            sb.append("<td>").append(subName != null ? subName : "").append("</td>");
+//            sb.append("<td>").append(clientID != null ? clientID : "").append("</td>");
+//            sb.append("<td>").append(filterString != null ? filterString : "").append("</td>");
+//            sb.append("<td>").append(queue.getMessageCount()).append("</td>");
+//            sb.append("<td>").append(queue.getMaxSize()).append("</td>");
+//            sb.append("</tr>");
+//         }
+//      }
+//      sb.append("</table>");
+//      
+//      return sb.toString();                                
+//   }
    
-   private int getMessageCount(String topicName, ListType type) throws Exception
-   {
-      Condition condition = new ConditionImpl(DestinationType.TOPIC, topicName);
-      
-      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForCondition(condition);
-      
-      int count = 0;
-      
-      for (Binding binding: bindings)
-      {
-         Queue queue = binding.getQueue();
-         
-         if (type == ListType.ALL || (type == ListType.DURABLE && queue.isDurable())
-             || (type == ListType.NON_DURABLE && !queue.isDurable()))
-         {            
-            count += queue.getMessageCount();
-         }
-      }
-
-      return count;
-   }  
    
-   private int getSubscriptionsCount(String topicName, boolean durable) throws Exception
-   {
-      Condition condition = new ConditionImpl(DestinationType.TOPIC, topicName);
-      
-      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForCondition(condition);
-      
-      int count = 0;
-      
-      for (Binding binding: bindings)
-      {
-         Queue queue = binding.getQueue();
-                  
-         if ((queue.isDurable() && durable) || (!queue.isDurable() && !durable))
-         {
-            count++;
-         }
-      }
-
-      return count;
-   }
-   
-   
-   private String listSubscriptionsAsHTML(String topicName, ListType type) throws Exception
-   {
-      Condition condition = new ConditionImpl(DestinationType.TOPIC, topicName);
-      
-      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForCondition(condition);
-      
-      StringBuffer sb = new StringBuffer();
-      
-      sb.append("<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">"  +
-                  "<tr>"                  +
-                  "<th>Id</th>"         +
-                  "<th>Durable</th>" +
-                  "<th>Subscription Name</th>"      +
-                  "<th>Client ID</th>"        +
-                  "<th>Selector</th>"   +
-                  "<th>Message Count</th>"        +
-                  "<th>Max Size</th>"   +
-                  "</tr>");
-      
-      for (Binding binding: bindings)
-      {
-         Queue queue = binding.getQueue();
-
-         if (type == ListType.ALL || (type == ListType.DURABLE && queue.isDurable())
-                  || (type == ListType.NON_DURABLE && !queue.isDurable()))
-         {            
-            String filterString = queue.getFilter() != null ? queue.getFilter().getFilterString() : null;
-                     
-            String subName = null;
-            String clientID = null;
-            
-            if (queue.isDurable())
-            {
-               MessageQueueNameHelper helper = MessageQueueNameHelper.createHelper(queue.getName());
-               subName = helper.getSubName();
-               clientID = helper.getClientId();
-            }
-            
-            sb.append("<tr><td>").append(queue.getName()).append("</td>");
-            sb.append("<td>").append(queue.isDurable() ? "Durable" : "Non Durable").append("</td>");
-            sb.append("<td>").append(subName != null ? subName : "").append("</td>");
-            sb.append("<td>").append(clientID != null ? clientID : "").append("</td>");
-            sb.append("<td>").append(filterString != null ? filterString : "").append("</td>");
-            sb.append("<td>").append(queue.getMessageCount()).append("</td>");
-            sb.append("<td>").append(queue.getMaxSize()).append("</td>");
-            sb.append("</tr>");
-         }
-      }
-      sb.append("</table>");
-      
-      return sb.toString();                                
-   }
-   
-   
 }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/Client.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/Client.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/Client.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -9,10 +9,9 @@
 import java.io.IOException;
 import java.util.concurrent.TimeUnit;
 
-import javax.jms.JMSException;
-
-import org.jboss.jms.client.remoting.ConsolidatedRemotingConnectionListener;
+import org.jboss.jms.client.api.FailureListener;
 import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -43,18 +42,17 @@
     *         <code>false</code>) or <code>null</code> (if
     *         <code>oneWay</code> was set to <code>true</code>)
     * 
-    * @throws JMSException
+    * @throws MessagingException
     *            if an exception has occured on the server
     * @throws IOException
     *            if an exception has occured on the network
     */
    AbstractPacket send(AbstractPacket packet, boolean oneWay)
-         throws JMSException, IOException;
+         throws Exception;
 
    void setBlockingRequestTimeout(int timeout, TimeUnit unit);
 
-   void addConnectionListener(
-         final ConsolidatedRemotingConnectionListener listener);
-
-   void removeConnectionListener(ConsolidatedRemotingConnectionListener listener);
+   void setFailureListener(final FailureListener listener);
+   
+   FailureListener getFailureListener();
 }
\ No newline at end of file

Modified: trunk/src/main/org/jboss/messaging/core/remoting/Interceptor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/Interceptor.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/Interceptor.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -7,8 +7,8 @@
 
 package org.jboss.messaging.core.remoting;
 
-import org.jboss.jms.exception.MessagingJMSException;
 import org.jboss.messaging.core.remoting.wireformat.Packet;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  *
@@ -21,14 +21,6 @@
  * @author clebert.suconic at jboss.com
  */
 public interface Interceptor
-{
-   /**
-    * If you need to intercept a return value, you could create your own implementation of PacketSender and recover the return value.
-    *
-    * @param packet
-    * @param handler
-    * @param sender
-    * @return false if the Packet transmission should be interrupted after this call
-    */
-   void intercept(Packet packet) throws MessagingJMSException;
+{   
+   void intercept(Packet packet) throws MessagingException;
 }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/NIOConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/NIOConnector.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/NIOConnector.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -8,7 +8,7 @@
 
 import java.io.IOException;
 
-import org.jboss.jms.client.remoting.ConsolidatedRemotingConnectionListener;
+import org.jboss.jms.client.api.FailureListener;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -22,9 +22,9 @@
 
    boolean disconnect();
 
-   void addConnectionListener(ConsolidatedRemotingConnectionListener listener);
+   void addFailureListener(FailureListener listener);
 
-   void removeConnectionListener(ConsolidatedRemotingConnectionListener listener);
+   void removeFailureListener(FailureListener listener);
 
    String getServerURI();
 }
\ No newline at end of file

Modified: trunk/src/main/org/jboss/messaging/core/remoting/NIOSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/NIOSession.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/NIOSession.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,10 +21,9 @@
 
    String getID();
 
-   void write(Object object);
+   void write(Object object) throws Exception;
 
-   Object writeAndBlock(AbstractPacket packet, long timeout,
-         TimeUnit timeUnit) throws Throwable;
+   Object writeAndBlock(AbstractPacket packet, long timeout, TimeUnit timeUnit) throws Exception;
 
    boolean isConnected();
 }
\ No newline at end of file

Modified: trunk/src/main/org/jboss/messaging/core/remoting/PacketDispatcher.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/PacketDispatcher.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/PacketDispatcher.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -13,11 +13,8 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
 import org.jboss.messaging.core.remoting.wireformat.Packet;
-import org.jboss.messaging.core.remoting.wireformat.SetSessionIDMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionSetIDMessage;
 import org.jboss.messaging.util.Logger;
 
 /**
@@ -90,14 +87,14 @@
       return handlers.get(handlerID);
    }
    
-   public void dispatch(Packet packet, PacketSender sender)
+   public void dispatch(Packet packet, PacketSender sender) throws Exception
    {
       //FIXME better separation between client and server PacketDispatchers
       if (this != client)
       {
-         if (packet instanceof SetSessionIDMessage)
+         if (packet instanceof SessionSetIDMessage)
          {
-            String clientSessionID = ((SetSessionIDMessage)packet).getSessionID();
+            String clientSessionID = ((SessionSetIDMessage)packet).getSessionID();
             if (log.isDebugEnabled())
                log.debug("associated server session " + sender.getSessionID() + " to client " + clientSessionID);
             sessions.put(sender.getSessionID(), clientSessionID);
@@ -116,15 +113,8 @@
          if (log.isTraceEnabled())
             log.trace(handler + " handles " + packet);
 
-         try
-         {
-            callFilters(packet);
-            handler.handle(packet, sender);
-         }
-         catch (MessagingJMSException e)
-         {
-            sender.send(new JMSExceptionMessage(e));
-         }
+         callFilters(packet);
+         handler.handle(packet, sender);
 
       } else
       {
@@ -133,13 +123,13 @@
    }
 
    /** Call filters on a package */
-   public void callFilters(Packet packet) throws MessagingJMSException
+   public void callFilters(Packet packet) throws Exception
    {
      if (filters != null)
      {
         for (Interceptor filter: filters)
         {
-              filter.intercept(packet);
+           filter.intercept(packet);          
         }
      }
    }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/PacketSender.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/PacketSender.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/PacketSender.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -16,7 +16,7 @@
  */
 public interface PacketSender
 {
-   void send(Packet packet);
+   void send(Packet packet) throws Exception;
 
    String getSessionID();
 }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/AbstractPacketCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -19,10 +19,7 @@
 
 import javax.transaction.xa.Xid;
 
-import org.jboss.jms.destination.JBossDestination;
-import org.jboss.messaging.core.Destination;
 import org.jboss.messaging.core.Message;
-import org.jboss.messaging.core.impl.DestinationImpl;
 import org.jboss.messaging.core.impl.MessageImpl;
 import org.jboss.messaging.core.impl.XidImpl;
 import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
@@ -64,30 +61,6 @@
       return baos.toByteArray();
    }
 
-   public static byte[] encode(Destination destination)
-   throws Exception
-   {
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      
-      destination.write(new DataOutputStream(baos));
-      
-      baos.flush();
-      
-      return baos.toByteArray();
-   }
-   
-   public static byte[] encodeJBossDestination(JBossDestination destination)
-   throws Exception
-   {
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      
-      JBossDestination.writeDestination(new DataOutputStream(baos), destination);
-      
-      baos.flush();
-      
-      return baos.toByteArray();
-   }
-
    // Constructors --------------------------------------------------
 
    protected AbstractPacketCodec(PacketType type)
@@ -246,26 +219,6 @@
 
    protected abstract P decodeBody(RemotingBuffer buffer) throws Exception;
 
-   protected static Destination decode(byte[] b) throws Exception
-   {
-      ByteArrayInputStream bais = new ByteArrayInputStream(b);
-      
-      Destination destination = new DestinationImpl();
-      
-      destination.read(new DataInputStream(bais));
-      
-      return destination;
-   }
-   
-   protected static JBossDestination decodeJBossDestination(byte[] b) throws Exception
-   {
-      ByteArrayInputStream bais = new ByteArrayInputStream(b);
-      
-      JBossDestination destination = JBossDestination.readDestination(new DataInputStream(bais));
-      
-      return destination;
-   }
-
    protected static Message decodeMessage(byte[] b) throws Exception
    {     
       ByteArrayInputStream bais = new ByteArrayInputStream(b);

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/AddTemporaryDestinationMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/AddTemporaryDestinationMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/AddTemporaryDestinationMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_ADDTEMPORARYDESTINATION;
-
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.remoting.wireformat.AddTemporaryDestinationMessage;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class AddTemporaryDestinationMessageCodec extends
-      AbstractPacketCodec<AddTemporaryDestinationMessage>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public AddTemporaryDestinationMessageCodec()
-   {
-      super(MSG_ADDTEMPORARYDESTINATION);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(AddTemporaryDestinationMessage message, RemotingBuffer out) throws Exception
-   {
-      byte[] destination = encode(message.getDestination());
-
-      int bodyLength = INT_LENGTH + destination.length;
-
-      out.putInt(bodyLength);
-      out.putInt(destination.length);
-      out.put(destination);
-   }
-
-   @Override
-   protected AddTemporaryDestinationMessage decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      int destinationLength = in.getInt();
-      byte[] b = new byte[destinationLength];
-      in.get(b);
-      Destination destination = decode(b);
-
-      return new AddTemporaryDestinationMessage(destination);
-   }
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserHasNextMessageResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserHasNextMessageResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserHasNextMessageResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_HASNEXTMESSAGE;
-
-import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageResponse;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class BrowserHasNextMessageResponseCodec extends
-      AbstractPacketCodec<BrowserHasNextMessageResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public BrowserHasNextMessageResponseCodec()
-   {
-      super(RESP_BROWSER_HASNEXTMESSAGE);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(BrowserHasNextMessageResponse response,
-         RemotingBuffer out) throws Exception
-   {
-      out.putInt(1); //body length
-      out.putBoolean(response.hasNext());
-   }
-
-   @Override
-   protected BrowserHasNextMessageResponse decodeBody(RemotingBuffer in) throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      boolean hasNext = in.getBoolean();
-
-      return new BrowserHasNextMessageResponse(hasNext);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockRequestCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockRequestCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockRequestCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_NEXTMESSAGEBLOCK;
-
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockRequest;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class BrowserNextMessageBlockRequestCodec extends AbstractPacketCodec<BrowserNextMessageBlockRequest>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public BrowserNextMessageBlockRequestCodec()
-   {
-      super(REQ_BROWSER_NEXTMESSAGEBLOCK);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(BrowserNextMessageBlockRequest request, RemotingBuffer out) throws Exception
-   {
-      out.putInt(LONG_LENGTH);
-      out.putLong(request.getMaxMessages());
-   }
-
-   @Override
-   protected BrowserNextMessageBlockRequest decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      long maxMessages = in.getLong();
-      
-      return new BrowserNextMessageBlockRequest(maxMessages);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private ----------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,112 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_NEXTMESSAGEBLOCK;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-
-import org.jboss.messaging.core.Message;
-import org.jboss.messaging.core.impl.MessageImpl;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockResponse;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class BrowserNextMessageBlockResponseCodec extends AbstractPacketCodec<BrowserNextMessageBlockResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   public static byte[] encode(Message[] messages) throws Exception
-   {
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      DataOutputStream daos = new DataOutputStream(baos);
-      
-      for (int i = 0; i < messages.length; i++)
-      {
-         Message message = messages[i];
-         message.write(daos);
-      }
-      return baos.toByteArray();
-   }
-
-   // Constructors --------------------------------------------------
-
-   public BrowserNextMessageBlockResponseCodec()
-   {
-      super(RESP_BROWSER_NEXTMESSAGEBLOCK);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(BrowserNextMessageBlockResponse response, RemotingBuffer out) throws Exception
-   {
-      Message[] messages = response.getMessages();
-      
-      byte[] encodedMessages = encode(messages);
-
-      int bodyLength = INT_LENGTH + INT_LENGTH + encodedMessages.length;
-
-      out.putInt(bodyLength);
-      out.putInt(messages.length);
-      out.putInt(encodedMessages.length);
-      out.put(encodedMessages);
-   }
-
-   @Override
-   protected BrowserNextMessageBlockResponse decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      int numOfMessages = in.getInt();
-      int encodedMessagesLength = in.getInt();
-      byte[] encodedMessages = new byte[encodedMessagesLength];
-      in.get(encodedMessages);
-      Message[] messages = decode(numOfMessages, encodedMessages);
-
-      return new BrowserNextMessageBlockResponse(messages);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private ----------------------------------------------------
-
-   private Message[] decode(int numOfMessages, byte[] encodedMessages) throws Exception
-   {
-      Message[] messages = new Message[numOfMessages];
-      ByteArrayInputStream bais = new ByteArrayInputStream(encodedMessages);
-      DataInputStream dais = new DataInputStream(bais);
-      
-      for (int i = 0; i < messages.length; i++)
-      {
-         Message message = new MessageImpl();
-         message.read(dais);
-         messages[i] = message;
-      }
-      
-      return messages;
-   }
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_NEXTMESSAGE;
-
-import org.jboss.messaging.core.Message;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageResponse;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class BrowserNextMessageResponseCodec extends AbstractPacketCodec<BrowserNextMessageResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public BrowserNextMessageResponseCodec()
-   {
-      super(RESP_BROWSER_NEXTMESSAGE);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(BrowserNextMessageResponse response, RemotingBuffer out) throws Exception
-   {      
-      byte[] encodedMsg = encodeMessage(response.getMessage());
-
-      int bodyLength = INT_LENGTH + encodedMsg.length;
-
-      out.putInt(bodyLength);      
-      out.putInt(encodedMsg.length);
-      out.put(encodedMsg);
-   }
-
-   @Override
-   protected BrowserNextMessageResponse decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      int msgLength = in.getInt();
-      byte[] encodedMsg = new byte[msgLength];
-      in.get(encodedMsg);
-      Message message = decodeMessage(encodedMsg);
-
-      return new BrowserNextMessageResponse(message);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private ----------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionCreateSessionMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateSessionRequestCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionCreateSessionMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionCreateSessionMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONN_CREATESESSION;
+
+import org.jboss.messaging.core.remoting.wireformat.ConnectionCreateSessionMessage;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class ConnectionCreateSessionMessageCodec extends
+      AbstractPacketCodec<ConnectionCreateSessionMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public ConnectionCreateSessionMessageCodec()
+   {
+      super(CONN_CREATESESSION);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(ConnectionCreateSessionMessage request, RemotingBuffer out) throws Exception
+   {
+      boolean xa = request.isXA();
+      boolean autoCommitSends = request.isAutoCommitSends();
+      boolean autoCommitAcks = request.isAutoCommitAcks();
+      
+
+      int bodyLength = 3;
+
+      out.putInt(bodyLength);
+
+      out.putBoolean(xa);
+      out.putBoolean(autoCommitSends);
+      out.putBoolean(autoCommitAcks);
+      
+   }
+
+   @Override
+   protected ConnectionCreateSessionMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      boolean xa = in.getBoolean();
+      boolean autoCommitSends = in.getBoolean();
+      boolean autoCommitAcks = in.getBoolean();
+
+      return new ConnectionCreateSessionMessage(xa, autoCommitSends, autoCommitAcks);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionCreateSessionResponseMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateSessionResponseCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionCreateSessionResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionCreateSessionResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import org.jboss.messaging.core.remoting.wireformat.ConnectionCreateSessionResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.PacketType;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class ConnectionCreateSessionResponseMessageCodec extends
+      AbstractPacketCodec<ConnectionCreateSessionResponseMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public ConnectionCreateSessionResponseMessageCodec()
+   {
+      super(PacketType.CONN_CREATESESSION_RESP);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(ConnectionCreateSessionResponseMessage response, RemotingBuffer out) throws Exception
+   {
+      String sessionID = response.getSessionID();
+
+      int bodyLength = sizeof(sessionID);
+
+      out.putInt(bodyLength);
+      out.putNullableString(sessionID);
+   }
+
+   @Override
+   protected ConnectionCreateSessionResponseMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      String sessionID = in.getNullableString();
+
+      return new ConnectionCreateSessionResponseMessage(sessionID);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionFactoryCreateConnectionRequestCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionFactoryCreateConnectionRequestCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionFactoryCreateConnectionRequestCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import org.jboss.messaging.core.remoting.wireformat.CreateConnectionRequest;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONNECTION;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class ConnectionFactoryCreateConnectionRequestCodec extends
-      AbstractPacketCodec<CreateConnectionRequest>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   public ConnectionFactoryCreateConnectionRequestCodec()
-   {
-      super(REQ_CREATECONNECTION);
-   }
-
-   // AbstractPackedCodec overrides----------------------------------
-
-   @Override
-   protected void encodeBody(CreateConnectionRequest request,
-         RemotingBuffer out)
-         throws Exception
-   {
-      byte version = request.getVersion();
-      String remotingSessionID = request.getRemotingSessionID();
-      String clientVMID = request.getClientVMID();
-      String username = request.getUsername();
-      String password = request.getPassword();
-      int prefetchSize = request.getPrefetchSize();
-      int dupOkBatchSize = request.getDupsOKBatchSize();
-      String clientID = request.getClientID();
-
-      int bodyLength = 1 // version
-            + sizeof(remotingSessionID)
-            + sizeof(clientVMID)
-            + sizeof(username) 
-            + sizeof(password)
-            + INT_LENGTH
-            + INT_LENGTH
-            + sizeof(clientID);
-
-      out.putInt(bodyLength);
-      out.put(version);
-      out.putNullableString(remotingSessionID);
-      out.putNullableString(clientVMID);
-      out.putNullableString(username);
-      out.putNullableString(password);
-      out.putInt(prefetchSize);
-      out.putInt(dupOkBatchSize);
-      out.putNullableString(clientID);
-   }
-
-   @Override
-   protected CreateConnectionRequest decodeBody(
-         RemotingBuffer in) throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-      byte version = in.get();
-      String remotingSessionID = in.getNullableString();
-      String clientVMID = in.getNullableString();
-      String username = in.getNullableString();
-      String password = in.getNullableString();
-      int prefetchSize = in.getInt();
-      int dupOkBatchSize = in.getInt();
-      String clientID = in.getNullableString();
-
-      return new CreateConnectionRequest(version, remotingSessionID,
-            clientVMID, username, password, prefetchSize, dupOkBatchSize, clientID);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionFactoryCreateConnectionResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionFactoryCreateConnectionResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionFactoryCreateConnectionResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATECONNECTION;
-
-import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class ConnectionFactoryCreateConnectionResponseCodec extends
-      AbstractPacketCodec<CreateConnectionResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   public ConnectionFactoryCreateConnectionResponseCodec()
-   {
-      super(RESP_CREATECONNECTION);
-   }
-
-   // AbstractPackedCodec overrides----------------------------------
-
-   @Override
-   protected void encodeBody(CreateConnectionResponse response,
-         RemotingBuffer out)
-         throws Exception
-   {
-      String id = response.getConnectionID();
-
-      int bodyLength = sizeof(id);
-
-      out.putInt(bodyLength);
-      out.putNullableString(id);
-   }
-
-   @Override
-   protected CreateConnectionResponse decodeBody(
-         RemotingBuffer in) throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (bodyLength > in.remaining())
-      {
-         return null;
-      }
-      String id = in.getNullableString();
-
-      return new CreateConnectionResponse(id);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-
-}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/ConsumerChangeRateMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/ConsumerChangeRateMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/ConsumerChangeRateMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -6,7 +6,7 @@
  */
 package org.jboss.messaging.core.remoting.codec;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CHANGERATE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONS_CHANGERATE;
 
 import org.jboss.messaging.core.remoting.wireformat.ConsumerChangeRateMessage;
 
@@ -26,7 +26,7 @@
 
    public ConsumerChangeRateMessageCodec()
    {
-      super(MSG_CHANGERATE);
+      super(CONS_CHANGERATE);
    }
 
    // Public --------------------------------------------------------

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateBrowserRequestCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateBrowserRequestCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateBrowserRequestCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATEBROWSER;
-
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.remoting.wireformat.CreateBrowserRequest;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class CreateBrowserRequestCodec extends
-      AbstractPacketCodec<CreateBrowserRequest>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateBrowserRequestCodec()
-   {
-      super(REQ_CREATEBROWSER);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(CreateBrowserRequest request, RemotingBuffer out) throws Exception
-   {
-      byte[] destination = encode(request.getDestination());
-      String selector = request.getSelector();
-
-      int bodyLength = INT_LENGTH + destination.length + sizeof(selector);
-
-      out.putInt(bodyLength);
-      out.putInt(destination.length);
-      out.put(destination);
-      out.putNullableString(selector);
-   }
-
-   @Override
-   protected CreateBrowserRequest decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      int destinationLength = in.getInt();
-      byte[] b = new byte[destinationLength];
-      in.get(b);
-      Destination destination = decode(b);
-      String selector = in.getNullableString();
-
-      return new CreateBrowserRequest(destination, selector);
-   }
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateBrowserResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateBrowserResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateBrowserResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATEBROWSER;
-
-import org.jboss.messaging.core.remoting.wireformat.CreateBrowserResponse;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class CreateBrowserResponseCodec extends
-      AbstractPacketCodec<CreateBrowserResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateBrowserResponseCodec()
-   {
-      super(RESP_CREATEBROWSER);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(CreateBrowserResponse response,
-         RemotingBuffer out) throws Exception
-   {
-      String browserID = response.getBrowserID();
-
-      int bodyLength = sizeof(browserID);
-      
-      out.putInt(bodyLength);
-      out.putNullableString(browserID);
-   }
-
-   @Override
-   protected CreateBrowserResponse decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      String browserID = in.getNullableString();
-
-      return new CreateBrowserResponse(browserID);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConnectionMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionFactoryCreateConnectionRequestCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConnectionMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConnectionMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import org.jboss.messaging.core.remoting.wireformat.CreateConnectionRequest;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CREATECONNECTION;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class CreateConnectionMessageCodec extends
+      AbstractPacketCodec<CreateConnectionRequest>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public CreateConnectionMessageCodec()
+   {
+      super(CREATECONNECTION);
+   }
+
+   // AbstractPackedCodec overrides----------------------------------
+
+   @Override
+   protected void encodeBody(CreateConnectionRequest request,
+         RemotingBuffer out)
+         throws Exception
+   {
+      byte version = request.getVersion();
+      String remotingSessionID = request.getRemotingSessionID();
+      String clientVMID = request.getClientVMID();
+      String username = request.getUsername();
+      String password = request.getPassword();
+      int prefetchSize = request.getPrefetchSize();
+
+      int bodyLength = 1 // version
+            + sizeof(remotingSessionID)
+            + sizeof(clientVMID)
+            + sizeof(username) 
+            + sizeof(password)
+            + INT_LENGTH;
+
+      out.putInt(bodyLength);
+      out.put(version);
+      out.putNullableString(remotingSessionID);
+      out.putNullableString(clientVMID);
+      out.putNullableString(username);
+      out.putNullableString(password);
+      out.putInt(prefetchSize);
+   }
+
+   @Override
+   protected CreateConnectionRequest decodeBody(
+         RemotingBuffer in) throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+      byte version = in.get();
+      String remotingSessionID = in.getNullableString();
+      String clientVMID = in.getNullableString();
+      String username = in.getNullableString();
+      String password = in.getNullableString();
+      int prefetchSize = in.getInt();
+
+      return new CreateConnectionRequest(version, remotingSessionID,
+            clientVMID, username, password, prefetchSize);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConnectionResponseMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/ConnectionFactoryCreateConnectionResponseCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConnectionResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConnectionResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CREATECONNECTION_RESP;
+
+import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class CreateConnectionResponseMessageCodec extends
+      AbstractPacketCodec<CreateConnectionResponse>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public CreateConnectionResponseMessageCodec()
+   {
+      super(CREATECONNECTION_RESP);
+   }
+
+   // AbstractPackedCodec overrides----------------------------------
+
+   @Override
+   protected void encodeBody(CreateConnectionResponse response,
+         RemotingBuffer out)
+         throws Exception
+   {
+      String id = response.getConnectionID();
+
+      int bodyLength = sizeof(id);
+
+      out.putInt(bodyLength);
+      out.putNullableString(id);
+   }
+
+   @Override
+   protected CreateConnectionResponse decodeBody(
+         RemotingBuffer in) throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (bodyLength > in.remaining())
+      {
+         return null;
+      }
+      String id = in.getNullableString();
+
+      return new CreateConnectionResponse(id);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConsumerRequestCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConsumerRequestCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConsumerRequestCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONSUMER;
-
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.remoting.wireformat.CreateConsumerRequest;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class CreateConsumerRequestCodec extends
-      AbstractPacketCodec<CreateConsumerRequest>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateConsumerRequestCodec()
-   {
-      super(REQ_CREATECONSUMER);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(CreateConsumerRequest request, RemotingBuffer out) throws Exception
-   {
-      byte[] destination = encode(request.getDestination());
-      String selector = request.getSelector();
-      boolean noLocal = request.isNoLocal();
-      String subName = request.getSubscriptionName();
-      boolean connectionConsumer = request.isConnectionConsumer();
-
-      int bodyLength = INT_LENGTH + destination.length + sizeof(selector)
-            + sizeof(subName) + 2;
-
-      out.putInt(bodyLength);
-      out.putInt(destination.length);
-      out.put(destination);
-      out.putNullableString(selector);
-      out.putBoolean(noLocal);
-      out.putNullableString(subName);
-      out.putBoolean(connectionConsumer);
-   }
-
-   @Override
-   protected CreateConsumerRequest decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      int destinationLength = in.getInt();
-      byte[] b = new byte[destinationLength];
-      in.get(b);
-      Destination destination = decode(b);
-      String selector = in.getNullableString();
-      boolean noLocal = in.getBoolean();
-      String subName = in.getNullableString();
-      boolean connectionConsumer = in.getBoolean();
- 
-      return new CreateConsumerRequest(destination, selector, noLocal, subName,
-            connectionConsumer);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConsumerResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConsumerResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConsumerResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATECONSUMER;
-
-import org.jboss.messaging.core.remoting.wireformat.CreateConsumerResponse;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class CreateConsumerResponseCodec extends
-      AbstractPacketCodec<CreateConsumerResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateConsumerResponseCodec()
-   {
-      super(RESP_CREATECONSUMER);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(CreateConsumerResponse response,
-         RemotingBuffer out) throws Exception
-   {
-      String consumerID = response.getConsumerID();
-      int bufferSize = response.getBufferSize();
-      int maxDeliveries = response.getMaxDeliveries();
-      long redeliveryDelay = response.getRedeliveryDelay();
-
-      int bodyLength = sizeof(consumerID) + 2 * INT_LENGTH
-            + LONG_LENGTH;
-
-      out.putInt(bodyLength);
-      out.putNullableString(consumerID);
-      out.putInt(bufferSize);
-      out.putInt(maxDeliveries);
-      out.putLong(redeliveryDelay);
-   }
-
-   @Override
-   protected CreateConsumerResponse decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      String consumerID = in.getNullableString();
-      int bufferSize = in.getInt();
-      int maxDeliveries = in.getInt();
-      long redeliveryDelay = in.getLong();
-
-      return new CreateConsumerResponse(consumerID, bufferSize, maxDeliveries,
-            redeliveryDelay);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateDestinationRequestCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateDestinationRequestCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateDestinationRequestCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATEDESTINATION;
-
-import org.jboss.messaging.core.remoting.wireformat.CreateDestinationRequest;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class CreateDestinationRequestCodec extends
-      AbstractPacketCodec<CreateDestinationRequest>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateDestinationRequestCodec()
-   {
-      super(REQ_CREATEDESTINATION);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(CreateDestinationRequest request,
-         RemotingBuffer out) throws Exception
-   {
-      String name = request.getName();
-      boolean isQueue = request.isQueue();
-
-      int bodyLength = sizeof(name) + 1;
-
-      out.putInt(bodyLength);
-      out.putNullableString(name);
-      out.putBoolean(isQueue);
-   }
-
-   @Override
-   protected CreateDestinationRequest decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      String name = in.getNullableString();
-      boolean isQueue = in.getBoolean();
-
-      return new CreateDestinationRequest(name, isQueue);
-   }
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateDestinationResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateDestinationResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateDestinationResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATEDESTINATION;
-
-import org.jboss.jms.destination.JBossDestination;
-import org.jboss.messaging.core.remoting.wireformat.CreateDestinationResponse;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class CreateDestinationResponseCodec extends
-      AbstractPacketCodec<CreateDestinationResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateDestinationResponseCodec()
-   {
-      super(RESP_CREATEDESTINATION);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(CreateDestinationResponse response, RemotingBuffer out) throws Exception
-   {
-      byte[] destination = encodeJBossDestination(response.getDestination());
-
-      int bodyLength = INT_LENGTH + destination.length;
-
-      out.putInt(bodyLength);
-      out.putInt(destination.length);
-      out.put(destination);
-   }
-
-   @Override
-   protected CreateDestinationResponse decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      int destinationLength = in.getInt();
-      byte[] b = new byte[destinationLength];
-      in.get(b);
-      JBossDestination destination = decodeJBossDestination(b);
-
-      return new CreateDestinationResponse(destination);
-   }
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateSessionRequestCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateSessionRequestCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateSessionRequestCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,75 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATESESSION;
-
-import org.jboss.messaging.core.remoting.wireformat.CreateSessionRequest;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class CreateSessionRequestCodec extends
-      AbstractPacketCodec<CreateSessionRequest>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateSessionRequestCodec()
-   {
-      super(REQ_CREATESESSION);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(CreateSessionRequest request, RemotingBuffer out) throws Exception
-   {
-      boolean transacted = request.isTransacted();
-      int acknowledgementMode = request.getAcknowledgementMode();
-      boolean xa = request.isXA();
-
-      int bodyLength = 1 + INT_LENGTH + 1;
-
-      out.putInt(bodyLength);
-      out.putBoolean(transacted);
-      out.putInt(acknowledgementMode);
-      out.putBoolean(xa);
-   }
-
-   @Override
-   protected CreateSessionRequest decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      boolean transacted = in.getBoolean();
-      int acknowledgementMode = in.getInt();
-      boolean xa = in.getBoolean();
-
-      return new CreateSessionRequest(transacted, acknowledgementMode, xa);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateSessionResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateSessionResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateSessionResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import org.jboss.messaging.core.remoting.wireformat.CreateSessionResponse;
-import org.jboss.messaging.core.remoting.wireformat.PacketType;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class CreateSessionResponseCodec extends
-      AbstractPacketCodec<CreateSessionResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateSessionResponseCodec()
-   {
-      super(PacketType.RESP_CREATESESSION);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(CreateSessionResponse response, RemotingBuffer out) throws Exception
-   {
-      String sessionID = response.getSessionID();
-      int dupsOKBatchSize = response.getDupsOKBatchSize();
-
-      int bodyLength = sizeof(sessionID) + INT_LENGTH;
-
-      out.putInt(bodyLength);
-      out.putNullableString(sessionID);
-      out.putInt(dupsOKBatchSize);
-   }
-
-   @Override
-   protected CreateSessionResponse decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      String sessionID = in.getNullableString();
-      int dupsOKBatchSize = in.getInt();
-
-      return new CreateSessionResponse(sessionID, dupsOKBatchSize);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/DeleteTemporaryDestinationMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/DeleteTemporaryDestinationMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/DeleteTemporaryDestinationMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_DELETETEMPORARYDESTINATION;
-
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.remoting.wireformat.DeleteTemporaryDestinationMessage;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class DeleteTemporaryDestinationMessageCodec extends
-      AbstractPacketCodec<DeleteTemporaryDestinationMessage>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public DeleteTemporaryDestinationMessageCodec()
-   {
-      super(MSG_DELETETEMPORARYDESTINATION);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(DeleteTemporaryDestinationMessage message,
-         RemotingBuffer out) throws Exception
-   {
-      byte[] destination = encode(message.getDestination());
-
-      int bodyLength = INT_LENGTH + destination.length;
-
-      out.putInt(bodyLength);
-      out.putInt(destination.length);
-      out.put(destination);
-   }
-
-   @Override
-   protected DeleteTemporaryDestinationMessage decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      int destinationLength = in.getInt();
-      byte[] b = new byte[destinationLength];
-      in.get(b);
-      Destination destination = decode(b);
-
-      return new DeleteTemporaryDestinationMessage(destination);
-   }
-
-   // Inner classes -------------------------------------------------
-}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/DeliverMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/DeliverMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/DeliverMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -6,7 +6,7 @@
  */
 package org.jboss.messaging.core.remoting.codec;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_DELIVERMESSAGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_DELIVER;
 
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.remoting.wireformat.DeliverMessage;
@@ -26,7 +26,7 @@
 
    public DeliverMessageCodec()
    {
-      super(MSG_DELIVERMESSAGE);
+      super(SESS_DELIVER);
    }
 
    // Public --------------------------------------------------------

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/GetClientIDResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/GetClientIDResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/GetClientIDResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETCLIENTID;
-
-import org.jboss.messaging.core.remoting.wireformat.GetClientIDResponse;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- */
-public class GetClientIDResponseCodec extends
-      AbstractPacketCodec<GetClientIDResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public GetClientIDResponseCodec()
-   {
-      super(RESP_GETCLIENTID);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(GetClientIDResponse response, RemotingBuffer out) throws Exception
-   {
-      String clientID = response.getClientID();
-
-      out.putInt(sizeof(clientID));
-      out.putNullableString(clientID);
-   }
-
-   @Override
-   protected GetClientIDResponse decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      String clientID = in.getNullableString();
-
-      return new GetClientIDResponse(clientID);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/JMSExceptionMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/JMSExceptionMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/JMSExceptionMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,105 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import javax.jms.JMSException;
-
-import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
-import org.jboss.messaging.core.remoting.wireformat.PacketType;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class JMSExceptionMessageCodec extends
-      AbstractPacketCodec<JMSExceptionMessage>
-{
-
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   public static byte[] encodeJMSException(JMSException exception)
-         throws IOException
-   {
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      ObjectOutputStream oos = new ObjectOutputStream(baos);
-      oos.writeObject(exception);
-
-      byte[] encodedException = baos.toByteArray();
-      return encodedException;
-   }
-
-   public static JMSException decodeJMSException(byte[] b)
-   throws IOException, ClassNotFoundException
-   {
-      ByteArrayInputStream bais = new ByteArrayInputStream(b);
-      ObjectInputStream ois = new ObjectInputStream(bais);
-      JMSException exception = (JMSException) ois.readObject();
-      return exception;
-   }
-   
-   // Constructors --------------------------------------------------
-
-   public JMSExceptionMessageCodec()
-   {
-      super(PacketType.MSG_JMSEXCEPTION);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(JMSExceptionMessage message, RemotingBuffer out) throws Exception
-   {
-      byte[] encodedException = encodeJMSException(message.getException());
-      
-      int bodyLength = INT_LENGTH + encodedException.length;
-
-      out.putInt(bodyLength);
-      out.putInt(encodedException.length);
-      out.put(encodedException);
-   }
-
-   @Override
-   protected JMSExceptionMessage decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      int encodedExceptionLength = in.getInt();
-      byte[] b = new byte[encodedExceptionLength];
-      in.get(b);
-
-      JMSException exception = decodeJMSException(b);
-      
-      return new JMSExceptionMessage(exception);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionAcknowledgeMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionAcknowledgeMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionAcknowledgeMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -28,7 +28,7 @@
 
    public SessionAcknowledgeMessageCodec()
    {
-      super(PacketType.MSG_ACKNOWLEDGE);
+      super(PacketType.SESS_ACKNOWLEDGE);
    }
 
    // Public --------------------------------------------------------

Added: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionAddAddressMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionAddAddressMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionAddAddressMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_ADD_ADDRESS;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionAddAddressMessage;
+
+/**
+ * 
+ * A SessionAddAddressMessageCodec
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionAddAddressMessageCodec extends AbstractPacketCodec<SessionAddAddressMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionAddAddressMessageCodec()
+   {
+      super(SESS_ADD_ADDRESS);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionAddAddressMessage message, RemotingBuffer out) throws Exception
+   {
+      String address = message.getAddress();
+     
+      int bodyLength = sizeof(address);
+
+      out.putInt(bodyLength);
+      out.putNullableString(address);
+   }
+
+   @Override
+   protected SessionAddAddressMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      String address = in.getNullableString();
+    
+      return new SessionAddAddressMessage(address);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+

Added: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBindingQueryMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBindingQueryMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBindingQueryMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BINDINGQUERY;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionBindingQueryMessage;
+
+/**
+ * 
+ * A SessionBindingQueryMessageCodec
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionBindingQueryMessageCodec extends AbstractPacketCodec<SessionBindingQueryMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionBindingQueryMessageCodec()
+   {
+      super(SESS_BINDINGQUERY);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionBindingQueryMessage message, RemotingBuffer out) throws Exception
+   {
+      String address = message.getAddress();
+     
+      int bodyLength = sizeof(address);
+
+      out.putInt(bodyLength);
+      out.putNullableString(address);
+   }
+
+   @Override
+   protected SessionBindingQueryMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      String address = in.getNullableString();
+    
+      return new SessionBindingQueryMessage(address);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+

Added: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBindingQueryResponseMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBindingQueryResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBindingQueryResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BINDINGQUERY_RESP;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionBindingQueryResponseMessage;
+
+/**
+ * 
+ * A SessionBindingQueryResponseMessageCodec
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionBindingQueryResponseMessageCodec extends AbstractPacketCodec<SessionBindingQueryResponseMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionBindingQueryResponseMessageCodec()
+   {
+      super(SESS_BINDINGQUERY_RESP);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+
+   @Override
+   protected void encodeBody(SessionBindingQueryResponseMessage message, RemotingBuffer out) throws Exception
+   {
+      boolean exists = message.isExists();
+      List<String> queueNames = message.getQueueNames();
+
+      int bodyLength = 1 + INT_LENGTH;
+      
+      for (String queueName: queueNames)
+      {
+         bodyLength += sizeof(queueName);
+      }
+      
+      out.putInt(bodyLength);
+      out.putBoolean(exists);
+      out.putInt(queueNames.size());
+      
+      for (String queueName: queueNames)
+      {
+         out.putNullableString(queueName);
+      }      
+   }
+
+   @Override
+   protected SessionBindingQueryResponseMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      boolean exists = in.getBoolean();
+      
+      int numQueues = in.getInt();
+      
+      List<String> queueNames = new ArrayList<String>(numQueues);
+      
+      for (int i = 0; i < numQueues; i++)
+      {
+         queueNames.add(in.getNullableString());
+      }
+          
+      return new SessionBindingQueryResponseMessage(exists, queueNames);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+
+

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserHasNextMessageResponseMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserHasNextMessageResponseCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserHasNextMessageResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserHasNextMessageResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_HASNEXTMESSAGE_RESP;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserHasNextMessageResponseMessage;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class SessionBrowserHasNextMessageResponseMessageCodec extends
+      AbstractPacketCodec<SessionBrowserHasNextMessageResponseMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionBrowserHasNextMessageResponseMessageCodec()
+   {
+      super(SESS_BROWSER_HASNEXTMESSAGE_RESP);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionBrowserHasNextMessageResponseMessage response,
+         RemotingBuffer out) throws Exception
+   {
+      out.putInt(1); //body length
+      out.putBoolean(response.hasNext());
+   }
+
+   @Override
+   protected SessionBrowserHasNextMessageResponseMessage decodeBody(RemotingBuffer in) throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      boolean hasNext = in.getBoolean();
+
+      return new SessionBrowserHasNextMessageResponseMessage(hasNext);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserNextMessageBlockMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockRequestCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserNextMessageBlockMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserNextMessageBlockMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_NEXTMESSAGEBLOCK;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageBlockMessage;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class SessionBrowserNextMessageBlockMessageCodec extends AbstractPacketCodec<SessionBrowserNextMessageBlockMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionBrowserNextMessageBlockMessageCodec()
+   {
+      super(SESS_BROWSER_NEXTMESSAGEBLOCK);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionBrowserNextMessageBlockMessage request, RemotingBuffer out) throws Exception
+   {
+      out.putInt(LONG_LENGTH);
+      out.putLong(request.getMaxMessages());
+   }
+
+   @Override
+   protected SessionBrowserNextMessageBlockMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      long maxMessages = in.getLong();
+      
+      return new SessionBrowserNextMessageBlockMessage(maxMessages);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserNextMessageBlockResponseMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserNextMessageBlockResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserNextMessageBlockResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_NEXTMESSAGEBLOCK_RESP;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.messaging.core.Message;
+import org.jboss.messaging.core.impl.MessageImpl;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageBlockResponseMessage;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class SessionBrowserNextMessageBlockResponseMessageCodec extends AbstractPacketCodec<SessionBrowserNextMessageBlockResponseMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   public static byte[] encode(Message[] messages) throws Exception
+   {
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      DataOutputStream daos = new DataOutputStream(baos);
+      
+      for (int i = 0; i < messages.length; i++)
+      {
+         Message message = messages[i];
+         message.write(daos);
+      }
+      return baos.toByteArray();
+   }
+
+   // Constructors --------------------------------------------------
+
+   public SessionBrowserNextMessageBlockResponseMessageCodec()
+   {
+      super(SESS_BROWSER_NEXTMESSAGEBLOCK_RESP);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionBrowserNextMessageBlockResponseMessage response, RemotingBuffer out) throws Exception
+   {
+      Message[] messages = response.getMessages();
+      
+      byte[] encodedMessages = encode(messages);
+
+      int bodyLength = INT_LENGTH + INT_LENGTH + encodedMessages.length;
+
+      out.putInt(bodyLength);
+      out.putInt(messages.length);
+      out.putInt(encodedMessages.length);
+      out.put(encodedMessages);
+   }
+
+   @Override
+   protected SessionBrowserNextMessageBlockResponseMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      int numOfMessages = in.getInt();
+      int encodedMessagesLength = in.getInt();
+      byte[] encodedMessages = new byte[encodedMessagesLength];
+      in.get(encodedMessages);
+      Message[] messages = decode(numOfMessages, encodedMessages);
+
+      return new SessionBrowserNextMessageBlockResponseMessage(messages);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   private Message[] decode(int numOfMessages, byte[] encodedMessages) throws Exception
+   {
+      Message[] messages = new Message[numOfMessages];
+      ByteArrayInputStream bais = new ByteArrayInputStream(encodedMessages);
+      DataInputStream dais = new DataInputStream(bais);
+      
+      for (int i = 0; i < messages.length; i++)
+      {
+         Message message = new MessageImpl();
+         message.read(dais);
+         messages[i] = message;
+      }
+      
+      return messages;
+   }
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserNextMessageResponseMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageResponseCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserNextMessageResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionBrowserNextMessageResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_NEXTMESSAGE_RESP;
+
+import org.jboss.messaging.core.Message;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageResponseMessage;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class SessionBrowserNextMessageResponseMessageCodec extends AbstractPacketCodec<SessionBrowserNextMessageResponseMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionBrowserNextMessageResponseMessageCodec()
+   {
+      super(SESS_BROWSER_NEXTMESSAGE_RESP);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionBrowserNextMessageResponseMessage response, RemotingBuffer out) throws Exception
+   {      
+      byte[] encodedMsg = encodeMessage(response.getMessage());
+
+      int bodyLength = INT_LENGTH + encodedMsg.length;
+
+      out.putInt(bodyLength);      
+      out.putInt(encodedMsg.length);
+      out.put(encodedMsg);
+   }
+
+   @Override
+   protected SessionBrowserNextMessageResponseMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      int msgLength = in.getInt();
+      byte[] encodedMsg = new byte[msgLength];
+      in.get(encodedMsg);
+      Message message = decodeMessage(encodedMsg);
+
+      return new SessionBrowserNextMessageResponseMessage(message);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCancelMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCancelMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCancelMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -28,7 +28,7 @@
 
    public SessionCancelMessageCodec()
    {
-      super(PacketType.MSG_CANCEL);
+      super(PacketType.SESS_CANCEL);
    }
 
    // Public --------------------------------------------------------

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateBrowserMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateBrowserRequestCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateBrowserMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateBrowserMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATEBROWSER;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateBrowserMessage;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class SessionCreateBrowserMessageCodec extends
+      AbstractPacketCodec<SessionCreateBrowserMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionCreateBrowserMessageCodec()
+   {
+      super(SESS_CREATEBROWSER);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionCreateBrowserMessage request, RemotingBuffer out) throws Exception
+   {
+      String queueName = request.getQueueName();
+      String filterString = request.getFilterString();
+
+      int bodyLength = sizeof(queueName) + sizeof(filterString);
+
+      out.putInt(bodyLength);
+      out.putNullableString(queueName);
+      out.putNullableString(filterString);
+   }
+
+   @Override
+   protected SessionCreateBrowserMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      String queueName = in.getNullableString();
+      String filterString = in.getNullableString();
+
+      return new SessionCreateBrowserMessage(queueName, filterString);
+   }
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateBrowserResponseMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateBrowserResponseCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateBrowserResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateBrowserResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATEBROWSER_RESP;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateBrowserResponseMessage;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class SessionCreateBrowserResponseMessageCodec extends
+      AbstractPacketCodec<SessionCreateBrowserResponseMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionCreateBrowserResponseMessageCodec()
+   {
+      super(SESS_CREATEBROWSER_RESP);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionCreateBrowserResponseMessage response,
+         RemotingBuffer out) throws Exception
+   {
+      String browserID = response.getBrowserID();
+
+      int bodyLength = sizeof(browserID);
+      
+      out.putInt(bodyLength);
+      out.putNullableString(browserID);
+   }
+
+   @Override
+   protected SessionCreateBrowserResponseMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      String browserID = in.getNullableString();
+
+      return new SessionCreateBrowserResponseMessage(browserID);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateConsumerMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConsumerRequestCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateConsumerMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateConsumerMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATECONSUMER;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateConsumerMessage;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class SessionCreateConsumerMessageCodec extends
+      AbstractPacketCodec<SessionCreateConsumerMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionCreateConsumerMessageCodec()
+   {
+      super(SESS_CREATECONSUMER);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionCreateConsumerMessage request, RemotingBuffer out) throws Exception
+   {
+      String queueName = request.getQueueName();
+      String filterString = request.getFilterString();
+      boolean noLocal = request.isNoLocal();
+      boolean autoDelete = request.isAutoDeleteQueue();
+
+      int bodyLength = sizeof(queueName) + sizeof(filterString) + 2;
+
+      out.putInt(bodyLength);
+      out.putNullableString(queueName);
+      out.putNullableString(filterString);
+      out.putBoolean(noLocal);
+      out.putBoolean(autoDelete);
+   }
+
+   @Override
+   protected SessionCreateConsumerMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      String queueName = in.getNullableString();
+      String filterString = in.getNullableString();
+      boolean noLocal = in.getBoolean();
+      boolean autoDelete = in.getBoolean();
+ 
+      return new SessionCreateConsumerMessage(queueName, filterString, noLocal, autoDelete);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateConsumerResponseMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/CreateConsumerResponseCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateConsumerResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateConsumerResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATECONSUMER_RESP;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateConsumerResponseMessage;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class SessionCreateConsumerResponseMessageCodec extends
+      AbstractPacketCodec<SessionCreateConsumerResponseMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionCreateConsumerResponseMessageCodec()
+   {
+      super(SESS_CREATECONSUMER_RESP);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionCreateConsumerResponseMessage response,
+         RemotingBuffer out) throws Exception
+   {
+      String consumerID = response.getConsumerID();
+      int bufferSize = response.getBufferSize();
+
+      int bodyLength = sizeof(consumerID) + INT_LENGTH;
+       
+      out.putInt(bodyLength);
+      out.putNullableString(consumerID);
+      out.putInt(bufferSize);
+   }
+
+   @Override
+   protected SessionCreateConsumerResponseMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      String consumerID = in.getNullableString();
+      int bufferSize = in.getInt();
+ 
+      return new SessionCreateConsumerResponseMessage(consumerID, bufferSize);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateQueueMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateQueueMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionCreateQueueMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATEQUEUE;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateQueueMessage;
+
+/**
+ * 
+ * A SessionCreateQueueMessageCodec
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionCreateQueueMessageCodec extends AbstractPacketCodec<SessionCreateQueueMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionCreateQueueMessageCodec()
+   {
+      super(SESS_CREATEQUEUE);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionCreateQueueMessage message, RemotingBuffer out) throws Exception
+   {
+      String address = message.getAddress();
+      String queueName = message.getQueueName();
+      String filterString = message.getFilterString();
+      boolean durable = message.isDurable();
+      boolean temporary = message.isTemporary();
+     
+      int bodyLength = sizeof(address) + sizeof(queueName) + sizeof(filterString) + 2;
+
+      out.putInt(bodyLength);
+      out.putNullableString(address);
+      out.putNullableString(queueName);
+      out.putNullableString(filterString);
+      out.putBoolean(durable);
+      out.putBoolean(temporary);
+   }
+
+   @Override
+   protected SessionCreateQueueMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      String address = in.getNullableString();
+      String queueName = in.getNullableString();
+      String filterString = in.getNullableString();
+      boolean durable = in.getBoolean();
+      boolean temporary = in.getBoolean();
+    
+      return new SessionCreateQueueMessage(address, queueName, filterString, durable, temporary);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+

Added: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionDeleteQueueMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionDeleteQueueMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionDeleteQueueMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_DELETE_QUEUE;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionDeleteQueueMessage;
+
+/**
+ * 
+ * A SessionDeleteQueueMessageCodec
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionDeleteQueueMessageCodec extends AbstractPacketCodec<SessionDeleteQueueMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionDeleteQueueMessageCodec()
+   {
+      super(SESS_DELETE_QUEUE);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionDeleteQueueMessage message, RemotingBuffer out) throws Exception
+   {
+      String queueName = message.getQueueName();
+     
+      int bodyLength = sizeof(queueName);
+
+      out.putInt(bodyLength);
+      out.putNullableString(queueName);
+   }
+
+   @Override
+   protected SessionDeleteQueueMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      String queueName = in.getNullableString();
+    
+      return new SessionDeleteQueueMessage(queueName);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionQueueQueryMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionQueueQueryMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionQueueQueryMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_QUEUEQUERY;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionQueueQueryMessage;
+
+/**
+ * 
+ * A SessionQueueQueryMessageCodec
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionQueueQueryMessageCodec extends AbstractPacketCodec<SessionQueueQueryMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionQueueQueryMessageCodec()
+   {
+      super(SESS_QUEUEQUERY);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionQueueQueryMessage message, RemotingBuffer out) throws Exception
+   {
+      String queueName = message.getQueueName();
+     
+      int bodyLength = sizeof(queueName);
+
+      out.putInt(bodyLength);
+      out.putNullableString(queueName);
+   }
+
+   @Override
+   protected SessionQueueQueryMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      String queueName = in.getNullableString();
+    
+      return new SessionQueueQueryMessage(queueName);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionQueueQueryResponseMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionQueueQueryResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionQueueQueryResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATEQUEUE;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionQueueQueryResponseMessage;
+
+/**
+ * 
+ * A SessionQueueQueryResponseMessageCodec
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionQueueQueryResponseMessageCodec extends AbstractPacketCodec<SessionQueueQueryResponseMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionQueueQueryResponseMessageCodec()
+   {
+      super(SESS_CREATEQUEUE);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionQueueQueryResponseMessage message, RemotingBuffer out) throws Exception
+   {
+      boolean exists = message.isExists();
+      boolean durable = message.isDurable();
+      boolean temporary = message.isTemporary();
+      int maxSize = message.getMaxSize();
+      int consumerCount = message.getConsumerCount();
+      int messageCount = message.getMessageCount();
+      String filterString  = message.getFilterString();
+      String address = message.getAddress();
+     
+      int bodyLength = 1 + 1 + 1 + INT_LENGTH + INT_LENGTH + INT_LENGTH + sizeof(filterString) + sizeof(address);
+
+      out.putInt(bodyLength);
+      out.putBoolean(exists);
+      out.putBoolean(durable);
+      out.putBoolean(temporary);
+      out.putInt(maxSize);
+      out.putInt(consumerCount);
+      out.putInt(messageCount);
+      out.putNullableString(filterString);
+      out.putNullableString(address);
+   }
+
+   @Override
+   protected SessionQueueQueryResponseMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      boolean exists = in.getBoolean();
+      boolean durable = in.getBoolean();
+      boolean temporary = in.getBoolean();
+      int maxSize = in.getInt();
+      int consumerCount = in.getInt();
+      int messageCount = in.getInt();
+      String filterString  = in.getNullableString();
+      String address = in.getNullableString();
+    
+      if (exists)
+      {
+         return new SessionQueueQueryResponseMessage(durable, temporary, maxSize, consumerCount,
+                                       messageCount, filterString, address);
+      }
+      else
+      {
+         return new SessionQueueQueryResponseMessage();
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+
+

Added: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionRemoveAddressMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionRemoveAddressMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionRemoveAddressMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_REMOVE_ADDRESS;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionRemoveAddressMessage;
+
+/**
+ * 
+ * A SessionRemoveAddressMessageCodec
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionRemoveAddressMessageCodec extends AbstractPacketCodec<SessionRemoveAddressMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionRemoveAddressMessageCodec()
+   {
+      super(SESS_REMOVE_ADDRESS);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionRemoveAddressMessage message, RemotingBuffer out) throws Exception
+   {
+      String address = message.getAddress();
+     
+      int bodyLength = sizeof(address);
+
+      out.putInt(bodyLength);
+      out.putNullableString(address);
+   }
+
+   @Override
+   protected SessionRemoveAddressMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+
+      String address = in.getNullableString();
+    
+      return new SessionRemoveAddressMessage(address);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionSendMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionSendMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionSendMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -6,7 +6,7 @@
  */
 package org.jboss.messaging.core.remoting.codec;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SENDMESSAGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_SEND;
 
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.remoting.wireformat.SessionSendMessage;
@@ -26,7 +26,7 @@
 
    public SessionSendMessageCodec()
    {
-      super(MSG_SENDMESSAGE);
+      super(SESS_SEND);
    }
 
    // Public --------------------------------------------------------
@@ -36,11 +36,13 @@
    @Override
    protected void encodeBody(SessionSendMessage message, RemotingBuffer out) throws Exception
    {
+      String address = message.getAddress();
       byte[] encodedMsg = encodeMessage(message.getMessage());   
 
-      int bodyLength = INT_LENGTH + encodedMsg.length;
+      int bodyLength = sizeof(address) + INT_LENGTH + encodedMsg.length;
 
       out.putInt(bodyLength);
+      out.putNullableString(address);
       out.putInt(encodedMsg.length);
       out.put(encodedMsg);
    }
@@ -55,12 +57,13 @@
          return null;
       }
 
+      String address = in.getNullableString();
       int msgLength = in.getInt();
       byte[] encodedMsg = new byte[msgLength];
       in.get(encodedMsg);
       Message msg = decodeMessage(encodedMsg);
 
-      return new SessionSendMessage(msg);
+      return new SessionSendMessage(address, msg);
    }
 
    // Package protected ---------------------------------------------

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionSetIDMessageCodec.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/codec/SetSessionIDMessageCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionSetIDMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionSetIDMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_SETID;
+
+import org.jboss.messaging.core.remoting.wireformat.SessionSetIDMessage;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class SessionSetIDMessageCodec extends
+      AbstractPacketCodec<SessionSetIDMessage>
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionSetIDMessageCodec()
+   {
+      super(SESS_SETID);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionSetIDMessage message, RemotingBuffer out)
+         throws Exception
+   {
+      String sessionID = message.getSessionID();
+
+      out.putInt(sizeof(sessionID));
+      out.putNullableString(sessionID);
+   }
+
+   @Override
+   protected SessionSetIDMessage decodeBody(RemotingBuffer in) throws Exception
+   {
+      int bodyLength = in.getInt();
+      if (bodyLength > in.remaining())
+      {
+         return null;
+      }
+      String sessionID = in.getNullableString();
+
+      return new SessionSetIDMessage(sessionID);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
\ No newline at end of file

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXACommitMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXACommitMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXACommitMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -30,7 +30,7 @@
 
    public SessionXACommitMessageCodec()
    {
-      super(PacketType.MSG_XA_COMMIT);
+      super(PacketType.SESS_XA_COMMIT);
    }
 
    // Public --------------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAEndMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAEndMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAEndMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -30,7 +30,7 @@
 
    public SessionXAEndMessageCodec()
    {
-      super(PacketType.MSG_XA_END);
+      super(PacketType.SESS_XA_END);
    }
 
    // Public --------------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAForgetMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAForgetMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAForgetMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -30,7 +30,7 @@
 
    public SessionXAForgetMessageCodec()
    {
-      super(PacketType.MSG_XA_FORGET);
+      super(PacketType.SESS_XA_FORGET);
    }
 
    // Public --------------------------------------------------------

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetInDoubtXidsResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetInDoubtXidsResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetInDoubtXidsResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.transaction.xa.Xid;
-
-import org.jboss.messaging.core.remoting.wireformat.PacketType;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsResponse;
-
-
-/**
- * 
- * A SessionXAGetInDoubtXidsResponseCodec
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class SessionXAGetInDoubtXidsResponseCodec extends AbstractPacketCodec<SessionXAGetInDoubtXidsResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SessionXAGetInDoubtXidsResponseCodec()
-   {
-      super(PacketType.REQ_XA_INDOUBT_XIDS);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(SessionXAGetInDoubtXidsResponse message, RemotingBuffer out) throws Exception
-   {      
-      int bodyLength = 1;
-      
-      for (Xid xid: message.getXids())
-      {
-         bodyLength += getXidLength(xid);
-      }
-       
-      out.putInt(bodyLength);
-      
-      out.putInt(message.getXids().size());
-      
-      for (Xid xid: message.getXids())
-      {
-        encodeXid(xid, out);
-      }
-      
-   }
-
-   @Override
-   protected SessionXAGetInDoubtXidsResponse decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-      
-      int size = in.getInt();
-      
-      List<Xid> xids = new ArrayList<Xid>(size);
-      
-      for (int i = 0; i < size; i++)
-      {
-         Xid xid = decodeXid(in);
-         
-         xids.add(xid);
-      }
-      
-      return new SessionXAGetInDoubtXidsResponse(xids);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private ----------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}
-

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetInDoubtXidsResponseMessageCodec.java (from rev 3655, trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetInDoubtXidsResponseCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetInDoubtXidsResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetInDoubtXidsResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.transaction.xa.Xid;
+
+import org.jboss.messaging.core.remoting.wireformat.PacketType;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsResponseMessage;
+
+
+/**
+ * 
+ * A SessionXAGetInDoubtXidsResponseMessageCodec
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionXAGetInDoubtXidsResponseMessageCodec extends AbstractPacketCodec<SessionXAGetInDoubtXidsResponseMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionXAGetInDoubtXidsResponseMessageCodec()
+   {
+      super(PacketType.SESS_XA_INDOUBT_XIDS);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionXAGetInDoubtXidsResponseMessage message, RemotingBuffer out) throws Exception
+   {      
+      int bodyLength = 1;
+      
+      for (Xid xid: message.getXids())
+      {
+         bodyLength += getXidLength(xid);
+      }
+       
+      out.putInt(bodyLength);
+      
+      out.putInt(message.getXids().size());
+      
+      for (Xid xid: message.getXids())
+      {
+        encodeXid(xid, out);
+      }
+      
+   }
+
+   @Override
+   protected SessionXAGetInDoubtXidsResponseMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+      
+      int size = in.getInt();
+      
+      List<Xid> xids = new ArrayList<Xid>(size);
+      
+      for (int i = 0; i < size; i++)
+      {
+         Xid xid = decodeXid(in);
+         
+         xids.add(xid);
+      }
+      
+      return new SessionXAGetInDoubtXidsResponseMessage(xids);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetTimeoutResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetTimeoutResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetTimeoutResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import org.jboss.messaging.core.remoting.wireformat.PacketType;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutResponse;
-
-
-/**
- * 
- * A SessionXAGetTimeoutResponseCodec
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class SessionXAGetTimeoutResponseCodec extends AbstractPacketCodec<SessionXAGetTimeoutResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SessionXAGetTimeoutResponseCodec()
-   {
-      super(PacketType.MSG_XA_GET_TIMEOUT_RESPONSE);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(SessionXAGetTimeoutResponse message, RemotingBuffer out) throws Exception
-   {      
-      int bodyLength = INT_LENGTH;
-      
-      out.putInt(bodyLength);
-      
-      out.putInt(message.getTimeoutSeconds());
-   }
-
-   @Override
-   protected SessionXAGetTimeoutResponse decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-      
-      int timeout = in.getInt();
-      
-      return new SessionXAGetTimeoutResponse(timeout);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private ----------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}
-

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetTimeoutResponseMessageCodec.java (from rev 3655, trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetTimeoutResponseCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetTimeoutResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAGetTimeoutResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import org.jboss.messaging.core.remoting.wireformat.PacketType;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutResponseMessage;
+
+
+/**
+ * 
+ * A SessionXAGetTimeoutResponseMessageCodec
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionXAGetTimeoutResponseMessageCodec extends AbstractPacketCodec<SessionXAGetTimeoutResponseMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionXAGetTimeoutResponseMessageCodec()
+   {
+      super(PacketType.SESS_XA_GET_TIMEOUT_RESP);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionXAGetTimeoutResponseMessage message, RemotingBuffer out) throws Exception
+   {      
+      int bodyLength = INT_LENGTH;
+      
+      out.putInt(bodyLength);
+      
+      out.putInt(message.getTimeoutSeconds());
+   }
+
+   @Override
+   protected SessionXAGetTimeoutResponseMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+      
+      int timeout = in.getInt();
+      
+      return new SessionXAGetTimeoutResponseMessage(timeout);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAJoinMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAJoinMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAJoinMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -30,7 +30,7 @@
 
    public SessionXAJoinMessageCodec()
    {
-      super(PacketType.MSG_XA_JOIN);
+      super(PacketType.SESS_XA_JOIN);
    }
 
    // Public --------------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAPrepareMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAPrepareMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAPrepareMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -30,7 +30,7 @@
 
    public SessionXAPrepareMessageCodec()
    {
-      super(PacketType.REQ_XA_PREPARE);
+      super(PacketType.SESS_XA_PREPARE);
    }
 
    // Public --------------------------------------------------------

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,82 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import org.jboss.messaging.core.remoting.wireformat.PacketType;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAResponse;
-
-
-/**
- * 
- * A SessionXAResponseCodec
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class SessionXAResponseCodec extends AbstractPacketCodec<SessionXAResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SessionXAResponseCodec()
-   {
-      super(PacketType.RESP_XA);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(SessionXAResponse message, RemotingBuffer out) throws Exception
-   {      
-      int bodyLength = 1 + INT_LENGTH + sizeof(message.getMessage());
-      
-      out.putInt(bodyLength);
-      
-      out.putBoolean(message.isError());
-      
-      out.putInt(message.getResponseCode());
-      
-      out.putNullableString(message.getMessage());
-   }
-
-   @Override
-   protected SessionXAResponse decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-      
-      boolean isError = in.getBoolean();
-      
-      int responseCode = in.getInt();
-      
-      String message = in.getNullableString();
-      
-      return new SessionXAResponse(isError, responseCode, message);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private ----------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}
-
-

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResponseMessageCodec.java (from rev 3655, trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResponseCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import org.jboss.messaging.core.remoting.wireformat.PacketType;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAResponseMessage;
+
+
+/**
+ * 
+ * A SessionXAResponseMessageCodec
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionXAResponseMessageCodec extends AbstractPacketCodec<SessionXAResponseMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionXAResponseMessageCodec()
+   {
+      super(PacketType.SESS_XA_RESP);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionXAResponseMessage message, RemotingBuffer out) throws Exception
+   {      
+      int bodyLength = 1 + INT_LENGTH + sizeof(message.getMessage());
+      
+      out.putInt(bodyLength);
+      
+      out.putBoolean(message.isError());
+      
+      out.putInt(message.getResponseCode());
+      
+      out.putNullableString(message.getMessage());
+   }
+
+   @Override
+   protected SessionXAResponseMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+      
+      boolean isError = in.getBoolean();
+      
+      int responseCode = in.getInt();
+      
+      String message = in.getNullableString();
+      
+      return new SessionXAResponseMessage(isError, responseCode, message);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+
+

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResumeMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResumeMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAResumeMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -30,7 +30,7 @@
 
    public SessionXAResumeMessageCodec()
    {
-      super(PacketType.MSG_XA_RESUME);
+      super(PacketType.SESS_XA_RESUME);
    }
 
    // Public --------------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXARollbackMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXARollbackMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXARollbackMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -23,7 +23,7 @@
 
    public SessionXARollbackMessageCodec()
    {
-      super(PacketType.MSG_XA_ROLLBACK);
+      super(PacketType.SESS_XA_ROLLBACK);
    }
 
    // Public --------------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -28,7 +28,7 @@
 
    public SessionXASetTimeoutMessageCodec()
    {
-      super(PacketType.MSG_XA_SET_TIMEOUT);
+      super(PacketType.SESS_XA_SET_TIMEOUT);
    }
 
    // Public --------------------------------------------------------

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutResponseCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutResponseCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import org.jboss.messaging.core.remoting.wireformat.PacketType;
-import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutResponse;
-
-/**
- * 
- * A SessionXASetTimeoutResponseCodec
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class SessionXASetTimeoutResponseCodec extends AbstractPacketCodec<SessionXASetTimeoutResponse>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SessionXASetTimeoutResponseCodec()
-   {
-      super(PacketType.MSG_XA_SET_TIMEOUT_RESPONSE);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(SessionXASetTimeoutResponse message, RemotingBuffer out) throws Exception
-   {                 
-      int bodyLength = 1;
-      
-      out.putInt(bodyLength);
-      
-      out.putBoolean(message.isOK());
-   }
-
-   @Override
-   protected SessionXASetTimeoutResponse decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-      
-      boolean ok = in.getBoolean();
-      
-      return new SessionXASetTimeoutResponse(ok);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private ----------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}
-
-

Copied: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutResponseMessageCodec.java (from rev 3655, trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutResponseCodec.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutResponseMessageCodec.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXASetTimeoutResponseMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import org.jboss.messaging.core.remoting.wireformat.PacketType;
+import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutResponseMessage;
+
+/**
+ * 
+ * A SessionXASetTimeoutResponseMessageCodec
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionXASetTimeoutResponseMessageCodec extends AbstractPacketCodec<SessionXASetTimeoutResponseMessage>
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionXASetTimeoutResponseMessageCodec()
+   {
+      super(PacketType.SESS_XA_SET_TIMEOUT_RESP);
+   }
+
+   // Public --------------------------------------------------------
+
+   // AbstractPacketCodec overrides ---------------------------------
+
+   @Override
+   protected void encodeBody(SessionXASetTimeoutResponseMessage message, RemotingBuffer out) throws Exception
+   {                 
+      int bodyLength = 1;
+      
+      out.putInt(bodyLength);
+      
+      out.putBoolean(message.isOK());
+   }
+
+   @Override
+   protected SessionXASetTimeoutResponseMessage decodeBody(RemotingBuffer in)
+         throws Exception
+   {
+      int bodyLength = in.getInt();
+      
+      if (in.remaining() < bodyLength)
+      {
+         return null;
+      }
+      
+      boolean ok = in.getBoolean();
+      
+      return new SessionXASetTimeoutResponseMessage(ok);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private ----------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+
+

Modified: trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAStartMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAStartMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SessionXAStartMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -30,7 +30,7 @@
 
    public SessionXAStartMessageCodec()
    {
-      super(PacketType.MSG_XA_START);
+      super(PacketType.SESS_XA_START);
    }
 
    // Public --------------------------------------------------------

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/SetClientIDMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SetClientIDMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SetClientIDMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SETCLIENTID;
-
-import org.jboss.messaging.core.remoting.wireformat.SetClientIDMessage;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- */
-public class SetClientIDMessageCodec extends
-      AbstractPacketCodec<SetClientIDMessage>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SetClientIDMessageCodec()
-   {
-      super(MSG_SETCLIENTID);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(SetClientIDMessage message, RemotingBuffer out) throws Exception
-   {
-      String clientID = message.getClientID();
-
-      out.putInt(sizeof(clientID));
-      out.putNullableString(clientID);
-   }
-
-   @Override
-   protected SetClientIDMessage decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      String clientID = in.getNullableString();
-
-      return new SetClientIDMessage(clientID);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/SetSessionIDMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/SetSessionIDMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/SetSessionIDMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SETSESSIONID;
-
-import org.jboss.messaging.core.remoting.wireformat.SetSessionIDMessage;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class SetSessionIDMessageCodec extends
-      AbstractPacketCodec<SetSessionIDMessage>
-{
-
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SetSessionIDMessageCodec()
-   {
-      super(MSG_SETSESSIONID);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(SetSessionIDMessage message, RemotingBuffer out)
-         throws Exception
-   {
-      String sessionID = message.getSessionID();
-
-      out.putInt(sizeof(sessionID));
-      out.putNullableString(sessionID);
-   }
-
-   @Override
-   protected SetSessionIDMessage decodeBody(RemotingBuffer in) throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (bodyLength > in.remaining())
-      {
-         return null;
-      }
-      String sessionID = in.getNullableString();
-
-      return new SetSessionIDMessage(sessionID);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}
\ No newline at end of file

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/UnsubscribeMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/UnsubscribeMessageCodec.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/UnsubscribeMessageCodec.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,61 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_UNSUBSCRIBE;
-
-import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class UnsubscribeMessageCodec extends
-      AbstractPacketCodec<UnsubscribeMessage>
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public UnsubscribeMessageCodec()
-   {
-      super(MSG_UNSUBSCRIBE);
-   }
-
-   // Public --------------------------------------------------------
-
-   // AbstractPacketCodec overrides ---------------------------------
-
-   @Override
-   protected void encodeBody(UnsubscribeMessage message, RemotingBuffer out) throws Exception
-   {
-      String subscriptionName = message.getSubscriptionName();
-
-      out.putInt(sizeof(subscriptionName));
-      out.putNullableString(subscriptionName);
-   }
-
-   @Override
-   protected UnsubscribeMessage decodeBody(RemotingBuffer in)
-         throws Exception
-   {
-      int bodyLength = in.getInt();
-      if (in.remaining() < bodyLength)
-      {
-         return null;
-      }
-
-      String subscriptionName = in.getNullableString();
-
-      return new UnsubscribeMessage(subscriptionName);
-   }
-
-   // Inner classes -------------------------------------------------
-}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/ClientImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/ClientImpl.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/ClientImpl.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -8,20 +8,16 @@
 
 import static java.util.concurrent.TimeUnit.SECONDS;
 
-import java.io.IOException;
 import java.util.concurrent.TimeUnit;
 
-import javax.jms.IllegalStateException;
-import javax.jms.JMSException;
-
-import org.jboss.jms.client.remoting.ConsolidatedRemotingConnectionListener;
-import org.jboss.jms.exception.MessagingNetworkFailureException;
+import org.jboss.jms.client.api.FailureListener;
 import org.jboss.messaging.core.remoting.Client;
 import org.jboss.messaging.core.remoting.NIOConnector;
 import org.jboss.messaging.core.remoting.NIOSession;
 import org.jboss.messaging.core.remoting.RemotingConfiguration;
 import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -36,16 +32,17 @@
 
    // Attributes ----------------------------------------------------
 
-   private RemotingConfiguration remotingConfig;
-
    private final NIOConnector connector;
 
    private NIOSession session;
 
    // By default, a blocking request will timeout after 5 seconds
    private int blockingRequestTimeout = 5;
+   
    private TimeUnit blockingRequestTimeUnit = SECONDS;
    
+   private FailureListener failureListener;
+   
    // Static --------------------------------------------------------
 
    // Constructors --------------------------------------------------
@@ -56,7 +53,6 @@
       assert remotingConfig != null;
       
       this.connector = connector;
-      this.remotingConfig = remotingConfig;
       setBlockingRequestTimeout(remotingConfig.getTimeout(), SECONDS);
    }
 
@@ -96,7 +92,7 @@
    }
 
    public AbstractPacket send(AbstractPacket packet, boolean oneWay)
-         throws JMSException, IOException
+         throws Exception
    {
       assert packet != null;
       checkConnected();
@@ -121,22 +117,29 @@
       this.blockingRequestTimeUnit = unit;
    }
 
-   /* (non-Javadoc)
-    * @see org.jboss.messaging.core.remoting.Client#addConnectionListener(org.jboss.jms.client.remoting.ConsolidatedRemotingConnectionListener)
-    */
-   public void addConnectionListener(
-         final ConsolidatedRemotingConnectionListener listener)
+   public void setFailureListener(final FailureListener listener)
    {
-      connector.addConnectionListener(listener);
+      if (listener == null && failureListener != null)
+      {
+         connector.removeFailureListener(failureListener);
+         
+         failureListener = null;
+      }
+      else
+      {
+         if (failureListener != null)
+         {
+            throw new IllegalStateException("Cannot set FailureListener - already has one set");
+         }
+         connector.addFailureListener(listener);
+         
+         failureListener = listener;
+      }
    }
 
-   /* (non-Javadoc)
-    * @see org.jboss.messaging.core.remoting.Client#removeConnectionListener(org.jboss.jms.client.remoting.ConsolidatedRemotingConnectionListener)
-    */
-   public void removeConnectionListener(
-         ConsolidatedRemotingConnectionListener listener)
+   public FailureListener getFailureListener()
    {
-      connector.removeConnectionListener(listener);
+      return failureListener;
    }
 
    /* (non-Javadoc)
@@ -170,7 +173,7 @@
 
    // Private -------------------------------------------------------
 
-   private void checkConnected() throws JMSException
+   private void checkConnected() throws MessagingException
    {
       if (session == null)
       {
@@ -179,30 +182,20 @@
       }
       if (!session.isConnected())
       {
-         throw new MessagingNetworkFailureException("Client " + this
-               + " is not connected.");
+         throw new MessagingException(MessagingException.NOT_CONNECTED);
       }
    }
    
-   private void sendOneWay(AbstractPacket packet) throws JMSException
+   private void sendOneWay(AbstractPacket packet) throws Exception
    {
       session.write(packet);
    }
 
-   private AbstractPacket sendBlocking(AbstractPacket packet)
-         throws IOException, JMSException
+   private AbstractPacket sendBlocking(AbstractPacket packet) throws Exception
    {
-      try
-      {
-         AbstractPacket response = (AbstractPacket) session.writeAndBlock(packet, 
-               blockingRequestTimeout, blockingRequestTimeUnit);
-         return response;
-      } catch (Throwable t)
-      {
-         IOException ioe = new IOException();
-         ioe.initCause(t);
-         throw ioe;
-      }
+      AbstractPacket response = (AbstractPacket) session.writeAndBlock(packet, 
+                                               blockingRequestTimeout, blockingRequestTimeUnit);
+      return response;
    }
 
    // Inner classes -------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/INVMConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/INVMConnector.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/INVMConnector.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -10,7 +10,7 @@
 
 import java.io.IOException;
 
-import org.jboss.jms.client.remoting.ConsolidatedRemotingConnectionListener;
+import org.jboss.jms.client.api.FailureListener;
 import org.jboss.messaging.core.remoting.NIOConnector;
 import org.jboss.messaging.core.remoting.NIOSession;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
@@ -34,7 +34,7 @@
    private INVMSession session;
 
    private PacketDispatcher serverDispatcher;
- 
+   
    // Static --------------------------------------------------------
 
    // Constructors --------------------------------------------------
@@ -78,16 +78,14 @@
       return INVM + "://" + host + ":" + port;
    }
    
-   public void removeConnectionListener(
-         ConsolidatedRemotingConnectionListener listener)
-   {
+   public void addFailureListener(FailureListener listener)
+   {      
    }
    
-   public void addConnectionListener(
-         ConsolidatedRemotingConnectionListener listener)
-   {
+   public void removeFailureListener(FailureListener listener)
+   {      
    }
-   
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/INVMSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/INVMSession.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/INVMSession.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -10,7 +10,7 @@
 
 import java.util.concurrent.TimeUnit;
 
-import org.jboss.jms.exception.MessagingJMSException;
+import org.jboss.jms.exception.JMSExceptionHelper;
 import org.jboss.messaging.core.remoting.NIOSession;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
 import org.jboss.messaging.core.remoting.PacketSender;
@@ -67,24 +67,17 @@
       return true;
    }
 
-   public void write(final Object object)
+   public void write(final Object object) throws Exception
    {
       assert object instanceof AbstractPacket;
 
       serverDispatcher.dispatch((AbstractPacket) object,
             new PacketSender()
             {
-               public void send(Packet response)
-               {
-                  try
-                  {
-                     serverDispatcher.callFilters(response);
-                     PacketDispatcher.client.dispatch(response, null);
-                  }
-                  catch (MessagingJMSException e)
-                  {
-                     log.warn("An interceptor throwed an exception what caused the packet " + response + " to be ignored", e);
-                  }
+               public void send(Packet response) throws Exception
+               {                  
+                  serverDispatcher.callFilters(response);
+                  PacketDispatcher.client.dispatch(response, null);   
                }
                
                public String getSessionID()
@@ -94,8 +87,7 @@
             });
    }
 
-   public Object writeAndBlock(final AbstractPacket request,
-         long timeout, TimeUnit timeUnit) throws Throwable
+   public Object writeAndBlock(final AbstractPacket request, long timeout, TimeUnit timeUnit) throws Exception
    {
       request.setCorrelationID(correlationCounter++);
       final Packet[] responses = new Packet[1];
@@ -103,18 +95,10 @@
       serverDispatcher.dispatch(request,
             new PacketSender()
             {
-               public void send(Packet response)
+               public void send(Packet response) throws Exception
                {
-                  try
-                  {
-                     serverDispatcher.callFilters(response);
-                     responses[0] = response;
-                  }
-                  catch (MessagingJMSException e)
-                  {
-                     log.warn("An interceptor throwed an exception what caused the packet " + response + " to be ignored", e);
-                     responses[0] = null;
-                  }
+                  serverDispatcher.callFilters(response);
+                  responses[0] = response;
                }
 
                public String getSessionID()

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaConnector.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -16,7 +16,6 @@
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.concurrent.ScheduledExecutorService;
 
@@ -28,7 +27,7 @@
 import org.apache.mina.common.IoServiceListener;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.transport.socket.nio.NioSocketConnector;
-import org.jboss.jms.client.remoting.ConsolidatedRemotingConnectionListener;
+import org.jboss.jms.client.api.FailureListener;
 import org.jboss.messaging.core.remoting.ConnectionExceptionListener;
 import org.jboss.messaging.core.remoting.KeepAliveFactory;
 import org.jboss.messaging.core.remoting.NIOConnector;
@@ -36,8 +35,9 @@
 import org.jboss.messaging.core.remoting.PacketDispatcher;
 import org.jboss.messaging.core.remoting.RemotingConfiguration;
 import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.SetSessionIDMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionSetIDMessage;
 import org.jboss.messaging.util.Logger;
+import org.jboss.messaging.util.MessagingException;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -62,7 +62,7 @@
    private IoSession session;
 
    // FIXME clean up this listener mess
-   private Map<ConsolidatedRemotingConnectionListener, IoServiceListener> listeners = new HashMap<ConsolidatedRemotingConnectionListener, IoServiceListener>();
+   private Map<FailureListener, IoServiceListener> listeners = new HashMap<FailureListener, IoServiceListener>();
    private ConnectionExceptionListener listener;
 
    // Static --------------------------------------------------------
@@ -117,7 +117,7 @@
          throw new IOException("Cannot connect to " + address.toString());
       }
       this.session = future.getSession();
-      AbstractPacket packet = new SetSessionIDMessage(Long.toString(session
+      AbstractPacket packet = new SessionSetIDMessage(Long.toString(session
             .getId()));
       session.write(packet);
 
@@ -144,8 +144,7 @@
       return closed;
    }
 
-   public void addConnectionListener(
-         final ConsolidatedRemotingConnectionListener listener)
+   public void addFailureListener(final FailureListener listener)
    {
       assert listener != null;
       assert connector != null;
@@ -158,8 +157,7 @@
          log.trace("added listener " + listener + " to " + this);
    }
 
-   public void removeConnectionListener(
-         ConsolidatedRemotingConnectionListener listener)
+   public void removeFailureListener(FailureListener listener)
    {
       assert listener != null;
       assert connector != null;
@@ -190,11 +188,11 @@
       if (listener != null)
          listener.handleConnectionException(cause, remoteSessionID);
       
-      Iterator<ConsolidatedRemotingConnectionListener> set = listeners.keySet().iterator();
-      while (set.hasNext())
+      for (FailureListener listener: listeners.keySet())
       {
-         ConsolidatedRemotingConnectionListener listener = set.next();
-         listener.handleConnectionException(cause);
+         MessagingException me = new MessagingException(MessagingException.CONNECTION_TIMEDOUT, "Timed out");
+         
+         listener.onFailure(me);
       }
    }
 
@@ -218,10 +216,9 @@
       private final Logger log = Logger
             .getLogger(IoServiceListenerAdapter.class);
 
-      private final ConsolidatedRemotingConnectionListener listener;
+      private final FailureListener listener;
 
-      private IoServiceListenerAdapter(
-            ConsolidatedRemotingConnectionListener listener)
+      private IoServiceListenerAdapter(FailureListener listener)
       {
          this.listener = listener;
       }
@@ -254,8 +251,10 @@
       {
          log.warn("destroyed session " + session);
 
-         Throwable t = new Throwable("MINA session has been destroyed");
-         listener.handleConnectionException(t);
+         MessagingException me =
+            new MessagingException(MessagingException.INTERNAL_ERROR, "MINA session has been destroyed");
+         
+         listener.onFailure(me);
       }
    }
 }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaHandler.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -13,7 +13,7 @@
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.keepalive.KeepAliveTimeoutException;
 import org.apache.mina.filter.reqres.Response;
-import org.jboss.jms.exception.MessagingJMSException;
+import org.jboss.jms.exception.JMSExceptionHelper;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
 import org.jboss.messaging.core.remoting.PacketSender;
 import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
@@ -98,18 +98,10 @@
       AbstractPacket packet = (AbstractPacket) message;
       PacketSender sender = new PacketSender()
       {
-         public void send(Packet p)
+         public void send(Packet p) throws Exception
          {
-            try
-            {
-               dispatcher.callFilters(p);
-               session.write(p);
-            }
-            catch (MessagingJMSException e)
-            {
-               log.warn("An interceptor throwed an exception what caused the packet " + p + " to be ignored", e);
-            }
-            
+            dispatcher.callFilters(p);
+            session.write(p);            
          }
          
          public String getSessionID()

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaSession.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/MinaSession.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -54,8 +54,7 @@
       session.write(object);
    }
 
-   public Object writeAndBlock(AbstractPacket packet, long timeout,
-         TimeUnit timeUnit) throws Throwable
+   public Object writeAndBlock(AbstractPacket packet, long timeout, TimeUnit timeUnit) throws Exception
    {
       packet.setCorrelationID(correlationCounter++);
       Request req = new Request(packet.getCorrelationID(), packet, timeout, timeUnit);

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -12,108 +12,106 @@
 
 import org.apache.mina.filter.codec.demux.DemuxingProtocolCodecFactory;
 import org.jboss.messaging.core.remoting.codec.AbstractPacketCodec;
-import org.jboss.messaging.core.remoting.codec.AddTemporaryDestinationMessageCodec;
-import org.jboss.messaging.core.remoting.codec.BrowserHasNextMessageResponseCodec;
-import org.jboss.messaging.core.remoting.codec.BrowserNextMessageBlockRequestCodec;
-import org.jboss.messaging.core.remoting.codec.BrowserNextMessageBlockResponseCodec;
-import org.jboss.messaging.core.remoting.codec.BrowserNextMessageResponseCodec;
+import org.jboss.messaging.core.remoting.codec.SessionBindingQueryMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionBindingQueryResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionBrowserHasNextMessageResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionBrowserNextMessageBlockMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionBrowserNextMessageBlockResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionBrowserNextMessageResponseMessageCodec;
 import org.jboss.messaging.core.remoting.codec.BytesPacketCodec;
-import org.jboss.messaging.core.remoting.codec.ConnectionFactoryCreateConnectionRequestCodec;
-import org.jboss.messaging.core.remoting.codec.ConnectionFactoryCreateConnectionResponseCodec;
+import org.jboss.messaging.core.remoting.codec.CreateConnectionMessageCodec;
+import org.jboss.messaging.core.remoting.codec.CreateConnectionResponseMessageCodec;
 import org.jboss.messaging.core.remoting.codec.ConsumerChangeRateMessageCodec;
-import org.jboss.messaging.core.remoting.codec.CreateBrowserRequestCodec;
-import org.jboss.messaging.core.remoting.codec.CreateBrowserResponseCodec;
-import org.jboss.messaging.core.remoting.codec.CreateConsumerRequestCodec;
-import org.jboss.messaging.core.remoting.codec.CreateConsumerResponseCodec;
-import org.jboss.messaging.core.remoting.codec.CreateDestinationRequestCodec;
-import org.jboss.messaging.core.remoting.codec.CreateDestinationResponseCodec;
-import org.jboss.messaging.core.remoting.codec.CreateSessionRequestCodec;
-import org.jboss.messaging.core.remoting.codec.CreateSessionResponseCodec;
-import org.jboss.messaging.core.remoting.codec.DeleteTemporaryDestinationMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionCreateBrowserMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionCreateBrowserResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionCreateConsumerMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionCreateConsumerResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.ConnectionCreateSessionMessageCodec;
+import org.jboss.messaging.core.remoting.codec.ConnectionCreateSessionResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionDeleteQueueMessageCodec;
 import org.jboss.messaging.core.remoting.codec.DeliverMessageCodec;
-import org.jboss.messaging.core.remoting.codec.GetClientIDResponseCodec;
-import org.jboss.messaging.core.remoting.codec.JMSExceptionMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionQueueQueryMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionQueueQueryResponseMessageCodec;
 import org.jboss.messaging.core.remoting.codec.RemotingBuffer;
 import org.jboss.messaging.core.remoting.codec.SessionAcknowledgeMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionAddAddressMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionCancelMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionCreateQueueMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionRemoveAddressMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionSendMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXACommitMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXAEndMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXAForgetMessageCodec;
-import org.jboss.messaging.core.remoting.codec.SessionXAGetInDoubtXidsResponseCodec;
-import org.jboss.messaging.core.remoting.codec.SessionXAGetTimeoutResponseCodec;
+import org.jboss.messaging.core.remoting.codec.SessionXAGetInDoubtXidsResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionXAGetTimeoutResponseMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXAJoinMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXAPrepareMessageCodec;
-import org.jboss.messaging.core.remoting.codec.SessionXAResponseCodec;
+import org.jboss.messaging.core.remoting.codec.SessionXAResponseMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXAResumeMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXARollbackMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXASetTimeoutMessageCodec;
-import org.jboss.messaging.core.remoting.codec.SessionXASetTimeoutResponseCodec;
+import org.jboss.messaging.core.remoting.codec.SessionXASetTimeoutResponseMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXAStartMessageCodec;
-import org.jboss.messaging.core.remoting.codec.SetClientIDMessageCodec;
-import org.jboss.messaging.core.remoting.codec.SetSessionIDMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionSetIDMessageCodec;
 import org.jboss.messaging.core.remoting.codec.TextPacketCodec;
-import org.jboss.messaging.core.remoting.codec.UnsubscribeMessageCodec;
 import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.AddTemporaryDestinationMessage;
-import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageRequest;
-import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageResponse;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockRequest;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockResponse;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageRequest;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageResponse;
-import org.jboss.messaging.core.remoting.wireformat.BrowserResetMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBindingQueryMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBindingQueryResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserHasNextMessageMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserHasNextMessageResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageBlockMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageBlockResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserResetMessage;
 import org.jboss.messaging.core.remoting.wireformat.BytesPacket;
 import org.jboss.messaging.core.remoting.wireformat.CloseMessage;
-import org.jboss.messaging.core.remoting.wireformat.ClosingMessage;
 import org.jboss.messaging.core.remoting.wireformat.ConsumerChangeRateMessage;
-import org.jboss.messaging.core.remoting.wireformat.CreateBrowserRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateBrowserResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateBrowserMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateBrowserResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.CreateConnectionRequest;
 import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateConsumerRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateConsumerResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateDestinationRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateDestinationResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateSessionRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateSessionResponse;
-import org.jboss.messaging.core.remoting.wireformat.DeleteTemporaryDestinationMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateConsumerMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateConsumerResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateQueueMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionCreateSessionMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionCreateSessionResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionDeleteQueueMessage;
 import org.jboss.messaging.core.remoting.wireformat.DeliverMessage;
-import org.jboss.messaging.core.remoting.wireformat.GetClientIDRequest;
-import org.jboss.messaging.core.remoting.wireformat.GetClientIDResponse;
-import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
 import org.jboss.messaging.core.remoting.wireformat.NullPacket;
 import org.jboss.messaging.core.remoting.wireformat.PacketType;
 import org.jboss.messaging.core.remoting.wireformat.Ping;
 import org.jboss.messaging.core.remoting.wireformat.Pong;
+import org.jboss.messaging.core.remoting.wireformat.SessionQueueQueryMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionQueueQueryResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionAcknowledgeMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionAddAddressMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionCancelMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionCommitMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionRecoverMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionRemoveAddressMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionRollbackMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionSendMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXACommitMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAEndMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAForgetMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsRequest;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAJoinMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAPrepareMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAResumeMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXARollbackMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAStartMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXASuspendMessage;
-import org.jboss.messaging.core.remoting.wireformat.SetClientIDMessage;
-import org.jboss.messaging.core.remoting.wireformat.SetSessionIDMessage;
-import org.jboss.messaging.core.remoting.wireformat.StartConnectionMessage;
-import org.jboss.messaging.core.remoting.wireformat.StopConnectionMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionSetIDMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionStartMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionStopMessage;
 import org.jboss.messaging.core.remoting.wireformat.TextPacket;
-import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
 import org.jboss.messaging.util.Logger;
 
 /**
@@ -136,55 +134,40 @@
    {
       addCodecForEmptyPacket(NULL, NullPacket.class);
 
-      addCodec(JMSExceptionMessage.class, JMSExceptionMessageCodec.class);
-
       // TextPacket are for testing purpose only!
       addCodec(TextPacket.class, TextPacketCodec.class);
       addCodec(BytesPacket.class, BytesPacketCodec.class);
 
       addCodecForEmptyPacket(PING, Ping.class);
       addCodecForEmptyPacket(PONG, Pong.class);
-      addCodec(SetSessionIDMessage.class, SetSessionIDMessageCodec.class);
+      addCodec(SessionSetIDMessage.class, SessionSetIDMessageCodec.class);
 
       addCodec(CreateConnectionRequest.class,
-            ConnectionFactoryCreateConnectionRequestCodec.class);
+            CreateConnectionMessageCodec.class);
 
       addCodec(CreateConnectionResponse.class,
-            ConnectionFactoryCreateConnectionResponseCodec.class);
+            CreateConnectionResponseMessageCodec.class);
 
-      addCodec(CreateSessionRequest.class, CreateSessionRequestCodec.class);
+      addCodec(ConnectionCreateSessionMessage.class, ConnectionCreateSessionMessageCodec.class);
 
-      addCodec(CreateSessionResponse.class, CreateSessionResponseCodec.class);
+      addCodec(ConnectionCreateSessionResponseMessage.class, ConnectionCreateSessionResponseMessageCodec.class);
 
-      addCodecForEmptyPacket(PacketType.REQ_GETCLIENTID,
-            GetClientIDRequest.class);
-
-      addCodec(GetClientIDResponse.class, GetClientIDResponseCodec.class);
-
-      addCodec(SetClientIDMessage.class, SetClientIDMessageCodec.class);
-
       addCodec(SessionSendMessage.class, SessionSendMessageCodec.class);
 
-      addCodec(CreateConsumerRequest.class, CreateConsumerRequestCodec.class);
+      addCodec(SessionCreateConsumerMessage.class, SessionCreateConsumerMessageCodec.class);
 
-      addCodec(CreateDestinationRequest.class,
-            CreateDestinationRequestCodec.class);
+      addCodec(SessionCreateConsumerResponseMessage.class, SessionCreateConsumerResponseMessageCodec.class);
 
-      addCodec(CreateDestinationResponse.class,
-            CreateDestinationResponseCodec.class);
+      addCodec(SessionCreateBrowserMessage.class, SessionCreateBrowserMessageCodec.class);
 
-      addCodec(CreateConsumerResponse.class, CreateConsumerResponseCodec.class);
+      addCodec(SessionCreateBrowserResponseMessage.class, SessionCreateBrowserResponseMessageCodec.class);
 
-      addCodec(CreateBrowserRequest.class, CreateBrowserRequestCodec.class);
+      addCodecForEmptyPacket(PacketType.CONN_START,
+            ConnectionStartMessage.class);
 
-      addCodec(CreateBrowserResponse.class, CreateBrowserResponseCodec.class);
+      addCodecForEmptyPacket(PacketType.CONN_STOP,
+            ConnectionStopMessage.class);
 
-      addCodecForEmptyPacket(PacketType.MSG_STARTCONNECTION,
-            StartConnectionMessage.class);
-
-      addCodecForEmptyPacket(PacketType.MSG_STOPCONNECTION,
-            StopConnectionMessage.class);
-
       addCodec(ConsumerChangeRateMessage.class, ConsumerChangeRateMessageCodec.class);
 
       addCodec(DeliverMessage.class, DeliverMessageCodec.class);
@@ -195,65 +178,55 @@
       addCodec(SessionCancelMessage.class,
             SessionCancelMessageCodec.class);
       
-      addCodecForEmptyPacket(PacketType.MSG_COMMIT, SessionCommitMessage.class);
+      addCodecForEmptyPacket(PacketType.SESS_COMMIT, SessionCommitMessage.class);
       
-      addCodecForEmptyPacket(PacketType.MSG_ROLLBACK, SessionRollbackMessage.class);
+      addCodecForEmptyPacket(PacketType.SESS_ROLLBACK, SessionRollbackMessage.class);
 
-      addCodecForEmptyPacket(PacketType.MSG_CLOSE, CloseMessage.class);
+      addCodecForEmptyPacket(PacketType.CLOSE, CloseMessage.class);
       
-      addCodecForEmptyPacket(PacketType.MSG_CLOSING, ClosingMessage.class);
-      
-      addCodecForEmptyPacket(PacketType.MSG_RECOVER, SessionRecoverMessage.class);
+      addCodecForEmptyPacket(PacketType.SESS_RECOVER, SessionRecoverMessage.class);
             
-      addCodecForEmptyPacket(PacketType.MSG_BROWSER_RESET,
-            BrowserResetMessage.class);
+      addCodecForEmptyPacket(PacketType.SESS_BROWSER_RESET,
+            SessionBrowserResetMessage.class);
 
-      addCodecForEmptyPacket(PacketType.REQ_BROWSER_HASNEXTMESSAGE,
-            BrowserHasNextMessageRequest.class);
+      addCodecForEmptyPacket(PacketType.SESS_BROWSER_HASNEXTMESSAGE,
+            SessionBrowserHasNextMessageMessage.class);
 
-      addCodec(BrowserHasNextMessageResponse.class,
-            BrowserHasNextMessageResponseCodec.class);
+      addCodec(SessionBrowserHasNextMessageResponseMessage.class,
+            SessionBrowserHasNextMessageResponseMessageCodec.class);
 
-      addCodecForEmptyPacket(PacketType.REQ_BROWSER_NEXTMESSAGE,
-            BrowserNextMessageRequest.class);
+      addCodecForEmptyPacket(PacketType.SESS_BROWSER_NEXTMESSAGE,
+            SessionBrowserNextMessageMessage.class);
 
-      addCodec(BrowserNextMessageResponse.class,
-            BrowserNextMessageResponseCodec.class);
+      addCodec(SessionBrowserNextMessageResponseMessage.class,
+            SessionBrowserNextMessageResponseMessageCodec.class);
 
-      addCodec(BrowserNextMessageBlockRequest.class,
-            BrowserNextMessageBlockRequestCodec.class);
+      addCodec(SessionBrowserNextMessageBlockMessage.class,
+            SessionBrowserNextMessageBlockMessageCodec.class);
 
-      addCodec(BrowserNextMessageBlockResponse.class,
-            BrowserNextMessageBlockResponseCodec.class);
+      addCodec(SessionBrowserNextMessageBlockResponseMessage.class,
+            SessionBrowserNextMessageBlockResponseMessageCodec.class);
 
-      addCodec(UnsubscribeMessage.class, UnsubscribeMessageCodec.class);
-
-      addCodec(AddTemporaryDestinationMessage.class,
-            AddTemporaryDestinationMessageCodec.class);
-
-      addCodec(DeleteTemporaryDestinationMessage.class,
-            DeleteTemporaryDestinationMessageCodec.class);
-      
       addCodec(SessionXACommitMessage.class, SessionXACommitMessageCodec.class);
       
       addCodec(SessionXAEndMessage.class, SessionXAEndMessageCodec.class);
       
       addCodec(SessionXAForgetMessage.class, SessionXAForgetMessageCodec.class);
       
-      addCodecForEmptyPacket(PacketType.REQ_XA_INDOUBT_XIDS,
-            SessionXAGetInDoubtXidsRequest.class);
+      addCodecForEmptyPacket(PacketType.SESS_XA_INDOUBT_XIDS,
+            SessionXAGetInDoubtXidsMessage.class);
       
-      addCodec(SessionXAGetInDoubtXidsResponse.class, SessionXAGetInDoubtXidsResponseCodec.class);
+      addCodec(SessionXAGetInDoubtXidsResponseMessage.class, SessionXAGetInDoubtXidsResponseMessageCodec.class);
       
-      addCodecForEmptyPacket(PacketType.MSG_XA_GET_TIMEOUT, SessionXAGetTimeoutMessage.class);
+      addCodecForEmptyPacket(PacketType.SESS_XA_GET_TIMEOUT, SessionXAGetTimeoutMessage.class);
       
-      addCodec(SessionXAGetTimeoutResponse.class, SessionXAGetTimeoutResponseCodec.class);
+      addCodec(SessionXAGetTimeoutResponseMessage.class, SessionXAGetTimeoutResponseMessageCodec.class);
       
       addCodec(SessionXAJoinMessage.class, SessionXAJoinMessageCodec.class);
       
       addCodec(SessionXAPrepareMessage.class, SessionXAPrepareMessageCodec.class);
       
-      addCodec(SessionXAResponse.class, SessionXAResponseCodec.class);
+      addCodec(SessionXAResponseMessage.class, SessionXAResponseMessageCodec.class);
       
       addCodec(SessionXAResumeMessage.class, SessionXAResumeMessageCodec.class);
       
@@ -261,11 +234,27 @@
       
       addCodec(SessionXASetTimeoutMessage.class, SessionXASetTimeoutMessageCodec.class);
       
-      addCodec(SessionXASetTimeoutResponse.class, SessionXASetTimeoutResponseCodec.class);
+      addCodec(SessionXASetTimeoutResponseMessage.class, SessionXASetTimeoutResponseMessageCodec.class);
       
       addCodec(SessionXAStartMessage.class, SessionXAStartMessageCodec.class);
       
-      addCodecForEmptyPacket(PacketType.MSG_XA_SUSPEND, SessionXASuspendMessage.class);
+      addCodecForEmptyPacket(PacketType.SESS_XA_SUSPEND, SessionXASuspendMessage.class);
+      
+      addCodec(SessionRemoveAddressMessage.class, SessionRemoveAddressMessageCodec.class);
+      
+      addCodec(SessionCreateQueueMessage.class, SessionCreateQueueMessageCodec.class);
+      
+      addCodec(SessionQueueQueryMessage.class, SessionQueueQueryMessageCodec.class);
+      
+      addCodec(SessionQueueQueryResponseMessage.class, SessionQueueQueryResponseMessageCodec.class);
+      
+      addCodec(SessionAddAddressMessage.class, SessionAddAddressMessageCodec.class);
+      
+      addCodec(SessionBindingQueryMessage.class, SessionBindingQueryMessageCodec.class);
+      
+      addCodec(SessionBindingQueryResponseMessage.class, SessionBindingQueryResponseMessageCodec.class);
+      
+      addCodec(SessionDeleteQueueMessage.class, SessionDeleteQueueMessageCodec.class);
    }
 
    // Public --------------------------------------------------------

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/AddTemporaryDestinationMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/AddTemporaryDestinationMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/AddTemporaryDestinationMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import org.jboss.messaging.core.Destination;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class AddTemporaryDestinationMessage extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final Destination destination;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public AddTemporaryDestinationMessage(Destination destination)
-   {
-      super(PacketType.MSG_ADDTEMPORARYDESTINATION);
-
-      assert destination != null;
-
-      this.destination = destination;
-   }
-
-   // Public --------------------------------------------------------
-
-   public Destination getDestination()
-   {
-      return destination;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", destination=" + destination + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserHasNextMessageRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserHasNextMessageRequest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserHasNextMessageRequest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_HASNEXTMESSAGE;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class BrowserHasNextMessageRequest extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public BrowserHasNextMessageRequest()
-   {
-    super(REQ_BROWSER_HASNEXTMESSAGE);
-   }
-
-   // Public --------------------------------------------------------
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserHasNextMessageResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserHasNextMessageResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserHasNextMessageResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_HASNEXTMESSAGE;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class BrowserHasNextMessageResponse extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final boolean hasNext;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public BrowserHasNextMessageResponse(boolean hasNext)
-   {
-      super(RESP_BROWSER_HASNEXTMESSAGE);
-
-      this.hasNext = hasNext;
-   }
-
-   // Public --------------------------------------------------------
-
-   public boolean hasNext()
-   {
-      return hasNext;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", hasNext=" + hasNext + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_NEXTMESSAGEBLOCK;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class BrowserNextMessageBlockRequest extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final long maxMessages;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public BrowserNextMessageBlockRequest(long maxMessages)
-   {
-      super(REQ_BROWSER_NEXTMESSAGEBLOCK);
-
-      this.maxMessages = maxMessages;
-   }
-
-   // Public --------------------------------------------------------
-
-   public long getMaxMessages()
-   {
-      return maxMessages;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", maxMessages=" + maxMessages + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_NEXTMESSAGEBLOCK;
-
-import java.util.Arrays;
-
-import org.jboss.messaging.core.Message;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- */
-public class BrowserNextMessageBlockResponse extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final Message[] messages;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public BrowserNextMessageBlockResponse(Message[] messages)
-   {
-      super(RESP_BROWSER_NEXTMESSAGEBLOCK);
-
-      assert messages != null;
-
-      this.messages = messages;
-   }
-
-   // Public --------------------------------------------------------
-
-   public Message[] getMessages()
-   {
-      return messages;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", messages=" + Arrays.asList(messages) + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageRequest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageRequest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_NEXTMESSAGE;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class BrowserNextMessageRequest extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public BrowserNextMessageRequest()
-   {
-      super(REQ_BROWSER_NEXTMESSAGE);
-   }
-
-   // Public --------------------------------------------------------
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,58 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import org.jboss.messaging.core.Message;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- */
-public class BrowserNextMessageResponse extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final Message message;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public BrowserNextMessageResponse(Message message)
-   {
-      super(PacketType.RESP_BROWSER_NEXTMESSAGE);
-
-      assert message != null;
-
-      this.message = message;
-   }
-
-   // Public --------------------------------------------------------
-
-   public Message getMessage()
-   {
-      return message;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", message=" + message + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserResetMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserResetMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserResetMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_BROWSER_RESET;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public class BrowserResetMessage extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public BrowserResetMessage()
-   {
-    super(MSG_BROWSER_RESET);
-   }
-
-   // Public --------------------------------------------------------
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CloseMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CloseMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CloseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -6,7 +6,7 @@
  */
 package org.jboss.messaging.core.remoting.wireformat;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CLOSE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CLOSE;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -26,7 +26,7 @@
 
    public CloseMessage()
    {
-      super(MSG_CLOSE);
+      super(CLOSE);
    }
    
    // Public --------------------------------------------------------

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ClosingMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ClosingMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ClosingMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- * 
- * @version <tt>$Revision$</tt>
- */
-public class ClosingMessage extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public ClosingMessage()
-   {
-      super(PacketType.MSG_CLOSING);
-   }
-
-   // Public --------------------------------------------------------
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionCreateSessionMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateSessionRequest.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionCreateSessionMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionCreateSessionMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONN_CREATESESSION;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class ConnectionCreateSessionMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+   
+   private final boolean xa;
+   
+   private final boolean autoCommitSends;
+   
+   private final boolean autoCommitAcks;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public ConnectionCreateSessionMessage(boolean xa, boolean autoCommitSends, boolean autoCommitAcks)
+   {
+      super(CONN_CREATESESSION);
+
+      this.xa = xa;
+      
+      this.autoCommitSends = autoCommitSends;
+      
+      this.autoCommitAcks = autoCommitAcks;
+   }
+
+   // Public --------------------------------------------------------
+
+   public boolean isXA()
+   {
+      return xa;
+   }
+
+   public boolean isAutoCommitSends()
+   {
+      return this.autoCommitSends;
+   }
+   
+   public boolean isAutoCommitAcks()
+   {
+      return this.autoCommitAcks;
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionCreateSessionResponseMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateSessionResponse.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionCreateSessionResponseMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionCreateSessionResponseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.Assert.assertValidID;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class ConnectionCreateSessionResponseMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final String sessionID;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public ConnectionCreateSessionResponseMessage(String sessionID)
+   {
+      super(PacketType.CONN_CREATESESSION_RESP);
+
+      assertValidID(sessionID);
+
+      this.sessionID = sessionID;
+   }
+
+   // Public --------------------------------------------------------
+
+   public String getSessionID()
+   {
+      return sessionID;
+   }
+
+
+   @Override
+   public String toString()
+   {
+      return getParentString() + ", sessionID=" + sessionID
+            + "]";
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionStartMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/StartConnectionMessage.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionStartMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionStartMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONN_START;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class ConnectionStartMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public ConnectionStartMessage()
+   {
+      super(CONN_START);
+   }
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionStopMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/StopConnectionMessage.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionStopMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConnectionStopMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONN_STOP;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class ConnectionStopMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public ConnectionStopMessage()
+   {
+      super(CONN_STOP);
+   }
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConsumerChangeRateMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConsumerChangeRateMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/ConsumerChangeRateMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -6,7 +6,7 @@
  */
 package org.jboss.messaging.core.remoting.wireformat;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CHANGERATE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONS_CHANGERATE;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -28,7 +28,7 @@
 
    public ConsumerChangeRateMessage(float rate)
    {
-      super(MSG_CHANGERATE);
+      super(CONS_CHANGERATE);
 
       this.rate = rate;
    }

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateBrowserRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateBrowserRequest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateBrowserRequest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATEBROWSER;
-
-import org.jboss.messaging.core.Destination;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class CreateBrowserRequest extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final Destination destination;
-   private final String selector;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateBrowserRequest(Destination destination, String selector)
-   {
-      super(REQ_CREATEBROWSER);
-
-      assert destination != null;
-
-      this.destination = destination;
-      this.selector = selector;
-   }
-
-   // Public --------------------------------------------------------
-
-   public Destination getDestination()
-   {
-      return destination;
-   }
-
-   public String getSelector()
-   {
-      return selector;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", destination=" + destination + ", selector="
-            + selector + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateBrowserResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateBrowserResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateBrowserResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.Assert.assertValidID;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATEBROWSER;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class CreateBrowserResponse extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final String browserID;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateBrowserResponse(String browserID)
-   {
-      super(RESP_CREATEBROWSER);
-
-      assertValidID(browserID);
-
-      this.browserID = browserID;
-   }
-
-   // Public --------------------------------------------------------
-
-   public String getBrowserID()
-   {
-      return browserID;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", browserID=" + browserID + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConnectionRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConnectionRequest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConnectionRequest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -7,7 +7,7 @@
 package org.jboss.messaging.core.remoting.wireformat;
 
 import static org.jboss.messaging.core.remoting.Assert.assertValidID;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONNECTION;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CREATECONNECTION;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -28,8 +28,6 @@
    private final String username;
    private final String password;
    private int prefetchSize;
-   private int dupsOKBatchSize;
-   private String clientID;
 
    // Static --------------------------------------------------------
 
@@ -37,9 +35,9 @@
 
    public CreateConnectionRequest(byte version,
          String remotingSessionID, String clientVMID, String username, String password,
-         int prefetchSize, int dupsOKBatchSize, String clientID)
+         int prefetchSize)
    {
-      super(REQ_CREATECONNECTION);
+      super(CREATECONNECTION);
 
       assertValidID(remotingSessionID);
       assertValidID(clientVMID);
@@ -50,8 +48,6 @@
       this.username = username;
       this.password = password;
       this.prefetchSize = prefetchSize;
-      this.dupsOKBatchSize = dupsOKBatchSize;
-      this.clientID = clientID;
    }
 
    // Public --------------------------------------------------------
@@ -104,28 +100,6 @@
       this.prefetchSize = prefetchSize;
    }
 
-   public int getDupsOKBatchSize()
-   {
-      return dupsOKBatchSize;
-   }
-
-   public void setDupsOKBatchSize(int dupsOKBatchSize)
-   {
-      this.dupsOKBatchSize = dupsOKBatchSize;
-   }
-
-   public String getClientID()
-   {
-      return clientID;
-   }
-
-   public void setClientID(String clientID)
-   {
-      this.clientID = clientID;
-   }
-
-   // Package protected ---------------------------------------------
-
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConnectionResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConnectionResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConnectionResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -7,7 +7,7 @@
 package org.jboss.messaging.core.remoting.wireformat;
 
 import static org.jboss.messaging.core.remoting.Assert.assertValidID;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATECONNECTION;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CREATECONNECTION_RESP;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -29,7 +29,7 @@
 
    public CreateConnectionResponse(String connectionID)
    {
-      super(RESP_CREATECONNECTION);
+      super(CREATECONNECTION_RESP);
 
       assertValidID(connectionID);
 

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConsumerRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConsumerRequest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConsumerRequest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,94 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import org.jboss.messaging.core.Destination;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- * 
- * @version <tt>$Revision$</tt>
- */
-public class CreateConsumerRequest extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final Destination destination;
-   private final String selector;
-   private final boolean noLocal;
-   private final String subscriptionName;
-   private final boolean connectionConsumer;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateConsumerRequest(Destination destination, String selector,
-         boolean noLocal, String subscriptionName, boolean connectionConsumer)
-   {
-      super(PacketType.REQ_CREATECONSUMER);
-
-      assert destination != null;
-
-      this.destination = destination;
-      this.selector = selector;
-      this.noLocal = noLocal;
-      this.subscriptionName = subscriptionName;
-      this.connectionConsumer = connectionConsumer;
-   }
-
-   // Public --------------------------------------------------------
-
-   public Destination getDestination()
-   {
-      return destination;
-   }
-
-   public String getSelector()
-   {
-      return selector;
-   }
-
-   public boolean isNoLocal()
-   {
-      return noLocal;
-   }
-
-   public String getSubscriptionName()
-   {
-      return subscriptionName;
-   }
-
-   public boolean isConnectionConsumer()
-   {
-      return connectionConsumer;
-   }
-
-   @Override
-   public String toString()
-   {
-      StringBuffer buff = new StringBuffer(getParentString());
-      buff.append(", destination=" + destination);
-      buff.append(", selector=" + selector);
-      buff.append(", noLocal=" + noLocal);
-      buff.append(", subName=" + subscriptionName);
-      buff.append(", connectionConsumer=" + connectionConsumer);
-      buff.append("]");
-      return buff.toString();
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConsumerResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConsumerResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConsumerResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATECONSUMER;
-
-import org.jboss.messaging.core.remoting.Assert;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- * 
- * @version <tt>$Revision$</tt>
- */
-public class CreateConsumerResponse extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final String consumerID;
-   private final int bufferSize;
-   private final int maxDeliveries;
-   private final long redeliveryDelay;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateConsumerResponse(String consumerID, int bufferSize,
-         int maxDeliveries, long redeliveryDelay)
-   {
-      super(RESP_CREATECONSUMER);
-
-      Assert.assertValidID(consumerID);
-
-      this.consumerID = consumerID;
-      this.bufferSize = bufferSize;
-      this.maxDeliveries = maxDeliveries;
-      this.redeliveryDelay = redeliveryDelay;
-   }
-
-   // Public --------------------------------------------------------
-
-   public String getConsumerID()
-   {
-      return consumerID;
-   }
-
-   public int getBufferSize()
-   {
-      return bufferSize;
-   }
-
-   public int getMaxDeliveries()
-   {
-      return maxDeliveries;
-   }
-
-   public long getRedeliveryDelay()
-   {
-      return redeliveryDelay;
-   }
-
-   @Override
-   public String toString()
-   {
-      StringBuffer buf = new StringBuffer(getParentString());
-      buf.append(", consumerID=" + consumerID);
-      buf.append(", bufferSize=" + bufferSize);
-      buf.append(", maxDeliveries=" + maxDeliveries);
-      buf.append(", redeliveryDelay=" + redeliveryDelay);
-      buf.append("]");
-      return buf.toString();
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateDestinationRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateDestinationRequest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateDestinationRequest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATEDESTINATION;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class CreateDestinationRequest extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final String name;
-   private final boolean isQueue;
-   
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateDestinationRequest(String name, boolean isQueue)
-   {
-      super(REQ_CREATEDESTINATION);
-
-      assert name != null;
-      assert name.length() > 0;
-
-      this.name = name;
-      this.isQueue = isQueue;
-   }
-
-   // Public --------------------------------------------------------
-
-   public String getName()
-   {
-      return name;
-   }
-   
-   public boolean isQueue()
-   {
-      return isQueue;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", name=" + name + ", isQueue=" + isQueue + "]";
-   }
-   
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateDestinationResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateDestinationResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateDestinationResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,61 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATEDESTINATION;
-
-import org.jboss.jms.destination.JBossDestination;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class CreateDestinationResponse extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final JBossDestination destination;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateDestinationResponse(JBossDestination destination)
-   {
-      super(RESP_CREATEDESTINATION);
-
-      assert destination != null;
-
-      this.destination = destination;
-   }
-
-   // Public --------------------------------------------------------
-
-   public JBossDestination getDestination()
-   {
-      return destination;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", destination=" + destination + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateSessionRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateSessionRequest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateSessionRequest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,75 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATESESSION;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- * 
- * @version <tt>$Revision$</tt>
- */
-public class CreateSessionRequest extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final boolean transacted;
-
-   private final int acknowledgementMode;
-
-   private final boolean xa;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateSessionRequest(boolean transacted, int acknowledgementMode,
-         boolean xa)
-   {
-      super(REQ_CREATESESSION);
-
-      this.transacted = transacted;
-      this.acknowledgementMode = acknowledgementMode;
-      this.xa = xa;
-   }
-
-   // Public --------------------------------------------------------
-
-   public boolean isTransacted()
-   {
-      return transacted;
-   }
-
-   public int getAcknowledgementMode()
-   {
-      return acknowledgementMode;
-   }
-
-   public boolean isXA()
-   {
-      return xa;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", transacted=" + transacted
-            + ", acknowledgementMode=" + acknowledgementMode + ", xa=" + xa
-            + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateSessionResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateSessionResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateSessionResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.Assert.assertValidID;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- * 
- * @version <tt>$Revision$</tt>
- */
-public class CreateSessionResponse extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final String sessionID;
-
-   private final int dupsOKBatchSize;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public CreateSessionResponse(String sessionID, int dupsOKBatchSize)
-   {
-      super(PacketType.RESP_CREATESESSION);
-
-      assertValidID(sessionID);
-
-      this.sessionID = sessionID;
-      this.dupsOKBatchSize = dupsOKBatchSize;
-   }
-
-   // Public --------------------------------------------------------
-
-   public String getSessionID()
-   {
-      return sessionID;
-   }
-
-   public int getDupsOKBatchSize()
-   {
-      return dupsOKBatchSize;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", sessionID=" + sessionID
-            + ", dupsOKBatchSize=" + dupsOKBatchSize + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/DeleteTemporaryDestinationMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/DeleteTemporaryDestinationMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/DeleteTemporaryDestinationMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,61 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_DELETETEMPORARYDESTINATION;
-
-import org.jboss.messaging.core.Destination;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class DeleteTemporaryDestinationMessage extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final Destination destination;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public DeleteTemporaryDestinationMessage(Destination destination)
-   {
-      super(MSG_DELETETEMPORARYDESTINATION);
-
-      assert destination != null;
-
-      this.destination = destination;
-   }
-
-   // Public --------------------------------------------------------
-
-   public Destination getDestination()
-   {
-      return destination;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", destination=" + destination + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/DeliverMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/DeliverMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/DeliverMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -6,7 +6,7 @@
  */
 package org.jboss.messaging.core.remoting.wireformat;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_DELIVERMESSAGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_DELIVER;
 
 import org.jboss.messaging.core.Message;
 
@@ -38,7 +38,7 @@
    public DeliverMessage(Message message, long deliveryID,
                          int deliveryCount)
    {
-      super(MSG_DELIVERMESSAGE);
+      super(SESS_DELIVER);
 
       assert message != null;
 

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientIDRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientIDRequest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientIDRequest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETCLIENTID;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- * 
- * @version <tt>$Revision$</tt>
- */
-public class GetClientIDRequest extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public GetClientIDRequest()
-   {
-      super(REQ_GETCLIENTID);
-   }
-
-   // Public --------------------------------------------------------
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientIDResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientIDResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientIDResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETCLIENTID;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- * 
- * @version <tt>$Revision$</tt>
- */
-public class GetClientIDResponse extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final String clientID;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public GetClientIDResponse(String clientID)
-   {
-      super(RESP_GETCLIENTID);
-
-      this.clientID = clientID;
-   }
-
-   // Public --------------------------------------------------------
-
-   public String getClientID()
-   {
-      return clientID;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", clientID=" + clientID + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/JMSExceptionMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/JMSExceptionMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/JMSExceptionMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_JMSEXCEPTION;
-
-import javax.jms.JMSException;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class JMSExceptionMessage extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final JMSException exception;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public JMSExceptionMessage(JMSException exception)
-   {
-      super(MSG_JMSEXCEPTION);
-
-      assert exception != null;
-
-      this.exception = exception;
-   }
-
-   // Public --------------------------------------------------------
-
-   public JMSException getException()
-   {
-      return exception;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", exception= " + exception + "]";
-   }
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/MessagingExceptionMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/JMSExceptionMessage.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/MessagingExceptionMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/MessagingExceptionMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.EXCEPTION;
+
+import org.jboss.messaging.util.MessagingException;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class MessagingExceptionMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final MessagingException exception;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public MessagingExceptionMessage(MessagingException exception)
+   {
+      super(EXCEPTION);
+
+      assert exception != null;
+
+      this.exception = exception;
+   }
+
+   // Public --------------------------------------------------------
+
+   public MessagingException getException()
+   {
+      return exception;
+   }
+
+   @Override
+   public String toString()
+   {
+      return getParentString() + ", exception= " + exception + "]";
+   }
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -13,78 +13,76 @@
  */
 public enum PacketType
 {
-   NULL                           ((byte) 1),
-   MSG_JMSEXCEPTION               ((byte) 2),
-   TEXT                           ((byte) 3),
-   BYTES                          ((byte) 4),
-   PING                           ((byte) 5),
-   PONG                           ((byte) 6),
-   MSG_SETSESSIONID               ((byte) 7),
-
-   // Connection factory
-   REQ_CREATECONNECTION           ((byte)10),
-   RESP_CREATECONNECTION          ((byte)11), 
+   // System
+   NULL                                ((byte)1),
+   TEXT                                ((byte)2),
+   BYTES                               ((byte)3),
+   PING                                ((byte)4),
+   PONG                                ((byte)5),
    
-   // Connection
-   REQ_CREATESESSION              ((byte)20),
-   RESP_CREATESESSION             ((byte)21),
-   MSG_STARTCONNECTION            ((byte)22),
-   MSG_STOPCONNECTION             ((byte)23),
-   REQ_GETCLIENTID                ((byte)24),
-   RESP_GETCLIENTID               ((byte)25),
-   MSG_SETCLIENTID                ((byte)26),
+   // Miscellaneous   
+   EXCEPTION                           ((byte)10),
+   CLOSE                               ((byte)11),
    
-   // Session
-   REQ_CREATECONSUMER             ((byte)40),
-   RESP_CREATECONSUMER            ((byte)41),  
-   REQ_CREATEDESTINATION          ((byte)42),
-   RESP_CREATEDESTINATION         ((byte)43),  
-   MSG_ADDTEMPORARYDESTINATION    ((byte)44),
-   MSG_DELETETEMPORARYDESTINATION ((byte)45),
-   REQ_CREATEBROWSER              ((byte)46),
-   RESP_CREATEBROWSER             ((byte)47),
-   MSG_SENDMESSAGE                ((byte)48),
-   MSG_DELIVERMESSAGE             ((byte)49),  
-   MSG_UNSUBSCRIBE                ((byte)50),
-   MSG_ACKNOWLEDGE                ((byte)51),
-   MSG_RECOVER                    ((byte)52),
-   MSG_COMMIT                     ((byte)53),
-   MSG_ROLLBACK                   ((byte)54),
-   MSG_CANCEL                     ((byte)55),
+   // Server
+   CREATECONNECTION                    ((byte)20),
+   CREATECONNECTION_RESP               ((byte)21),    
    
-   MSG_XA_START                   ((byte)56),
-   MSG_XA_END                     ((byte)57),
-   MSG_XA_COMMIT                  ((byte)58),
-   REQ_XA_PREPARE                 ((byte)59),
-   RESP_XA                        ((byte)60),
-   MSG_XA_ROLLBACK                ((byte)61),
-   MSG_XA_JOIN                    ((byte)62),
-   MSG_XA_SUSPEND                 ((byte)63),
-   MSG_XA_RESUME                  ((byte)64),
-   MSG_XA_FORGET                  ((byte)65),
-   REQ_XA_INDOUBT_XIDS            ((byte)66),
-   RESP_XA_INDOUBT_XIDS           ((byte)67),
-   MSG_XA_SET_TIMEOUT             ((byte)68),
-   MSG_XA_SET_TIMEOUT_RESPONSE    ((byte)69),
-   MSG_XA_GET_TIMEOUT             ((byte)70),
-   MSG_XA_GET_TIMEOUT_RESPONSE    ((byte)71),
-   
-   // ClientConsumer 
-   MSG_CHANGERATE                 ((byte)80),
-   
-   // Browser
-   MSG_BROWSER_RESET              ((byte)90),
-   REQ_BROWSER_HASNEXTMESSAGE     ((byte)91),
-   RESP_BROWSER_HASNEXTMESSAGE    ((byte)92),
-   REQ_BROWSER_NEXTMESSAGEBLOCK   ((byte)93),
-   RESP_BROWSER_NEXTMESSAGEBLOCK  ((byte)94),
-   REQ_BROWSER_NEXTMESSAGE        ((byte)95),
-   RESP_BROWSER_NEXTMESSAGE       ((byte)96),
+   // Connection
+   CONN_CREATESESSION                  ((byte)30),
+   CONN_CREATESESSION_RESP             ((byte)31),
+   CONN_START                          ((byte)32),
+   CONN_STOP                           ((byte)33),
 
-   // Misc
-   MSG_CLOSING                    ((byte)100),  
-   MSG_CLOSE                      ((byte)101);
+   // Session   
+   SESS_SETID                          ((byte)40),   
+   SESS_CREATECONSUMER                 ((byte)41),
+   SESS_CREATECONSUMER_RESP            ((byte)42),   
+   SESS_CREATEBROWSER                  ((byte)43),
+   SESS_CREATEBROWSER_RESP             ((byte)44),
+   SESS_SEND                           ((byte)45),
+   SESS_DELIVER                        ((byte)46),  
+   SESS_ACKNOWLEDGE                    ((byte)47),
+   SESS_RECOVER                        ((byte)48),
+   SESS_COMMIT                         ((byte)49),
+   SESS_ROLLBACK                       ((byte)50),
+   SESS_CANCEL                         ((byte)51),
+   SESS_QUEUEQUERY                     ((byte)52),
+   SESS_QUEUEQUERY_RESP                ((byte)53),
+   SESS_CREATEQUEUE                    ((byte)54),
+   SESS_DELETE_QUEUE                   ((byte)55),   
+   SESS_ADD_ADDRESS                    ((byte)56),
+   SESS_REMOVE_ADDRESS                 ((byte)57),
+   SESS_BINDINGQUERY                   ((byte)58),
+   SESS_BINDINGQUERY_RESP              ((byte)59),  
+   SESS_BROWSER_RESET                  ((byte)60),
+   SESS_BROWSER_HASNEXTMESSAGE         ((byte)61),
+   SESS_BROWSER_HASNEXTMESSAGE_RESP    ((byte)62),
+   SESS_BROWSER_NEXTMESSAGEBLOCK       ((byte)63),
+   SESS_BROWSER_NEXTMESSAGEBLOCK_RESP  ((byte)64),
+   SESS_BROWSER_NEXTMESSAGE            ((byte)65),
+   SESS_BROWSER_NEXTMESSAGE_RESP       ((byte)66),      
+   SESS_XA_START                       ((byte)67),
+   SESS_XA_END                         ((byte)68),
+   SESS_XA_COMMIT                      ((byte)69),
+   SESS_XA_PREPARE                     ((byte)70),
+   SESS_XA_RESP                        ((byte)71),
+   SESS_XA_ROLLBACK                    ((byte)72),
+   SESS_XA_JOIN                        ((byte)73),
+   SESS_XA_SUSPEND                     ((byte)74),
+   SESS_XA_RESUME                      ((byte)75),
+   SESS_XA_FORGET                      ((byte)76),
+   SESS_XA_INDOUBT_XIDS                ((byte)77),
+   SESS_XA_INDOUBT_XIDS_RESP           ((byte)78),
+   SESS_XA_SET_TIMEOUT                 ((byte)79),
+   SESS_XA_SET_TIMEOUT_RESP            ((byte)80),
+   SESS_XA_GET_TIMEOUT                 ((byte)81),
+   SESS_XA_GET_TIMEOUT_RESP            ((byte)82),
+       
+   // Consumer 
+   CONS_CHANGERATE                     ((byte)90);
    
+
    private final byte type;
 
    PacketType(byte type)

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionAcknowledgeMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionAcknowledgeMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionAcknowledgeMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -28,7 +28,7 @@
 
    public SessionAcknowledgeMessage(long deliveryID, boolean allUpTo)
    {
-      super(PacketType.MSG_ACKNOWLEDGE);
+      super(PacketType.SESS_ACKNOWLEDGE);
       
       this.deliveryID = deliveryID;
       

Added: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionAddAddressMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionAddAddressMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionAddAddressMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_ADD_ADDRESS;
+
+
+/**
+ * 
+ * A SessionAddAddressMessage
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionAddAddressMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+   
+   private String address;
+   
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionAddAddressMessage(String address)
+   {
+      super(SESS_ADD_ADDRESS);
+      
+      this.address = address;
+   }
+
+   // Public --------------------------------------------------------
+   
+   public String getAddress()
+   {
+      return address;
+   }
+   
+   @Override
+   public String toString()
+   {
+      return getParentString() + ", address=" + address + "]";
+   }
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+

Added: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBindingQueryMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBindingQueryMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBindingQueryMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+
+/**
+ * 
+ * A SessionQueueQueryMessage
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionBindingQueryMessage extends AbstractPacket
+{
+   private String address;
+
+   public SessionBindingQueryMessage(String address)
+   {
+      super(PacketType.SESS_BINDINGQUERY);
+
+      this.address = address;            
+   }
+
+   public String getAddress()
+   {
+      return address;
+   }
+   
+}

Added: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBindingQueryResponseMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBindingQueryResponseMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBindingQueryResponseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,39 @@
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BINDINGQUERY_RESP;
+
+import java.util.List;
+
+/**
+ * 
+ * A SessionBindingQueryResponseMessage
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionBindingQueryResponseMessage extends AbstractPacket
+{
+   private boolean exists;
+   
+   private List<String> queueNames;
+   
+   public SessionBindingQueryResponseMessage(boolean exists, List<String> queueNames)
+   {
+      super(SESS_BINDINGQUERY_RESP);
+
+      this.exists = exists;
+
+      this.queueNames = queueNames;
+   }
+
+   public boolean isExists()
+   {
+      return exists;
+   }
+
+   public List<String> getQueueNames()
+   {
+      return this.queueNames;
+   }
+
+}

Added: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserHasNextMessageMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserHasNextMessageMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserHasNextMessageMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_HASNEXTMESSAGE;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class SessionBrowserHasNextMessageMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionBrowserHasNextMessageMessage()
+   {
+    super(SESS_BROWSER_HASNEXTMESSAGE);
+   }
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserHasNextMessageResponseMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserHasNextMessageResponseMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserHasNextMessageResponseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_HASNEXTMESSAGE_RESP;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class SessionBrowserHasNextMessageResponseMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final boolean hasNext;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionBrowserHasNextMessageResponseMessage(boolean hasNext)
+   {
+      super(SESS_BROWSER_HASNEXTMESSAGE_RESP);
+
+      this.hasNext = hasNext;
+   }
+
+   // Public --------------------------------------------------------
+
+   public boolean hasNext()
+   {
+      return hasNext;
+   }
+
+   @Override
+   public String toString()
+   {
+      return getParentString() + ", hasNext=" + hasNext + "]";
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageBlockMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageBlockMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageBlockMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_NEXTMESSAGEBLOCK;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class SessionBrowserNextMessageBlockMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final long maxMessages;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionBrowserNextMessageBlockMessage(long maxMessages)
+   {
+      super(SESS_BROWSER_NEXTMESSAGEBLOCK);
+
+      this.maxMessages = maxMessages;
+   }
+
+   // Public --------------------------------------------------------
+
+   public long getMaxMessages()
+   {
+      return maxMessages;
+   }
+
+   @Override
+   public String toString()
+   {
+      return getParentString() + ", maxMessages=" + maxMessages + "]";
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageBlockResponseMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageBlockResponseMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageBlockResponseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_NEXTMESSAGEBLOCK_RESP;
+
+import java.util.Arrays;
+
+import org.jboss.messaging.core.Message;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionBrowserNextMessageBlockResponseMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final Message[] messages;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionBrowserNextMessageBlockResponseMessage(Message[] messages)
+   {
+      super(SESS_BROWSER_NEXTMESSAGEBLOCK_RESP);
+
+      assert messages != null;
+
+      this.messages = messages;
+   }
+
+   // Public --------------------------------------------------------
+
+   public Message[] getMessages()
+   {
+      return messages;
+   }
+
+   @Override
+   public String toString()
+   {
+      return getParentString() + ", messages=" + Arrays.asList(messages) + "]";
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_NEXTMESSAGE;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class SessionBrowserNextMessageMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionBrowserNextMessageMessage()
+   {
+      super(SESS_BROWSER_NEXTMESSAGE);
+   }
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageResponseMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageResponseMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserNextMessageResponseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import org.jboss.messaging.core.Message;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionBrowserNextMessageResponseMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final Message message;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionBrowserNextMessageResponseMessage(Message message)
+   {
+      super(PacketType.SESS_BROWSER_NEXTMESSAGE_RESP);
+
+      assert message != null;
+
+      this.message = message;
+   }
+
+   // Public --------------------------------------------------------
+
+   public Message getMessage()
+   {
+      return message;
+   }
+
+   @Override
+   public String toString()
+   {
+      return getParentString() + ", message=" + message + "]";
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserResetMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserResetMessage.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserResetMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionBrowserResetMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_RESET;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class SessionBrowserResetMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionBrowserResetMessage()
+   {
+    super(SESS_BROWSER_RESET);
+   }
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCancelMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCancelMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCancelMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -6,7 +6,7 @@
  */
 package org.jboss.messaging.core.remoting.wireformat;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CANCEL;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CANCEL;
 
 
 /**
@@ -30,7 +30,7 @@
 
    public SessionCancelMessage(long deliveryID, boolean expired)
    {
-      super(MSG_CANCEL);
+      super(SESS_CANCEL);
       
       this.deliveryID = deliveryID;
       

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCommitMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCommitMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCommitMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -24,7 +24,7 @@
 
    public SessionCommitMessage()
    {
-      super(PacketType.MSG_COMMIT);
+      super(PacketType.SESS_COMMIT);
    }
 
    // Public --------------------------------------------------------

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateBrowserMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateBrowserRequest.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateBrowserMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateBrowserMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATEBROWSER;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class SessionCreateBrowserMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final String queueName;
+   private final String filterString;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionCreateBrowserMessage(String queueName, String filterString)
+   {
+      super(SESS_CREATEBROWSER);
+
+      assert queueName != null;
+
+      this.queueName = queueName;
+      this.filterString = filterString;
+   }
+
+   // Public --------------------------------------------------------
+
+   public String getQueueName()
+   {
+      return queueName;
+   }
+
+   public String getFilterString()
+   {
+      return filterString;
+   }
+
+   @Override
+   public String toString()
+   {
+      return getParentString() + ", queueName=" + queueName + ", filterString="
+            + filterString + "]";
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateBrowserResponseMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateBrowserResponse.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateBrowserResponseMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateBrowserResponseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.Assert.assertValidID;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATEBROWSER_RESP;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class SessionCreateBrowserResponseMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final String browserID;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionCreateBrowserResponseMessage(String browserID)
+   {
+      super(SESS_CREATEBROWSER_RESP);
+
+      assertValidID(browserID);
+
+      this.browserID = browserID;
+   }
+
+   // Public --------------------------------------------------------
+
+   public String getBrowserID()
+   {
+      return browserID;
+   }
+
+   @Override
+   public String toString()
+   {
+      return getParentString() + ", browserID=" + browserID + "]";
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateConsumerMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConsumerRequest.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateConsumerMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateConsumerMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionCreateConsumerMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private String queueName;
+   private String filterString;
+   private boolean noLocal;
+   private boolean autoDeleteQueue;
+      
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionCreateConsumerMessage(String queueName, String filterString, boolean noLocal, boolean autoDeleteQueue)
+   {
+      super(PacketType.SESS_CREATECONSUMER);
+
+      this.queueName = queueName;
+      this.filterString = filterString;
+      this.noLocal = noLocal;
+      this.autoDeleteQueue = autoDeleteQueue;
+   }
+
+   // Public --------------------------------------------------------
+
+   @Override
+   public String toString()
+   {
+      StringBuffer buff = new StringBuffer(getParentString());
+      buff.append(", queueName=" + queueName);
+      buff.append(", filterString=" + filterString);
+      buff.append(", noLocal=" + noLocal);
+      buff.append(", autoDeleteQueue=" + autoDeleteQueue);
+      buff.append("]");
+      return buff.toString();
+   }
+
+   public String getQueueName()
+   {
+      return queueName;
+   }
+
+   public String getFilterString()
+   {
+      return filterString;
+   }
+
+   public boolean isNoLocal()
+   {
+      return noLocal;
+   }
+   
+   public boolean isAutoDeleteQueue()
+   {
+      return autoDeleteQueue;
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateConsumerResponseMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/CreateConsumerResponse.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateConsumerResponseMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateConsumerResponseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATECONSUMER_RESP;
+
+import org.jboss.messaging.core.remoting.Assert;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionCreateConsumerResponseMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final String consumerID;
+   private final int bufferSize;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionCreateConsumerResponseMessage(String consumerID, int bufferSize)
+   {
+      super(SESS_CREATECONSUMER_RESP);
+
+      Assert.assertValidID(consumerID);
+
+      this.consumerID = consumerID;
+      this.bufferSize = bufferSize;
+   }
+
+   // Public --------------------------------------------------------
+
+   public String getConsumerID()
+   {
+      return consumerID;
+   }
+
+   public int getBufferSize()
+   {
+      return bufferSize;
+   }
+
+   @Override
+   public String toString()
+   {
+      StringBuffer buf = new StringBuffer(getParentString());
+      buf.append(", consumerID=" + consumerID);
+      buf.append(", bufferSize=" + bufferSize);
+      buf.append("]");
+      return buf.toString();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateQueueMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateQueueMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionCreateQueueMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATEQUEUE;
+
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionCreateQueueMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private String address;
+   private String queueName;
+   private String filterString;
+   private boolean durable;
+   private boolean temporary;
+   
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionCreateQueueMessage(String address, String queueName, String filterString, boolean durable, boolean temporary)
+   {
+      super(SESS_CREATEQUEUE);
+
+      this.address = address;
+      this.queueName = queueName;
+      this.filterString = filterString;
+      this.durable = durable;
+      this.temporary = temporary;
+   }
+
+   // Public --------------------------------------------------------
+
+   @Override
+   public String toString()
+   {
+      StringBuffer buff = new StringBuffer(getParentString());
+      buff.append(", address=" + address);
+      buff.append(", queueName=" + queueName);
+      buff.append(", filterString=" + filterString);
+      buff.append(", durable=" + durable);
+      buff.append(", temporary=" + temporary);
+      buff.append("]");
+      return buff.toString();
+   }
+   
+   public String getAddress()
+   {
+      return address;
+   }
+
+   public String getQueueName()
+   {
+      return queueName;
+   }
+
+   public String getFilterString()
+   {
+      return filterString;
+   }
+
+   public boolean isDurable()
+   {
+      return durable;
+   }
+   
+   public boolean isTemporary()
+   {
+      return temporary;
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionDeleteQueueMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionDeleteQueueMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionDeleteQueueMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_DELETE_QUEUE;
+
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionDeleteQueueMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private String queueName;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionDeleteQueueMessage(String queueName)
+   {
+      super(SESS_DELETE_QUEUE);
+
+      this.queueName = queueName;
+   }
+
+   // Public --------------------------------------------------------
+
+   @Override
+   public String toString()
+   {
+      StringBuffer buff = new StringBuffer(getParentString());
+      buff.append(", queueName=" + queueName);
+      buff.append("]");
+      return buff.toString();
+   }
+   
+   public String getQueueName()
+   {
+      return queueName;
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Added: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionQueueQueryMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionQueueQueryMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionQueueQueryMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+
+/**
+ * 
+ * A SessionQueueQueryMessage
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionQueueQueryMessage extends AbstractPacket
+{
+   private String queueName;
+
+   public SessionQueueQueryMessage(String queueName)
+   {
+      super(PacketType.SESS_QUEUEQUERY);
+
+      this.queueName = queueName;            
+   }
+
+   public String getQueueName()
+   {
+      return queueName;
+   }
+   
+}

Added: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionQueueQueryResponseMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionQueueQueryResponseMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionQueueQueryResponseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,101 @@
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_QUEUEQUERY_RESP;
+
+/**
+ * 
+ * A SessionQueueQueryResponseMessage
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionQueueQueryResponseMessage extends AbstractPacket
+{
+   private boolean exists;
+   
+   private boolean durable;
+   
+   private boolean temporary;
+   
+   private int maxSize;
+   
+   private int consumerCount;
+   
+   private int messageCount;
+   
+   private String filterString;
+   
+   private String address;
+   
+   //etc
+   
+   public SessionQueueQueryResponseMessage(boolean durable, boolean temporary, int maxSize, int consumerCount,
+                             int messageCount, String filterString, String address)
+   {
+      super(SESS_QUEUEQUERY_RESP);
+      
+      this.exists = true;
+      
+      this.durable = durable;
+      
+      this.temporary = temporary;
+      
+      this.maxSize = maxSize;
+      
+      this.consumerCount = consumerCount;
+      
+      this.messageCount = messageCount;
+      
+      this.filterString = filterString;
+      
+      this.address = address;
+   }
+   
+   public SessionQueueQueryResponseMessage()
+   {
+      super(SESS_QUEUEQUERY_RESP);
+      
+      this.exists = false;
+   }
+   
+   public boolean isExists()
+   {
+      return exists;
+   }
+   
+   public boolean isDurable()
+   {
+      return durable;
+   }
+   
+   public boolean isTemporary()
+   {
+      return temporary;
+   }
+   
+   public int getMaxSize()
+   {
+      return maxSize;
+   }
+   
+   public int getConsumerCount()
+   {
+      return consumerCount;
+   }
+   
+   public int getMessageCount()
+   {
+      return messageCount;
+   }
+   
+   public String getFilterString()
+   {
+      return filterString;
+   }
+   
+   public String getAddress()
+   {
+      return address;
+   }
+   
+}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionRecoverMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionRecoverMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionRecoverMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -6,7 +6,7 @@
  */
 package org.jboss.messaging.core.remoting.wireformat;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_RECOVER;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_RECOVER;
 
 
 /**
@@ -26,7 +26,7 @@
 
    public SessionRecoverMessage()
    {
-      super(MSG_RECOVER);
+      super(SESS_RECOVER);
    }
 
    // Public --------------------------------------------------------

Added: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionRemoveAddressMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionRemoveAddressMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionRemoveAddressMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_REMOVE_ADDRESS;
+
+
+/**
+ * 
+ * A SessionRemoveAddressMessage
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class SessionRemoveAddressMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+   
+   private String address;
+   
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+   
+   public SessionRemoveAddressMessage(String address)
+   {
+      super(SESS_REMOVE_ADDRESS);
+      
+      this.address = address;
+   }
+
+   // Public --------------------------------------------------------
+   
+   public String getAddress()
+   {
+      return address;
+   }
+   
+   @Override
+   public String toString()
+   {
+      return getParentString() + ", address=" + address + "]";
+   }
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+
+

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionRollbackMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionRollbackMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionRollbackMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -6,7 +6,7 @@
  */
 package org.jboss.messaging.core.remoting.wireformat;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_ROLLBACK;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_ROLLBACK;
 
 
 /**
@@ -26,7 +26,7 @@
 
    public SessionRollbackMessage()
    {
-      super(MSG_ROLLBACK);
+      super(SESS_ROLLBACK);
    }
 
    // Public --------------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionSendMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionSendMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionSendMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -6,7 +6,7 @@
  */
 package org.jboss.messaging.core.remoting.wireformat;
 
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SENDMESSAGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_SEND;
 
 import org.jboss.messaging.core.Message;
 
@@ -22,18 +22,22 @@
 
    // Attributes ----------------------------------------------------
 
+   private String address;
+   
    private final Message message;
 
    // Static --------------------------------------------------------
 
    // Constructors --------------------------------------------------
 
-   public SessionSendMessage(Message message)
+   public SessionSendMessage(String address, Message message)
    {
-      super(MSG_SENDMESSAGE);
+      super(SESS_SEND);
 
       assert message != null;
-
+            
+      this.address = address;
+      
       this.message = message;
    }
 
@@ -43,11 +47,16 @@
    {
       return message;
    }
+   
+   public String getAddress()
+   {
+      return address;
+   }
 
    @Override
    public String toString()
    {
-      return getParentString() + ", message=" + message
+      return getParentString() + ", message=" + message + ", address=" + address
             + "]";
    }
    

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionSetIDMessage.java (from rev 3654, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SetSessionIDMessage.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionSetIDMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionSetIDMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.Assert.assertValidID;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_SETID;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionSetIDMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final String sessionID;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionSetIDMessage(String sessionID)
+   {
+      super(SESS_SETID);
+
+      assertValidID(sessionID);
+      this.sessionID = sessionID;
+   }
+
+   // Public --------------------------------------------------------
+
+   public String getSessionID()
+   {
+      return sessionID;
+   }
+
+   @Override
+   public String toString()
+   {
+      return getParentString() + ", sessionID=" + sessionID + "]";
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
\ No newline at end of file

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXACommitMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXACommitMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXACommitMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -30,7 +30,7 @@
 
    public SessionXACommitMessage(Xid xid, boolean onePhase)
    {
-      super(PacketType.MSG_XA_COMMIT);
+      super(PacketType.SESS_XA_COMMIT);
       
       this.xid = xid;
       

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAEndMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAEndMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAEndMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -30,7 +30,7 @@
 
    public SessionXAEndMessage(Xid xid, boolean failed)
    {
-      super(PacketType.MSG_XA_END);
+      super(PacketType.SESS_XA_END);
       
       this.xid = xid;
       

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAForgetMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAForgetMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAForgetMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -28,7 +28,7 @@
 
    public SessionXAForgetMessage(Xid xid)
    {
-      super(PacketType.MSG_XA_FORGET);
+      super(PacketType.SESS_XA_FORGET);
       
       this.xid = xid;
    }

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsMessage.java (from rev 3655, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsRequest.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionXAGetInDoubtXidsMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+   
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionXAGetInDoubtXidsMessage()
+   {
+      super(PacketType.SESS_XA_INDOUBT_XIDS);
+   }
+
+   // Public --------------------------------------------------------
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+
+

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsRequest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsRequest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * 
- * @version <tt>$Revision$</tt>
- */
-public class SessionXAGetInDoubtXidsRequest extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-   
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SessionXAGetInDoubtXidsRequest()
-   {
-      super(PacketType.REQ_XA_INDOUBT_XIDS);
-   }
-
-   // Public --------------------------------------------------------
-   
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}
-
-

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import java.util.List;
-
-import javax.transaction.xa.Xid;
-
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * 
- * @version <tt>$Revision$</tt>
- */
-public class SessionXAGetInDoubtXidsResponse extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-   
-   private List<Xid> xids;
-   
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SessionXAGetInDoubtXidsResponse(List<Xid> xids)
-   {
-      super(PacketType.RESP_XA_INDOUBT_XIDS);
-      
-      this.xids = xids;
-   }
-
-   // Public --------------------------------------------------------
-   
-   public List<Xid> getXids()
-   {
-      return xids;
-   }
-   
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}
-
-

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsResponseMessage.java (from rev 3655, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsResponse.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsResponseMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetInDoubtXidsResponseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import java.util.List;
+
+import javax.transaction.xa.Xid;
+
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionXAGetInDoubtXidsResponseMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+   
+   private List<Xid> xids;
+   
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionXAGetInDoubtXidsResponseMessage(List<Xid> xids)
+   {
+      super(PacketType.SESS_XA_INDOUBT_XIDS_RESP);
+      
+      this.xids = xids;
+   }
+
+   // Public --------------------------------------------------------
+   
+   public List<Xid> getXids()
+   {
+      return xids;
+   }
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+
+

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -25,7 +25,7 @@
 
    public SessionXAGetTimeoutMessage()
    {
-      super(PacketType.MSG_XA_GET_TIMEOUT);
+      super(PacketType.SESS_XA_GET_TIMEOUT);
    }
    
    // Public --------------------------------------------------------

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * 
- * @version <tt>$Revision$</tt>
- */
-public class SessionXAGetTimeoutResponse extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-   
-   private int timeoutSeconds;
-   
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SessionXAGetTimeoutResponse(int timeoutSeconds)
-   {
-      super(PacketType.MSG_XA_GET_TIMEOUT_RESPONSE);
-      
-      this.timeoutSeconds = timeoutSeconds;
-   }
-   
-
-   // Public --------------------------------------------------------
-   
-   public int getTimeoutSeconds()
-   {
-      return this.timeoutSeconds;
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}
-

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutResponseMessage.java (from rev 3655, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutResponse.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutResponseMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAGetTimeoutResponseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionXAGetTimeoutResponseMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+   
+   private int timeoutSeconds;
+   
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionXAGetTimeoutResponseMessage(int timeoutSeconds)
+   {
+      super(PacketType.SESS_XA_GET_TIMEOUT_RESP);
+      
+      this.timeoutSeconds = timeoutSeconds;
+   }
+   
+
+   // Public --------------------------------------------------------
+   
+   public int getTimeoutSeconds()
+   {
+      return this.timeoutSeconds;
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAJoinMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAJoinMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAJoinMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -28,7 +28,7 @@
 
    public SessionXAJoinMessage(Xid xid)
    {
-      super(PacketType.MSG_XA_JOIN);
+      super(PacketType.SESS_XA_JOIN);
       
       this.xid = xid;
    }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAPrepareMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAPrepareMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAPrepareMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -28,7 +28,7 @@
 
    public SessionXAPrepareMessage(Xid xid)
    {
-      super(PacketType.REQ_XA_PREPARE);
+      super(PacketType.SESS_XA_PREPARE);
       
       this.xid = xid;
    }

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * 
- * @version <tt>$Revision$</tt>
- */
-public class SessionXAResponse extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-   
-   private boolean error;
-   
-   private int responseCode;
-   
-   private String message;
-      
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SessionXAResponse(boolean isError, int responseCode, String message)
-   {
-      super(PacketType.RESP_XA);
-      
-      this.error = isError;
-      
-      this.responseCode = responseCode;
-      
-      this.message = message;
-   }
-
-   // Public --------------------------------------------------------
-   
-   public boolean isError()
-   {
-      return error;
-   }
-   
-   public int getResponseCode()
-   {
-      return this.responseCode;
-   }
-   
-   public String getMessage()
-   {
-      return message;
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}
-

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResponseMessage.java (from rev 3655, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResponse.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResponseMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResponseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionXAResponseMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+   
+   private boolean error;
+   
+   private int responseCode;
+   
+   private String message;
+      
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionXAResponseMessage(boolean isError, int responseCode, String message)
+   {
+      super(PacketType.SESS_XA_RESP);
+      
+      this.error = isError;
+      
+      this.responseCode = responseCode;
+      
+      this.message = message;
+   }
+
+   // Public --------------------------------------------------------
+   
+   public boolean isError()
+   {
+      return error;
+   }
+   
+   public int getResponseCode()
+   {
+      return this.responseCode;
+   }
+   
+   public String getMessage()
+   {
+      return message;
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}
+

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResumeMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResumeMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAResumeMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -28,7 +28,7 @@
 
    public SessionXAResumeMessage(Xid xid)
    {
-      super(PacketType.MSG_XA_RESUME);
+      super(PacketType.SESS_XA_RESUME);
       
       this.xid = xid;
    }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXARollbackMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXARollbackMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXARollbackMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -28,7 +28,7 @@
 
    public SessionXARollbackMessage(Xid xid)
    {
-      super(PacketType.MSG_XA_ROLLBACK);
+      super(PacketType.SESS_XA_ROLLBACK);
       
       this.xid = xid;
    }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -27,7 +27,7 @@
 
    public SessionXASetTimeoutMessage(int timeoutSeconds)
    {
-      super(PacketType.MSG_XA_SET_TIMEOUT);
+      super(PacketType.SESS_XA_SET_TIMEOUT);
       
       this.timeoutSeconds = timeoutSeconds;
    }

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutResponse.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutResponse.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * 
- * @version <tt>$Revision$</tt>
- */
-public class SessionXASetTimeoutResponse extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-   
-   private boolean ok;
-   
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SessionXASetTimeoutResponse(boolean ok)
-   {
-      super(PacketType.MSG_XA_SET_TIMEOUT_RESPONSE);
-      
-      this.ok = ok;
-   }
-   
-   // Public --------------------------------------------------------
-   
-   public boolean isOK()
-   {
-      return ok;
-   }
-   
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutResponseMessage.java (from rev 3655, trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutResponse.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutResponseMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASetTimeoutResponseMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionXASetTimeoutResponseMessage extends AbstractPacket
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+   
+   private boolean ok;
+   
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public SessionXASetTimeoutResponseMessage(boolean ok)
+   {
+      super(PacketType.SESS_XA_SET_TIMEOUT_RESP);
+      
+      this.ok = ok;
+   }
+   
+   // Public --------------------------------------------------------
+   
+   public boolean isOK()
+   {
+      return ok;
+   }
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAStartMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAStartMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXAStartMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -28,7 +28,7 @@
 
    public SessionXAStartMessage(Xid xid)
    {
-      super(PacketType.MSG_XA_START);
+      super(PacketType.SESS_XA_START);
       
       this.xid = xid;
    }

Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASuspendMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASuspendMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SessionXASuspendMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -24,7 +24,7 @@
 
    public SessionXASuspendMessage()
    {
-      super(PacketType.MSG_XA_SUSPEND);
+      super(PacketType.SESS_XA_SUSPEND);
    }
 
    // Public --------------------------------------------------------

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SetClientIDMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SetClientIDMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SetClientIDMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.Assert.assertValidID;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SETCLIENTID;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- * 
- * @version <tt>$Revision$</tt>
- */
-public class SetClientIDMessage extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final String clientID;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SetClientIDMessage(String clientID)
-   {
-      super(MSG_SETCLIENTID);
-
-      assertValidID(clientID);
-
-      this.clientID = clientID;
-   }
-
-   // Public --------------------------------------------------------
-
-   public String getClientID()
-   {
-      return clientID;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", clientID=" + clientID + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SetSessionIDMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SetSessionIDMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/SetSessionIDMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.Assert.assertValidID;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SETSESSIONID;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- * 
- * @version <tt>$Revision$</tt>
- */
-public class SetSessionIDMessage extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final String sessionID;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public SetSessionIDMessage(String sessionID)
-   {
-      super(MSG_SETSESSIONID);
-
-      assertValidID(sessionID);
-      this.sessionID = sessionID;
-   }
-
-   // Public --------------------------------------------------------
-
-   public String getSessionID()
-   {
-      return sessionID;
-   }
-
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", sessionID=" + sessionID + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}
\ No newline at end of file

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/StartConnectionMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/StartConnectionMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/StartConnectionMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_STARTCONNECTION;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- */
-public class StartConnectionMessage extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public StartConnectionMessage()
-   {
-      super(MSG_STARTCONNECTION);
-   }
-
-   // Public --------------------------------------------------------
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/StopConnectionMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/StopConnectionMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/StopConnectionMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_STOPCONNECTION;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- */
-public class StopConnectionMessage extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public StopConnectionMessage()
-   {
-      super(MSG_STOPCONNECTION);
-   }
-
-   // Public --------------------------------------------------------
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/UnsubscribeMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/UnsubscribeMessage.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/UnsubscribeMessage.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_UNSUBSCRIBE;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class UnsubscribeMessage extends AbstractPacket
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final String subscriptionName;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public UnsubscribeMessage(String subscriptionName)
-   {
-      super(MSG_UNSUBSCRIBE);
-
-      assert subscriptionName != null;
-
-      this.subscriptionName = subscriptionName;
-   }
-
-   // Public --------------------------------------------------------
-
-   public String getSubscriptionName()
-   {
-      return subscriptionName;
-   }
-   
-   @Override
-   public String toString()
-   {
-      return getParentString() + ", subscriptionName=" + subscriptionName + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Modified: trunk/src/main/org/jboss/messaging/util/ExceptionUtil.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/ExceptionUtil.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/src/main/org/jboss/messaging/util/ExceptionUtil.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -21,12 +21,7 @@
  */
 package org.jboss.messaging.util;
 
-import java.util.UUID;
 
-import javax.jms.JMSException;
-
-import org.jboss.jms.exception.MessagingJMSException;
-
 /**
  * A ExceptionUtil
 
@@ -39,44 +34,9 @@
 public class ExceptionUtil
 {
    private static final Logger log = Logger.getLogger(ExceptionUtil.class);
+    
    
    /*
-    * The strategy for what how we propagate Throwables from the server to the client
-    * in the event of one occuring on the server in a client initiated invocation is as
-    * follows:
-    * 1) We always log the Throwable irrespective of it's type - this is so system administrators
-    * have a record of what has happened - typically they may configure log4j to send an email
-    * or create some other alert when this happens
-    * 2) If the exception is a JMSException that was created and thrown in the messaging code, then
-    * this is propagated back to the client
-    * 4) Any other Errors or Exceptions (e.g. SQLException) are rethrown as a JMSException
-    * - we do not want to propagate the original exception back to the client since the client may not
-    * have the correct jars to receive the exception - (e.g. if it was an exception thrown from a postgressql driver)
-    * Also there maybe security reasons we do not want to expose the specific original exception to the client
-    */
-   public static JMSException handleJMSInvocation(Throwable t, String msg)
-   {
-      //We create a GUID and log it and send it in the client exception.
-      //This allows what is received at the client to be correlated if necessary
-      //to what is logged in the server logs
-      String id = UUID.randomUUID().toString();
-      
-      //First we log the Throwable
-      log.error(msg + " [" + id + "]", t);
-      
-      if (t instanceof JMSException)
-      {         
-         return (JMSException)t;
-      }
-      else
-      {
-         JMSException e = new MessagingJMSException("A failure has occurred during processing of the request. " + 
-                                                    "Please consult the server logs for more details. " + msg + " [" + id + "]");    
-         return e;
-      }    
-   }   
-   
-   /*
     * This method is used to log any Throwables occurring in the execution of JMX methods before
     * propagating them back to the caller.
     * If we don't log them then we have no record of them occurring on the server.

Added: trunk/src/main/org/jboss/messaging/util/MessagingException.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/MessagingException.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/util/MessagingException.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -0,0 +1,90 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.messaging.util;
+
+/**
+ * 
+ * A MessagingException
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class MessagingException extends Exception
+{
+   private static final long serialVersionUID = -4802014152804997417L;
+   
+   // Error codes -------------------------------------------------
+            
+   public static final int INTERNAL_ERROR = 000;
+   
+   public static final int UNSUPPORTED_PACKET = 001;
+   
+   public static final int NOT_CONNECTED = 002;
+   
+   public static final int CONNECTION_TIMEDOUT = 003;
+
+   
+   public static final int QUEUE_DOES_NOT_EXIST = 100;
+   
+   public static final int QUEUE_EXISTS = 101;
+   
+   public static final int OBJECT_CLOSED = 102;
+   
+   public static final int INVALID_FILTER_EXPRESSION = 103;
+   
+   public static final int ILLEGAL_STATE = 104;
+   
+   public static final int SECURITY_EXCEPTION = 105;
+   
+   public static final int ADDRESS_DOES_NOT_EXIST = 106;
+   
+   public static final int ADDRESS_EXISTS = 107;
+   
+   private int code;
+   
+   public MessagingException()
+   {      
+   }
+   
+   public MessagingException(int code)
+   {
+      this.code = code;
+   }
+   
+   public MessagingException(int code, String msg)
+   {
+      super(msg);
+      
+      this.code = code;
+   }
+   
+   public int getCode()
+   {
+      return code;
+   }
+   
+   public String toString()
+   {
+      return "MessagingException[errorCode=" + code + " message=" + getMessage() + "]";
+   }
+
+}

Modified: trunk/tests/src/org/jboss/jms/server/test/unit/ConfigurationTest.java
===================================================================
--- trunk/tests/src/org/jboss/jms/server/test/unit/ConfigurationTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/jms/server/test/unit/ConfigurationTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -109,27 +109,7 @@
          }
       }
    }
-
-   public void testSetDLQ() throws Exception
-   {
-      assertEquals("failed to set DLQ", "DLQtest", configuration.getDefaultDLQ());
-   }
-
-   public void testSetDefMaxDelAtt() throws Exception
-   {
-      assertEquals("failed to set Default max delivery attempts", new Integer(100), configuration.getDefaultMaxDeliveryAttempts());
-   }
-
-   public void testSetExpiryQueue() throws Exception
-   {
-      assertEquals("failed to set DLQ", "ExpiryQueuetest", configuration.getDefaultExpiryQueue());
-   }
-
-   public void testSetDefaultRedeliveryDelay() throws Exception
-   {
-      assertEquals("failed to set Default redeliver delay", 10, configuration.getDefaultRedeliveryDelay());
-   }
-
+  
    public void testSetMessageCounterSamplePeriod() throws Exception
    {
       assertEquals("failed to set Message Counter sample period", 50000, configuration.getMessageCounterSamplePeriod());

Modified: trunk/tests/src/org/jboss/messaging/core/impl/bdbje/test/unit/BDBJEPersistenceManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/impl/bdbje/test/unit/BDBJEPersistenceManagerTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/messaging/core/impl/bdbje/test/unit/BDBJEPersistenceManagerTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -30,13 +30,10 @@
 import javax.transaction.xa.Xid;
 
 import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
-import org.jboss.messaging.core.DestinationType;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.MessageReference;
 import org.jboss.messaging.core.Queue;
 import org.jboss.messaging.core.impl.BindingImpl;
-import org.jboss.messaging.core.impl.ConditionImpl;
 import org.jboss.messaging.core.impl.MessageImpl;
 import org.jboss.messaging.core.impl.QueueFactoryImpl;
 import org.jboss.messaging.core.impl.QueueImpl;
@@ -673,22 +670,22 @@
       
       Queue queue4 = new QueueImpl(4, "queue4", new FilterImpl("a=1"), false, true, false, -1);
       
-      Condition condition1 = new ConditionImpl(DestinationType.QUEUE, "condition1");
+      String condition1 = "queue.condition1";
       
-      Binding binding1 = new BindingImpl(1, condition1, queue1, false);
+      Binding binding1 = new BindingImpl(1, condition1, queue1);
       
-      Condition condition2 = new ConditionImpl(DestinationType.TOPIC, "condition2");
+      String condition2 = "queue.condition2";
       
-      Binding binding2 = new BindingImpl(1, condition2, queue2, true);
+      Binding binding2 = new BindingImpl(1, condition2, queue2);
       
-      Condition condition3 = new ConditionImpl(DestinationType.QUEUE, "condition3");
+      String condition3 = "queue.condition3";
       
-      Binding binding3 = new BindingImpl(3, condition3, queue3, false);
+      Binding binding3 = new BindingImpl(3, condition3, queue3);
       
       //same condition
-      Condition condition4 = new ConditionImpl(DestinationType.QUEUE, "condition3");
+      String condition4 = "queue.condition3";
       
-      Binding binding4 = new BindingImpl(3, condition4, queue4, false);
+      Binding binding4 = new BindingImpl(3, condition4, queue4);
       
       
       pm.addBinding(binding1);
@@ -762,22 +759,22 @@
       
       Queue queue4 = new QueueImpl(4, "queue4", null, false, true, false, -1);
       
-      Condition condition1 = new ConditionImpl(DestinationType.QUEUE, "condition1");
+      String condition1 = "queue.condition1";
       
-      Binding binding1 = new BindingImpl(1, condition1, queue1, false);
+      Binding binding1 = new BindingImpl(1, condition1, queue1);
       
-      Condition condition2 = new ConditionImpl(DestinationType.TOPIC, "condition2");
+      String condition2 = "queue.condition2";
       
-      Binding binding2 = new BindingImpl(1, condition2, queue2, true);
+      Binding binding2 = new BindingImpl(1, condition2, queue2);
       
-      Condition condition3 = new ConditionImpl(DestinationType.QUEUE, "condition3");
+      String condition3 = "queue.condition3";
       
-      Binding binding3 = new BindingImpl(3, condition3, queue3, false);
+      Binding binding3 = new BindingImpl(3, condition3, queue3);
       
       //same condition
-      Condition condition4 = new ConditionImpl(DestinationType.QUEUE, "condition3");
+      String condition4 = "queue.condition3";
       
-      Binding binding4 = new BindingImpl(3, condition4, queue4, false);
+      Binding binding4 = new BindingImpl(3, condition4, queue4);
                         
       pm.addBinding(binding1);
       
@@ -1010,12 +1007,8 @@
    {
       assertEquals(b1.getNodeID(), b2.getNodeID());
       
-      assertEquals(b1.getCondition().getType(), b2.getCondition().getType());
+      assertEquals(b1.getAddress(), b2.getAddress());
       
-      assertEquals(b1.getCondition().getKey(), b2.getCondition().getKey());
-      
-      assertEquals(b1.isAllNodes(), b2.isAllNodes());
-      
       Queue queue1 = b1.getQueue();
       
       Queue queue2 = b2.getQueue();

Modified: trunk/tests/src/org/jboss/messaging/core/impl/filter/test/unit/FilterTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/impl/filter/test/unit/FilterTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/messaging/core/impl/filter/test/unit/FilterTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -25,6 +25,7 @@
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.impl.MessageImpl;
 import org.jboss.messaging.core.impl.filter.FilterImpl;
+import org.jboss.messaging.util.MessagingException;
 import org.jboss.test.messaging.JBMBaseTestCase;
 
 /**
@@ -605,9 +606,9 @@
          
          fail("Should throw exception");
       }
-      catch (IllegalArgumentException e)
+      catch (MessagingException e)
       {
-         assertEquals("Invalid filter: " + filterString, e.getMessage());
+         assertEquals(MessagingException.INVALID_FILTER_EXPRESSION, e.getCode());
       }            
    }
    

Modified: trunk/tests/src/org/jboss/messaging/core/impl/postoffice/test/unit/PostOfficeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/impl/postoffice/test/unit/PostOfficeTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/messaging/core/impl/postoffice/test/unit/PostOfficeTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -27,8 +27,6 @@
 
 import org.easymock.EasyMock;
 import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
-import org.jboss.messaging.core.DestinationType;
 import org.jboss.messaging.core.Filter;
 import org.jboss.messaging.core.Message;
 import org.jboss.messaging.core.PersistenceManager;
@@ -37,7 +35,6 @@
 import org.jboss.messaging.core.QueueFactory;
 import org.jboss.messaging.core.Transaction;
 import org.jboss.messaging.core.impl.BindingImpl;
-import org.jboss.messaging.core.impl.ConditionImpl;
 import org.jboss.messaging.core.impl.QueueFactoryImpl;
 import org.jboss.messaging.core.impl.QueueImpl;
 import org.jboss.messaging.core.impl.TransactionImpl;
@@ -74,7 +71,7 @@
       
       final int nodeID = 21;
       
-      PostOffice po = new PostOfficeImpl(nodeID, pm, qf);
+      PostOffice po = new PostOfficeImpl(nodeID, pm, qf, false);
       
       final long id = 324;
       final String name = "wibb22";
@@ -87,18 +84,17 @@
       
       EasyMock.expect(qf.createQueue(-1, name, filter, durable, temporary)).andReturn(queue);
             
-      final Condition condition = new ConditionImpl(DestinationType.QUEUE, "wibble");
-      final boolean allNodes = false;
+      final String condition = "queue.wibble";
+
+      Binding expected = new BindingImpl(nodeID, condition, queue);
       
-      Binding expected = new BindingImpl(nodeID, condition, queue, allNodes);
-      
       pm.addBinding(EasyMock.eq(expected));
       
       EasyMock.replay(qf);
       
       EasyMock.replay(pm);
       
-      po.addQueue(condition, name, filter, durable, temporary, allNodes);
+      po.addBinding(condition, name, filter, durable, temporary);
       
       EasyMock.verify(qf);
       
@@ -118,7 +114,7 @@
       
       EasyMock.replay(pm);
       
-      po.addQueue(condition, name, filter, durable2, temporary, allNodes);
+      po.addBinding(condition, name, filter, durable2, temporary);
       
       EasyMock.verify(qf);
       
@@ -133,7 +129,7 @@
       
       final int nodeID = 21;
       
-      PostOffice po = new PostOfficeImpl(nodeID, pm, qf);
+      PostOffice po = new PostOfficeImpl(nodeID, pm, qf, false);
       
       final long id = 324;
       final String name = "wibb22";
@@ -146,11 +142,10 @@
       
       EasyMock.expect(qf.createQueue(-1, name, filter, durable, temporary)).andReturn(queue);
             
-      final Condition condition = new ConditionImpl(DestinationType.QUEUE, "wibble");
-      final boolean allNodes = false;
+      final String condition = "queue.wibble";
+ 
+      Binding expected = new BindingImpl(nodeID, condition, queue);
       
-      Binding expected = new BindingImpl(nodeID, condition, queue, allNodes);
-      
       pm.addBinding(EasyMock.eq(expected));
       
       pm.deleteBinding(EasyMock.eq(expected));
@@ -159,9 +154,9 @@
       
       EasyMock.replay(pm);
       
-      po.addQueue(condition, name, filter, durable, temporary, allNodes);
+      po.addBinding(condition, name, filter, durable, temporary);
       
-      po.removeQueue(condition, name, allNodes);
+      po.removeBinding(name);
       
       EasyMock.verify(qf);
       
@@ -181,9 +176,9 @@
       
       EasyMock.replay(pm);
       
-      po.addQueue(condition, name, filter, durable2, temporary, allNodes);
+      po.addBinding(condition, name, filter, durable2, temporary);
       
-      po.removeQueue(condition, name, allNodes);
+      po.removeBinding(name);
       
       EasyMock.verify(qf);
       
@@ -198,19 +193,19 @@
       
       final int nodeID = 21;
       
-      PostOffice po = new PostOfficeImpl(nodeID, pm, qf);
+      PostOffice po = new PostOfficeImpl(nodeID, pm, qf, false);
       
-      final Condition condition1 = new ConditionImpl(DestinationType.QUEUE, "wibble");      
+      final String condition1 = "queue.wibble";      
                 
-      po.addQueue(condition1, "queue1", null, false, false, false);      
-      Map<Condition, List<Binding>> mappings = po.getMappings();      
+      po.addBinding(condition1, "queue1", null, false, false);      
+      Map<String, List<Binding>> mappings = po.getMappings();      
       assertEquals(1, mappings.size());
       
-      po.addQueue(condition1, "queue2", null, false, false, false);     
+      po.addBinding(condition1, "queue2", null, false, false);     
       mappings = po.getMappings();      
       assertEquals(1, mappings.size());
       
-      po.addQueue(condition1, "queue3", null, false, false, false); 
+      po.addBinding(condition1, "queue3", null, false, false); 
       mappings = po.getMappings();      
       assertEquals(1, mappings.size());
       
@@ -230,43 +225,43 @@
       Queue queue3 = binding3.getQueue();
       assertEquals("queue3", queue3.getName());
       
-      final Condition condition2 = new ConditionImpl(DestinationType.QUEUE, "wibble2"); 
+      final String condition2 = "queue.wibble2"; 
       
-      po.addQueue(condition2, "queue4", null, false, false, false);       
+      po.addBinding(condition2, "queue4", null, false, false);       
       mappings = po.getMappings();      
       assertEquals(2, mappings.size());
       
-      po.addQueue(condition2, "queue5", null, false, false, false); 
+      po.addBinding(condition2, "queue5", null, false, false); 
       mappings = po.getMappings();      
       assertEquals(2, mappings.size());
       
-      final Condition condition3 = new ConditionImpl(DestinationType.TOPIC, "wibblexyz"); 
+      final String condition3 = "topic.wibblexyz"; 
       
-      po.addQueue(condition3, "queue6", null, false, false, false);       
+      po.addBinding(condition3, "queue6", null, false, false);       
       mappings = po.getMappings();      
       assertEquals(3, mappings.size());
       
-      po.removeQueue(condition3, "queue6", false);
+      po.removeBinding("queue6");
       mappings = po.getMappings();      
       assertEquals(2, mappings.size());
       
-      po.removeQueue(condition2, "queue4", false);
+      po.removeBinding("queue4");
       mappings = po.getMappings();      
       assertEquals(2, mappings.size());
       
-      po.removeQueue(condition2, "queue5", false);
+      po.removeBinding("queue5");
       mappings = po.getMappings();      
       assertEquals(1, mappings.size());
       
-      po.removeQueue(condition1, "queue1", false);
+      po.removeBinding("queue1");
       mappings = po.getMappings();      
       assertEquals(1, mappings.size());
       
-      po.removeQueue(condition1, "queue2", false);
+      po.removeBinding("queue2");
       mappings = po.getMappings();      
       assertEquals(1, mappings.size());
       
-      po.removeQueue(condition1, "queue3", false);
+      po.removeBinding("queue3");
       mappings = po.getMappings();      
       assertEquals(0, mappings.size());      
    }
@@ -277,13 +272,13 @@
       
       QueueFactory qf = new QueueFactoryImpl();
       
-      PostOffice po = new PostOfficeImpl(1, pm, qf);
+      PostOffice po = new PostOfficeImpl(1, pm, qf, false);
       
       Message message = this.generateMessage(1);
       
       try
       {
-         po.route(new ConditionImpl(DestinationType.QUEUE, "eek"), message);
+         po.route("queue.eek", message);
          fail("Should throw exception");
       }
       catch (NullPointerException e)
@@ -298,11 +293,11 @@
       
       QueueFactory qf = new QueueFactoryImpl();
       
-      PostOffice po = new PostOfficeImpl(1, pm, qf);
+      PostOffice po = new PostOfficeImpl(1, pm, qf, false);
       
-      Condition condition = new ConditionImpl(DestinationType.QUEUE, "queue1");
+      String condition = "queue.queue1";
       
-      po.addQueue(condition, "queue1", null, false, false, false);
+      po.addBinding(condition, "queue1", null, false, false);
       
       Message message = this.generateMessage(1);
       
@@ -312,7 +307,7 @@
       
       msgs.add(message);
       
-      po.route(new ConditionImpl(DestinationType.QUEUE, "queue1"), message);
+      po.route("queue.queue1", message);
       
       if (message.getNumDurableReferences() != 0)
       {
@@ -322,7 +317,7 @@
       
       
       
-      Map<Condition, List<Binding>> mappings = po.getMappings();
+      Map<String, List<Binding>> mappings = po.getMappings();
       
       Binding binding = mappings.get(condition).get(0);
       

Modified: trunk/tests/src/org/jboss/messaging/core/impl/test/unit/QueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/impl/test/unit/QueueTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/messaging/core/impl/test/unit/QueueTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -506,7 +506,7 @@
       
       for (int i = 0; i < numMessages; i++)
       {
-         queue.referenceAcknowledged();
+         queue.decrementDeliveringCount();
       }
       
       for (int i = 0; i < 2 * numMessages; i++)
@@ -531,7 +531,7 @@
       refs.clear();
       for (int i = 0; i < 2 * numMessages; i++)
       {
-         queue.referenceAcknowledged();
+         queue.decrementDeliveringCount();
       }
       
       FakeConsumer cons3 = new FakeConsumer();
@@ -566,7 +566,7 @@
       refs.clear();
       for (int i = 0; i < 3 * numMessages; i++)
       {
-         queue.referenceAcknowledged();
+         queue.decrementDeliveringCount();
       }
       
       for (int i = 0; i < 2 * numMessages; i++)
@@ -592,7 +592,7 @@
       refs.clear();
       for (int i = 0; i < 2 * numMessages; i++)
       {
-         queue.referenceAcknowledged();
+         queue.decrementDeliveringCount();
       }
       
       for (int i = 0; i < numMessages; i++)
@@ -1041,7 +1041,7 @@
             
       assertRefListsIdenticalRefs(refs, consumer.getReferences()); 
       
-      queue.referenceAcknowledged();
+      queue.decrementDeliveringCount();
 
       queue.removeConsumer(consumer);
             
@@ -1149,8 +1149,8 @@
             
       assertRefListsIdenticalRefs(refs, consumer.getReferences()); 
       
-      queue.referenceAcknowledged();
-      queue.referenceAcknowledged();
+      queue.decrementDeliveringCount();
+      queue.decrementDeliveringCount();
       
       queue.removeConsumer(consumer);
       

Modified: trunk/tests/src/org/jboss/messaging/core/remoting/impl/mina/integration/test/ReversePacketHandler.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/remoting/impl/mina/integration/test/ReversePacketHandler.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/messaging/core/remoting/impl/mina/integration/test/ReversePacketHandler.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -17,9 +17,9 @@
 
 import org.jboss.messaging.core.remoting.PacketSender;
 import org.jboss.messaging.core.remoting.test.unit.TestPacketHandler;
-import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
 import org.jboss.messaging.core.remoting.wireformat.Packet;
 import org.jboss.messaging.core.remoting.wireformat.TextPacket;
+import org.jboss.messaging.util.Logger;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -30,6 +30,9 @@
 public class ReversePacketHandler extends TestPacketHandler
 {
    // Constants -----------------------------------------------------
+   
+   private static final Logger log = Logger.getLogger(ReversePacketHandler.class);
+   
 
    // Attributes ----------------------------------------------------
 
@@ -79,7 +82,14 @@
       {
          TextPacket response = new TextPacket(reverse(message.getText()));
          response.normalize(message);
-         sender.send(response);
+         try
+         {
+            sender.send(response);
+         }
+         catch (Exception e)
+         {
+            log.error("Failed to handle", e);
+         }
       }
    }
 

Modified: trunk/tests/src/org/jboss/messaging/core/remoting/test/unit/ClientTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/remoting/test/unit/ClientTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/messaging/core/remoting/test/unit/ClientTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -16,8 +16,6 @@
 
 import java.io.IOException;
 
-import javax.jms.IllegalStateException;
-
 import junit.framework.TestCase;
 
 import org.jboss.messaging.core.remoting.Client;
@@ -158,9 +156,10 @@
       {
          client.send(new NullPacket(), true);
          fail("can not send a packet if the dispatcher is not connected");
-      } catch (IllegalStateException e)
+      }
+      catch (IllegalStateException e)
       {
-
+         //Ok
       }
       
       verify(connector);

Modified: trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/PacketTypeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/PacketTypeTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/PacketTypeTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -19,49 +19,65 @@
 import static org.jboss.messaging.core.remoting.impl.mina.MinaPacketCodec.UTF_8_ENCODER;
 import static org.jboss.messaging.core.remoting.wireformat.AbstractPacket.NO_ID_SET;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.BYTES;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_ACKNOWLEDGE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_ADDTEMPORARYDESTINATION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_BROWSER_RESET;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CANCEL;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CHANGERATE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CLOSE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_COMMIT;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_DELETETEMPORARYDESTINATION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_DELIVERMESSAGE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_JMSEXCEPTION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_RECOVER;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_ROLLBACK;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SENDMESSAGE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SETCLIENTID;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SETSESSIONID;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_STARTCONNECTION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_STOPCONNECTION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_UNSUBSCRIBE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_ACKNOWLEDGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_ADD_ADDRESS;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_RESET;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CANCEL;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONS_CHANGERATE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CLOSE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_COMMIT;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_DELIVER;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_RECOVER;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_REMOVE_ADDRESS;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_ROLLBACK;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_SEND;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_SETID;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONN_START;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONN_STOP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_COMMIT;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_END;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_FORGET;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_GET_TIMEOUT;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_GET_TIMEOUT_RESP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_JOIN;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_RESUME;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_ROLLBACK;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_SET_TIMEOUT;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_SET_TIMEOUT_RESP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_START;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_SUSPEND;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.NULL;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.PING;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.PONG;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_HASNEXTMESSAGE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_NEXTMESSAGE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_NEXTMESSAGEBLOCK;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATEBROWSER;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONNECTION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONSUMER;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATEDESTINATION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATESESSION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETCLIENTID;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_HASNEXTMESSAGE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_NEXTMESSAGE;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_NEXTMESSAGEBLOCK;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATEBROWSER;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATECONNECTION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATECONSUMER;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATEDESTINATION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATESESSION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETCLIENTID;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BINDINGQUERY;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_HASNEXTMESSAGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_NEXTMESSAGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_NEXTMESSAGEBLOCK;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATEBROWSER;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CREATECONNECTION;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATECONSUMER;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONN_CREATESESSION;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATEQUEUE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_DELETE_QUEUE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_QUEUEQUERY;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_INDOUBT_XIDS;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_PREPARE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BINDINGQUERY_RESP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_HASNEXTMESSAGE_RESP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_NEXTMESSAGE_RESP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_BROWSER_NEXTMESSAGEBLOCK_RESP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATEBROWSER_RESP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CREATECONNECTION_RESP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_CREATECONSUMER_RESP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.CONN_CREATESESSION_RESP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_QUEUEQUERY_RESP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_RESP;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.SESS_XA_INDOUBT_XIDS_RESP;
 import static org.jboss.messaging.core.remoting.wireformat.PacketType.TEXT;
 import static org.jboss.messaging.core.remoting.wireformat.test.unit.CodecAssert.assertEqualsByteArrays;
 import static org.jboss.messaging.test.unit.RandomUtil.randomByte;
 import static org.jboss.messaging.test.unit.RandomUtil.randomBytes;
+import static org.jboss.messaging.test.unit.RandomUtil.randomInt;
 import static org.jboss.messaging.test.unit.RandomUtil.randomLong;
 import static org.jboss.messaging.test.unit.RandomUtil.randomString;
 
@@ -71,123 +87,114 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.jms.InvalidDestinationException;
-import javax.jms.JMSException;
 import javax.transaction.xa.Xid;
 
 import org.apache.mina.common.IoBuffer;
-import org.jboss.jms.destination.JBossQueue;
-import org.jboss.jms.destination.JBossTopic;
-import org.jboss.messaging.core.Destination;
-import org.jboss.messaging.core.DestinationType;
 import org.jboss.messaging.core.Message;
-import org.jboss.messaging.core.impl.DestinationImpl;
 import org.jboss.messaging.core.impl.MessageImpl;
 import org.jboss.messaging.core.remoting.codec.AbstractPacketCodec;
-import org.jboss.messaging.core.remoting.codec.AddTemporaryDestinationMessageCodec;
-import org.jboss.messaging.core.remoting.codec.BrowserHasNextMessageResponseCodec;
-import org.jboss.messaging.core.remoting.codec.BrowserNextMessageBlockRequestCodec;
-import org.jboss.messaging.core.remoting.codec.BrowserNextMessageBlockResponseCodec;
-import org.jboss.messaging.core.remoting.codec.BrowserNextMessageResponseCodec;
+import org.jboss.messaging.core.remoting.codec.SessionBindingQueryMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionBindingQueryResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionBrowserHasNextMessageResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionBrowserNextMessageBlockMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionBrowserNextMessageBlockResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionBrowserNextMessageResponseMessageCodec;
 import org.jboss.messaging.core.remoting.codec.BytesPacketCodec;
-import org.jboss.messaging.core.remoting.codec.ConnectionFactoryCreateConnectionRequestCodec;
-import org.jboss.messaging.core.remoting.codec.ConnectionFactoryCreateConnectionResponseCodec;
+import org.jboss.messaging.core.remoting.codec.CreateConnectionMessageCodec;
+import org.jboss.messaging.core.remoting.codec.CreateConnectionResponseMessageCodec;
 import org.jboss.messaging.core.remoting.codec.ConsumerChangeRateMessageCodec;
-import org.jboss.messaging.core.remoting.codec.CreateBrowserRequestCodec;
-import org.jboss.messaging.core.remoting.codec.CreateBrowserResponseCodec;
-import org.jboss.messaging.core.remoting.codec.CreateConsumerRequestCodec;
-import org.jboss.messaging.core.remoting.codec.CreateConsumerResponseCodec;
-import org.jboss.messaging.core.remoting.codec.CreateDestinationRequestCodec;
-import org.jboss.messaging.core.remoting.codec.CreateDestinationResponseCodec;
-import org.jboss.messaging.core.remoting.codec.CreateSessionRequestCodec;
-import org.jboss.messaging.core.remoting.codec.CreateSessionResponseCodec;
-import org.jboss.messaging.core.remoting.codec.DeleteTemporaryDestinationMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionCreateBrowserMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionCreateBrowserResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionCreateConsumerMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionCreateConsumerResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.ConnectionCreateSessionMessageCodec;
+import org.jboss.messaging.core.remoting.codec.ConnectionCreateSessionResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionDeleteQueueMessageCodec;
 import org.jboss.messaging.core.remoting.codec.DeliverMessageCodec;
-import org.jboss.messaging.core.remoting.codec.GetClientIDResponseCodec;
-import org.jboss.messaging.core.remoting.codec.JMSExceptionMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionQueueQueryMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionQueueQueryResponseMessageCodec;
 import org.jboss.messaging.core.remoting.codec.RemotingBuffer;
 import org.jboss.messaging.core.remoting.codec.SessionAcknowledgeMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionAddAddressMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionCancelMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionCreateQueueMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionRemoveAddressMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionSendMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXACommitMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXAEndMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXAForgetMessageCodec;
-import org.jboss.messaging.core.remoting.codec.SessionXAGetInDoubtXidsResponseCodec;
-import org.jboss.messaging.core.remoting.codec.SessionXAGetTimeoutResponseCodec;
+import org.jboss.messaging.core.remoting.codec.SessionXAGetInDoubtXidsResponseMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionXAGetTimeoutResponseMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXAJoinMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXAPrepareMessageCodec;
-import org.jboss.messaging.core.remoting.codec.SessionXAResponseCodec;
+import org.jboss.messaging.core.remoting.codec.SessionXAResponseMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXAResumeMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXARollbackMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXASetTimeoutMessageCodec;
-import org.jboss.messaging.core.remoting.codec.SessionXASetTimeoutResponseCodec;
+import org.jboss.messaging.core.remoting.codec.SessionXASetTimeoutResponseMessageCodec;
 import org.jboss.messaging.core.remoting.codec.SessionXAStartMessageCodec;
-import org.jboss.messaging.core.remoting.codec.SetClientIDMessageCodec;
-import org.jboss.messaging.core.remoting.codec.SetSessionIDMessageCodec;
+import org.jboss.messaging.core.remoting.codec.SessionSetIDMessageCodec;
 import org.jboss.messaging.core.remoting.codec.TextPacketCodec;
-import org.jboss.messaging.core.remoting.codec.UnsubscribeMessageCodec;
 import org.jboss.messaging.core.remoting.impl.mina.PacketCodecFactory;
 import org.jboss.messaging.core.remoting.impl.mina.MinaPacketCodec.BufferWrapper;
 import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.AddTemporaryDestinationMessage;
-import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageRequest;
-import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageResponse;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockRequest;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockResponse;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageRequest;
-import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageResponse;
-import org.jboss.messaging.core.remoting.wireformat.BrowserResetMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBindingQueryMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBindingQueryResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserHasNextMessageMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserHasNextMessageResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageBlockMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageBlockResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserNextMessageResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionBrowserResetMessage;
 import org.jboss.messaging.core.remoting.wireformat.BytesPacket;
 import org.jboss.messaging.core.remoting.wireformat.CloseMessage;
-import org.jboss.messaging.core.remoting.wireformat.ClosingMessage;
 import org.jboss.messaging.core.remoting.wireformat.ConsumerChangeRateMessage;
-import org.jboss.messaging.core.remoting.wireformat.CreateBrowserRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateBrowserResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateBrowserMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateBrowserResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.CreateConnectionRequest;
 import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateConsumerRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateConsumerResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateDestinationRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateDestinationResponse;
-import org.jboss.messaging.core.remoting.wireformat.CreateSessionRequest;
-import org.jboss.messaging.core.remoting.wireformat.CreateSessionResponse;
-import org.jboss.messaging.core.remoting.wireformat.DeleteTemporaryDestinationMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateConsumerMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateConsumerResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionCreateQueueMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionCreateSessionMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionCreateSessionResponseMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionDeleteQueueMessage;
 import org.jboss.messaging.core.remoting.wireformat.DeliverMessage;
-import org.jboss.messaging.core.remoting.wireformat.GetClientIDRequest;
-import org.jboss.messaging.core.remoting.wireformat.GetClientIDResponse;
-import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
 import org.jboss.messaging.core.remoting.wireformat.NullPacket;
 import org.jboss.messaging.core.remoting.wireformat.PacketType;
 import org.jboss.messaging.core.remoting.wireformat.Ping;
 import org.jboss.messaging.core.remoting.wireformat.Pong;
+import org.jboss.messaging.core.remoting.wireformat.SessionQueueQueryMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionQueueQueryResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionAcknowledgeMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionAddAddressMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionCancelMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionCommitMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionRecoverMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionRemoveAddressMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionRollbackMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionSendMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXACommitMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAEndMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAForgetMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsRequest;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetInDoubtXidsResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAGetTimeoutResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAJoinMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAPrepareMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXAResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXAResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAResumeMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXARollbackMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutMessage;
-import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutResponse;
+import org.jboss.messaging.core.remoting.wireformat.SessionXASetTimeoutResponseMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXAStartMessage;
 import org.jboss.messaging.core.remoting.wireformat.SessionXASuspendMessage;
-import org.jboss.messaging.core.remoting.wireformat.SetClientIDMessage;
-import org.jboss.messaging.core.remoting.wireformat.SetSessionIDMessage;
-import org.jboss.messaging.core.remoting.wireformat.StartConnectionMessage;
-import org.jboss.messaging.core.remoting.wireformat.StopConnectionMessage;
+import org.jboss.messaging.core.remoting.wireformat.SessionSetIDMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionStartMessage;
+import org.jboss.messaging.core.remoting.wireformat.ConnectionStopMessage;
 import org.jboss.messaging.core.remoting.wireformat.TextPacket;
-import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
 import org.jboss.messaging.test.unit.RandomUtil;
 import org.jboss.messaging.test.unit.UnitTestCase;
 import org.jboss.messaging.util.Logger;
@@ -366,28 +373,6 @@
       assertEquals(packet.getTargetID(), p.getTargetID());
    }
 
-   public void testJMSExceptionMessage() throws Exception
-   {
-      JMSException e = new InvalidDestinationException(
-            "testJMSExceptionMessage");
-      JMSExceptionMessage message = new JMSExceptionMessage(e);
-
-      AbstractPacketCodec<JMSExceptionMessage> codec = new JMSExceptionMessageCodec();
-      SimpleRemotingBuffer buffer = encode(message, codec);
-      checkHeader(buffer, message);
-      checkBody(buffer, JMSExceptionMessageCodec.encodeJMSException(e));
-      buffer.rewind();
-
-      AbstractPacket decodedPacket = codec.decode(buffer);
-
-      assertTrue(decodedPacket instanceof JMSExceptionMessage);
-      JMSExceptionMessage decodedMessage = (JMSExceptionMessage) decodedPacket;
-
-      assertEquals(MSG_JMSEXCEPTION, decodedMessage.getType());
-      assertEquals(message.getException().getMessage(), decodedMessage
-            .getException().getMessage());
-   }
-
    public void testPing() throws Exception
    {
       Ping packet = new Ping();
@@ -462,9 +447,9 @@
 
    public void testSetSessionIDMessage() throws Exception
    {
-      SetSessionIDMessage message = new SetSessionIDMessage(randomString());
+      SessionSetIDMessage message = new SessionSetIDMessage(randomString());
 
-      AbstractPacketCodec codec = new SetSessionIDMessageCodec();
+      AbstractPacketCodec codec = new SessionSetIDMessageCodec();
       SimpleRemotingBuffer buffer = encode(message, codec);
       checkHeader(buffer, message);
       checkBody(buffer, message.getSessionID());
@@ -472,9 +457,9 @@
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof SetSessionIDMessage);
-      SetSessionIDMessage decodedMessage = (SetSessionIDMessage) decodedPacket;
-      assertEquals(MSG_SETSESSIONID, decodedMessage.getType());
+      assertTrue(decodedPacket instanceof SessionSetIDMessage);
+      SessionSetIDMessage decodedMessage = (SessionSetIDMessage) decodedPacket;
+      assertEquals(SESS_SETID, decodedMessage.getType());
       assertEquals(message.getSessionID(), decodedMessage.getSessionID());
    }
    
@@ -486,18 +471,15 @@
       String username = null;
       String password = null;
       int prefetchSize = 0;
-      int dupsOkBatchSize = 150;
-      String clientID = null;
-
+ 
       CreateConnectionRequest request = new CreateConnectionRequest(version,
-            remotingSessionID, clientVMID, username, password, prefetchSize,
-            dupsOkBatchSize, null);
+            remotingSessionID, clientVMID, username, password, prefetchSize);
 
-      AbstractPacketCodec<CreateConnectionRequest> codec = new ConnectionFactoryCreateConnectionRequestCodec();
+      AbstractPacketCodec<CreateConnectionRequest> codec = new CreateConnectionMessageCodec();
       SimpleRemotingBuffer buffer = encode(request, codec);
       checkHeader(buffer, request);
       checkBody(buffer, version, remotingSessionID, clientVMID, username,
-            password, prefetchSize, dupsOkBatchSize, clientID);
+            password, prefetchSize);
       buffer.rewind();
 
       AbstractPacket decodedPacket = codec.decode(buffer);
@@ -505,7 +487,7 @@
       assertTrue(decodedPacket instanceof CreateConnectionRequest);
       CreateConnectionRequest decodedRequest = (CreateConnectionRequest) decodedPacket;
 
-      assertEquals(REQ_CREATECONNECTION, decodedPacket.getType());
+      assertEquals(CREATECONNECTION, decodedPacket.getType());
       assertEquals(request.getVersion(), decodedRequest.getVersion());
       assertEquals(request.getRemotingSessionID(), decodedRequest
             .getRemotingSessionID());
@@ -519,7 +501,7 @@
       CreateConnectionResponse response = new CreateConnectionResponse(
             randomString());
 
-      AbstractPacketCodec<CreateConnectionResponse> codec = new ConnectionFactoryCreateConnectionResponseCodec();
+      AbstractPacketCodec<CreateConnectionResponse> codec = new CreateConnectionResponseMessageCodec();
       SimpleRemotingBuffer buffer = encode(response, codec);
       checkHeader(buffer, response);
       checkBody(buffer, response.getConnectionID());
@@ -529,199 +511,122 @@
 
       assertTrue(decodedPacket instanceof CreateConnectionResponse);
       CreateConnectionResponse decodedResponse = (CreateConnectionResponse) decodedPacket;
-      assertEquals(RESP_CREATECONNECTION, decodedResponse.getType());
+      assertEquals(CREATECONNECTION_RESP, decodedResponse.getType());
       assertEquals(response.getConnectionID(), decodedResponse
             .getConnectionID());
    }
 
    public void testCreateSessionRequest() throws Exception
    {
-      CreateSessionRequest request = new CreateSessionRequest(true, 0, false);
+      //TODO test this more thoroughly
+      
+      ConnectionCreateSessionMessage request = new ConnectionCreateSessionMessage(true, true, true);
 
-      AbstractPacketCodec codec = new CreateSessionRequestCodec();
+      AbstractPacketCodec codec = new ConnectionCreateSessionMessageCodec();
       SimpleRemotingBuffer buffer = encode(request, codec);
       checkHeader(buffer, request);
-      checkBody(buffer, request.isTransacted(), request
-            .getAcknowledgementMode(), request.isXA());
+      checkBody(buffer, request.isXA(), request.isAutoCommitSends(), request.isAutoCommitAcks());
       buffer.rewind();
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof CreateSessionRequest);
-      CreateSessionRequest decodedRequest = (CreateSessionRequest) decodedPacket;
-      assertEquals(REQ_CREATESESSION, decodedRequest.getType());
-      assertEquals(request.isTransacted(), decodedRequest.isTransacted());
-      assertEquals(request.getAcknowledgementMode(), decodedRequest
-            .getAcknowledgementMode());
+      assertTrue(decodedPacket instanceof ConnectionCreateSessionMessage);
+      ConnectionCreateSessionMessage decodedRequest = (ConnectionCreateSessionMessage) decodedPacket;
+      assertEquals(CONN_CREATESESSION, decodedRequest.getType());
       assertEquals(request.isXA(), decodedRequest.isXA());
+      assertEquals(request.isAutoCommitSends(), decodedRequest.isAutoCommitSends());
+      assertEquals(request.isAutoCommitAcks(), decodedRequest.isAutoCommitAcks());
+      assertEquals(request.isXA(), decodedRequest.isXA());
    }
 
    public void testCreateSessionResponse() throws Exception
    {
-      CreateSessionResponse response = new CreateSessionResponse(
-            randomString(), 23);
+      ConnectionCreateSessionResponseMessage response = new ConnectionCreateSessionResponseMessage(randomString());
 
-      AbstractPacketCodec codec = new CreateSessionResponseCodec();
+      AbstractPacketCodec codec = new ConnectionCreateSessionResponseMessageCodec();
       SimpleRemotingBuffer buffer = encode(response, codec);
       checkHeader(buffer, response);
-      checkBody(buffer, response.getSessionID(), response.getDupsOKBatchSize());
+      checkBody(buffer, response.getSessionID());
       buffer.rewind();
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof CreateSessionResponse);
-      CreateSessionResponse decodedResponse = (CreateSessionResponse) decodedPacket;
-      assertEquals(RESP_CREATESESSION, decodedResponse.getType());
+      assertTrue(decodedPacket instanceof ConnectionCreateSessionResponseMessage);
+      ConnectionCreateSessionResponseMessage decodedResponse = (ConnectionCreateSessionResponseMessage) decodedPacket;
+      assertEquals(CONN_CREATESESSION_RESP, decodedResponse.getType());
       assertEquals(response.getSessionID(), decodedResponse.getSessionID());
-      assertEquals(response.getDupsOKBatchSize(), decodedResponse
-            .getDupsOKBatchSize());
    }
 
    public void testSendMessage() throws Exception
    {
-      SessionSendMessage packet = new SessionSendMessage(new MessageImpl());
+      SessionSendMessage packet = new SessionSendMessage(randomString(), new MessageImpl());
 
       AbstractPacketCodec codec = new SessionSendMessageCodec();
       SimpleRemotingBuffer buffer = encode(packet, codec);
       checkHeader(buffer, packet);
-      checkBody(buffer, encodeMessage(packet.getMessage()));
+      checkBody(buffer, packet.getAddress(), encodeMessage(packet.getMessage()));
       buffer.rewind();
 
       AbstractPacket p = codec.decode(buffer);
 
       assertTrue(p instanceof SessionSendMessage);
       SessionSendMessage decodedPacket = (SessionSendMessage) p;
-      assertEquals(MSG_SENDMESSAGE, decodedPacket.getType());
+      assertEquals(SESS_SEND, decodedPacket.getType());
+      assertEquals(packet.getAddress(), decodedPacket.getAddress());
       assertEquals(packet.getMessage().getMessageID(), decodedPacket
             .getMessage().getMessageID());
    }
 
    public void testCreateConsumerRequest() throws Exception
-   {
-      Destination destination = new DestinationImpl(DestinationType.QUEUE,
-            "testCreateConsumerRequest", false);
-      CreateConsumerRequest request = new CreateConsumerRequest(destination,
-            "color = 'red'", false, "subscription", false);
+   {      
+      String destination = "queue.testCreateConsumerRequest";
+      SessionCreateConsumerMessage request = new SessionCreateConsumerMessage(destination,
+            "color = 'red'", false, false);
 
-      AbstractPacketCodec codec = new CreateConsumerRequestCodec();
+      AbstractPacketCodec codec = new SessionCreateConsumerMessageCodec();
       SimpleRemotingBuffer buffer = encode(request, codec);
       checkHeader(buffer, request);
-      checkBody(buffer, AbstractPacketCodec.encode(destination), request
-            .getSelector(), request.isNoLocal(), request.getSubscriptionName(),
-            request.isConnectionConsumer());
+      checkBody(buffer, request.getQueueName(), request
+            .getFilterString(), request.isNoLocal(), request.isAutoDeleteQueue());
       buffer.rewind();
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof CreateConsumerRequest);
-      CreateConsumerRequest decodedRequest = (CreateConsumerRequest) decodedPacket;
-      assertEquals(REQ_CREATECONSUMER, decodedRequest.getType());
-      assertEquals(request.getDestination(), decodedRequest.getDestination());
-      assertEquals(request.getSelector(), decodedRequest.getSelector());
+      assertTrue(decodedPacket instanceof SessionCreateConsumerMessage);
+      SessionCreateConsumerMessage decodedRequest = (SessionCreateConsumerMessage) decodedPacket;
+      assertEquals(SESS_CREATECONSUMER, decodedRequest.getType());
+      assertEquals(request.getQueueName(), decodedRequest.getQueueName());
+      assertEquals(request.getFilterString(), decodedRequest.getFilterString());
       assertEquals(request.isNoLocal(), decodedRequest.isNoLocal());
-      assertEquals(request.getSubscriptionName(), decodedRequest
-            .getSubscriptionName());
-      assertEquals(request.isConnectionConsumer(), decodedRequest
-            .isConnectionConsumer());
-      ;
+      assertEquals(request.isAutoDeleteQueue(), decodedRequest.isAutoDeleteQueue());
    }
 
-   public void testCreateDestinationRequest() throws Exception
-   {
-      CreateDestinationRequest request = new CreateDestinationRequest(
-            "testCreateDestinationRequest", false);
-
-      AbstractPacketCodec codec = new CreateDestinationRequestCodec();
-      SimpleRemotingBuffer buffer = encode(request, codec);
-      checkHeader(buffer, request);
-      checkBody(buffer, request.getName(), request.isQueue());
-      buffer.rewind();
-
-      AbstractPacket decodedPacket = codec.decode(buffer);
-
-      assertTrue(decodedPacket instanceof CreateDestinationRequest);
-      CreateDestinationRequest decodedRequest = (CreateDestinationRequest) decodedPacket;
-      assertEquals(REQ_CREATEDESTINATION, decodedRequest.getType());
-      assertEquals(request.getName(), decodedRequest.getName());
-      assertEquals(request.isQueue(), decodedRequest.isQueue());
-   }
-
-   public void testCreateDestinationResponseForQueue() throws Exception
-   {
-      JBossQueue destination = new JBossQueue("testCreateQueueResponse");
-
-      CreateDestinationResponse response = new CreateDestinationResponse(
-            destination);
-
-      AbstractPacketCodec codec = new CreateDestinationResponseCodec();
-      SimpleRemotingBuffer buffer = encode(response, codec);
-      checkHeader(buffer, response);
-      checkBody(buffer, AbstractPacketCodec.encodeJBossDestination(destination));
-      buffer.rewind();
-
-      AbstractPacket decodedPacket = codec.decode(buffer);
-
-      assertTrue(decodedPacket instanceof CreateDestinationResponse);
-      CreateDestinationResponse decodedResponse = (CreateDestinationResponse) decodedPacket;
-      assertEquals(RESP_CREATEDESTINATION, decodedResponse.getType());
-      assertTrue(decodedResponse.getDestination() instanceof JBossQueue);
-      assertEquals(response.getDestination(), decodedResponse.getDestination());
-   }
-
-   public void testCreateDestinationResponseForTopic() throws Exception
-   {
-      JBossTopic destination = new JBossTopic(
-            "testCreateDestinationResponseForTopic");
-
-      CreateDestinationResponse response = new CreateDestinationResponse(
-            destination);
-
-      AbstractPacketCodec codec = new CreateDestinationResponseCodec();
-      SimpleRemotingBuffer buffer = encode(response, codec);
-      checkHeader(buffer, response);
-      checkBody(buffer, AbstractPacketCodec.encodeJBossDestination(destination));
-      buffer.rewind();
-
-      AbstractPacket decodedPacket = codec.decode(buffer);
-
-      assertTrue(decodedPacket instanceof CreateDestinationResponse);
-      CreateDestinationResponse decodedResponse = (CreateDestinationResponse) decodedPacket;
-      assertEquals(RESP_CREATEDESTINATION, decodedResponse.getType());
-      assertTrue(decodedResponse.getDestination() instanceof JBossTopic);
-      assertEquals(response.getDestination(), decodedResponse.getDestination());
-   }
-
    public void testCreateConsumerResponse() throws Exception
    {
 
-      CreateConsumerResponse response = new CreateConsumerResponse(
-            randomString(), 23, 42, randomLong());
+      SessionCreateConsumerResponseMessage response = new SessionCreateConsumerResponseMessage(
+            randomString(), RandomUtil.randomInt());
 
-      AbstractPacketCodec codec = new CreateConsumerResponseCodec();
+      AbstractPacketCodec codec = new SessionCreateConsumerResponseMessageCodec();
       SimpleRemotingBuffer buffer = encode(response, codec);
       checkHeader(buffer, response);
-      checkBody(buffer, response.getConsumerID(), response.getBufferSize(),
-            response.getMaxDeliveries(), response.getRedeliveryDelay());
+      checkBody(buffer, response.getConsumerID(), response.getBufferSize());
       buffer.rewind();
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof CreateConsumerResponse);
-      CreateConsumerResponse decodedResponse = (CreateConsumerResponse) decodedPacket;
-      assertEquals(RESP_CREATECONSUMER, decodedResponse.getType());
+      assertTrue(decodedPacket instanceof SessionCreateConsumerResponseMessage);
+      SessionCreateConsumerResponseMessage decodedResponse = (SessionCreateConsumerResponseMessage) decodedPacket;
+      assertEquals(SESS_CREATECONSUMER_RESP, decodedResponse.getType());
       assertEquals(response.getBufferSize(), decodedResponse.getBufferSize());
-      assertEquals(response.getMaxDeliveries(), decodedResponse
-            .getMaxDeliveries());
-      assertEquals(response.getRedeliveryDelay(), decodedResponse
-            .getRedeliveryDelay());
    }
 
    public void testStartConnectionMessage() throws Exception
    {
-      StartConnectionMessage packet = new StartConnectionMessage();
+      ConnectionStartMessage packet = new ConnectionStartMessage();
 
       AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            MSG_STARTCONNECTION, StartConnectionMessage.class);
+            CONN_START, ConnectionStartMessage.class);
       SimpleRemotingBuffer buffer = encode(packet, codec);
       checkHeader(buffer, packet);
       checkBodyIsEmpty(buffer);
@@ -729,16 +634,16 @@
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof StartConnectionMessage);
-      assertEquals(MSG_STARTCONNECTION, decodedPacket.getType());
+      assertTrue(decodedPacket instanceof ConnectionStartMessage);
+      assertEquals(CONN_START, decodedPacket.getType());
    }
 
    public void testStopConnectionMessage() throws Exception
    {
-      StopConnectionMessage packet = new StopConnectionMessage();
+      ConnectionStopMessage packet = new ConnectionStopMessage();
 
       AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            MSG_STOPCONNECTION, StopConnectionMessage.class);
+            CONN_STOP, ConnectionStopMessage.class);
       SimpleRemotingBuffer buffer = encode(packet, codec);
       checkHeader(buffer, packet);
       checkBodyIsEmpty(buffer);
@@ -746,8 +651,8 @@
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof StopConnectionMessage);
-      assertEquals(MSG_STOPCONNECTION, decodedPacket.getType());
+      assertTrue(decodedPacket instanceof ConnectionStopMessage);
+      assertEquals(CONN_STOP, decodedPacket.getType());
    }
 
    public void testChangeRateMessage() throws Exception
@@ -763,7 +668,7 @@
 
       assertTrue(decodedPacket instanceof ConsumerChangeRateMessage);
       ConsumerChangeRateMessage decodedMessage = (ConsumerChangeRateMessage) decodedPacket;
-      assertEquals(MSG_CHANGERATE, decodedMessage.getType());
+      assertEquals(CONS_CHANGERATE, decodedMessage.getType());
       assertEquals(message.getRate(), decodedMessage.getRate());
    }
 
@@ -783,7 +688,7 @@
 
       assertTrue(decodedPacket instanceof DeliverMessage);
       DeliverMessage decodedMessage = (DeliverMessage) decodedPacket;
-      assertEquals(MSG_DELIVERMESSAGE, decodedMessage.getType());
+      assertEquals(SESS_DELIVER, decodedMessage.getType());
       assertEquals(message.getMessage().getMessageID(), decodedMessage
             .getMessage().getMessageID());
       assertEquals(message.getDeliveryID(), decodedMessage.getDeliveryID());
@@ -806,7 +711,7 @@
 
       assertTrue(decodedPacket instanceof SessionAcknowledgeMessage);
       SessionAcknowledgeMessage decodedMessage = (SessionAcknowledgeMessage) decodedPacket;
-      assertEquals(MSG_ACKNOWLEDGE, decodedMessage.getType());
+      assertEquals(SESS_ACKNOWLEDGE, decodedMessage.getType());
       assertEquals(message.getDeliveryID(), decodedMessage.getDeliveryID());
       assertEquals(message.isAllUpTo(), decodedMessage.isAllUpTo());
    }
@@ -826,7 +731,7 @@
 
       assertTrue(decodedPacket instanceof SessionCancelMessage);
       SessionCancelMessage decodedMessage = (SessionCancelMessage) decodedPacket;
-      assertEquals(MSG_CANCEL, decodedMessage.getType());
+      assertEquals(SESS_CANCEL, decodedMessage.getType());
       assertEquals(message.getDeliveryID(), decodedMessage.getDeliveryID());
       assertEquals(message.isExpired(), decodedMessage.isExpired());
    }
@@ -836,7 +741,7 @@
       SessionCommitMessage message = new SessionCommitMessage();
 
       AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            MSG_COMMIT, SessionCommitMessage.class);
+            SESS_COMMIT, SessionCommitMessage.class);
       SimpleRemotingBuffer buffer = encode(message, codec);
       checkHeader(buffer, message);
       checkBodyIsEmpty(buffer);
@@ -846,7 +751,7 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
 
       assertTrue(decodedPacket instanceof SessionCommitMessage);
-      assertEquals(MSG_COMMIT, decodedPacket.getType());
+      assertEquals(SESS_COMMIT, decodedPacket.getType());
    }
 
    public void testSessionRollbackMessage() throws Exception
@@ -854,7 +759,7 @@
       SessionRollbackMessage message = new SessionRollbackMessage();
 
       AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            MSG_ROLLBACK, SessionRollbackMessage.class);
+            SESS_ROLLBACK, SessionRollbackMessage.class);
       SimpleRemotingBuffer buffer = encode(message, codec);
       checkHeader(buffer, message);
       checkBodyIsEmpty(buffer);
@@ -864,7 +769,7 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
 
       assertTrue(decodedPacket instanceof SessionRollbackMessage);
-      assertEquals(MSG_ROLLBACK, decodedPacket.getType());
+      assertEquals(SESS_ROLLBACK, decodedPacket.getType());
    }
    
    public void testSessionRecoverMessage() throws Exception
@@ -872,7 +777,7 @@
       SessionRecoverMessage message = new SessionRecoverMessage();
 
       AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            MSG_RECOVER, SessionRecoverMessage.class);
+            SESS_RECOVER, SessionRecoverMessage.class);
       SimpleRemotingBuffer buffer = encode(message, codec);
       checkHeader(buffer, message);
       checkBodyIsEmpty(buffer);
@@ -882,34 +787,15 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
 
       assertTrue(decodedPacket instanceof SessionRecoverMessage);
-      assertEquals(MSG_RECOVER, decodedPacket.getType());
+      assertEquals(SESS_RECOVER, decodedPacket.getType());
    }
 
-   public void testClosingMessage() throws Exception
-   {
-      ClosingMessage request = new ClosingMessage();
-
-      AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            PacketType.MSG_CLOSING, ClosingMessage.class);
-      SimpleRemotingBuffer buffer = encode(request, codec);
-      checkHeader(buffer, request);
-      checkBodyIsEmpty(buffer);
-
-      buffer.rewind();
-
-      AbstractPacket decodedPacket = codec.decode(buffer);
-
-      assertTrue(decodedPacket instanceof ClosingMessage);
-      ClosingMessage decodedRequest = (ClosingMessage) decodedPacket;
-      assertEquals(PacketType.MSG_CLOSING, decodedRequest.getType());
-   }
-
    public void testCloseMessage() throws Exception
    {
       CloseMessage message = new CloseMessage();
 
       AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            MSG_CLOSE, CloseMessage.class);
+            CLOSE, CloseMessage.class);
       SimpleRemotingBuffer buffer = encode(message, codec);
       checkHeader(buffer, message);
       checkBodyIsEmpty(buffer);
@@ -919,90 +805,36 @@
 
       assertTrue(decodedPacket instanceof CloseMessage);
       CloseMessage decodedMessage = (CloseMessage) decodedPacket;
-      assertEquals(MSG_CLOSE, decodedMessage.getType());
+      assertEquals(CLOSE, decodedMessage.getType());
    }
 
-   public void testGetClientIDRequest() throws Exception
-   {
-      GetClientIDRequest request = new GetClientIDRequest();
 
-      AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            REQ_GETCLIENTID, GetClientIDRequest.class);
-      SimpleRemotingBuffer buffer = encode(request, codec);
-      checkHeader(buffer, request);
-      checkBodyIsEmpty(buffer);
-      buffer.rewind();
-
-      AbstractPacket decodedPacket = codec.decode(buffer);
-
-      assertTrue(decodedPacket instanceof GetClientIDRequest);
-      assertEquals(REQ_GETCLIENTID, decodedPacket.getType());
-   }
-
-   public void testGetClientIDResponse() throws Exception
-   {
-      GetClientIDResponse response = new GetClientIDResponse(randomString());
-
-      AbstractPacketCodec codec = new GetClientIDResponseCodec();
-      SimpleRemotingBuffer buffer = encode(response, codec);
-      checkHeader(buffer, response);
-      checkBody(buffer, response.getClientID());
-      buffer.rewind();
-
-      AbstractPacket decodedPacket = codec.decode(buffer);
-
-      assertTrue(decodedPacket instanceof GetClientIDResponse);
-      GetClientIDResponse decodedResponse = (GetClientIDResponse) decodedPacket;
-      assertEquals(RESP_GETCLIENTID, decodedResponse.getType());
-      assertEquals(response.getClientID(), decodedResponse.getClientID());
-   }
-
-   public void testSetClientIDMessage() throws Exception
-   {
-      SetClientIDMessage message = new SetClientIDMessage(randomString());
-
-      AbstractPacketCodec codec = new SetClientIDMessageCodec();
-      SimpleRemotingBuffer buffer = encode(message, codec);
-      checkHeader(buffer, message);
-      checkBody(buffer, message.getClientID());
-      buffer.rewind();
-
-      AbstractPacket decodedPacket = codec.decode(buffer);
-
-      assertTrue(decodedPacket instanceof SetClientIDMessage);
-      SetClientIDMessage decodedMessage = (SetClientIDMessage) decodedPacket;
-      assertEquals(MSG_SETCLIENTID, decodedMessage.getType());
-      assertEquals(message.getClientID(), decodedMessage.getClientID());
-   }
-
    public void testCreateBrowserRequest() throws Exception
    {
-      Destination destination = new DestinationImpl(DestinationType.QUEUE,
-            "testCreateBrowserRequest", false);
-      CreateBrowserRequest request = new CreateBrowserRequest(destination,
+      String destination = "queue.testCreateBrowserRequest";
+      SessionCreateBrowserMessage request = new SessionCreateBrowserMessage(destination,
             "color = 'red'");
 
-      AbstractPacketCodec codec = new CreateBrowserRequestCodec();
+      AbstractPacketCodec codec = new SessionCreateBrowserMessageCodec();
       SimpleRemotingBuffer buffer = encode(request, codec);
       checkHeader(buffer, request);
-      checkBody(buffer, AbstractPacketCodec.encode(destination), request
-            .getSelector());
+      checkBody(buffer, request.getQueueName(), request.getFilterString());
       buffer.rewind();
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof CreateBrowserRequest);
-      CreateBrowserRequest decodedRequest = (CreateBrowserRequest) decodedPacket;
-      assertEquals(REQ_CREATEBROWSER, decodedRequest.getType());
-      assertEquals(request.getDestination(), decodedRequest.getDestination());
-      assertEquals(request.getSelector(), decodedRequest.getSelector());
+      assertTrue(decodedPacket instanceof SessionCreateBrowserMessage);
+      SessionCreateBrowserMessage decodedRequest = (SessionCreateBrowserMessage) decodedPacket;
+      assertEquals(SESS_CREATEBROWSER, decodedRequest.getType());
+      assertEquals(request.getQueueName(), decodedRequest.getQueueName());
+      assertEquals(request.getFilterString(), decodedRequest.getFilterString());
    }
 
    public void testCreateBrowserResponse() throws Exception
    {
-      CreateBrowserResponse response = new CreateBrowserResponse(randomString());
+      SessionCreateBrowserResponseMessage response = new SessionCreateBrowserResponseMessage(randomString());
 
-      AbstractPacketCodec codec = new CreateBrowserResponseCodec();
+      AbstractPacketCodec codec = new SessionCreateBrowserResponseMessageCodec();
       SimpleRemotingBuffer buffer = encode(response, codec);
       checkHeader(buffer, response);
       checkBody(buffer, response.getBrowserID());
@@ -1010,18 +842,18 @@
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof CreateBrowserResponse);
-      CreateBrowserResponse decodedResponse = (CreateBrowserResponse) decodedPacket;
-      assertEquals(RESP_CREATEBROWSER, decodedResponse.getType());
+      assertTrue(decodedPacket instanceof SessionCreateBrowserResponseMessage);
+      SessionCreateBrowserResponseMessage decodedResponse = (SessionCreateBrowserResponseMessage) decodedPacket;
+      assertEquals(SESS_CREATEBROWSER_RESP, decodedResponse.getType());
       assertEquals(response.getBrowserID(), decodedResponse.getBrowserID());
    }
 
    public void testBrowserResetMessage() throws Exception
    {
-      BrowserResetMessage message = new BrowserResetMessage();
+      SessionBrowserResetMessage message = new SessionBrowserResetMessage();
 
       AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            MSG_BROWSER_RESET, BrowserResetMessage.class);
+            SESS_BROWSER_RESET, SessionBrowserResetMessage.class);
       SimpleRemotingBuffer buffer = encode(message, codec);
       checkHeader(buffer, message);
       checkBodyIsEmpty(buffer);
@@ -1029,16 +861,16 @@
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof BrowserResetMessage);
-      assertEquals(MSG_BROWSER_RESET, decodedPacket.getType());
+      assertTrue(decodedPacket instanceof SessionBrowserResetMessage);
+      assertEquals(SESS_BROWSER_RESET, decodedPacket.getType());
    }
 
    public void testBrowserHasNextMessageRequest() throws Exception
    {
-      BrowserHasNextMessageRequest request = new BrowserHasNextMessageRequest();
+      SessionBrowserHasNextMessageMessage request = new SessionBrowserHasNextMessageMessage();
 
       AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            REQ_BROWSER_HASNEXTMESSAGE, BrowserHasNextMessageRequest.class);
+            SESS_BROWSER_HASNEXTMESSAGE, SessionBrowserHasNextMessageMessage.class);
       SimpleRemotingBuffer buffer = encode(request, codec);
       checkHeader(buffer, request);
       checkBodyIsEmpty(buffer);
@@ -1046,15 +878,15 @@
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof BrowserHasNextMessageRequest);
-      assertEquals(REQ_BROWSER_HASNEXTMESSAGE, decodedPacket.getType());
+      assertTrue(decodedPacket instanceof SessionBrowserHasNextMessageMessage);
+      assertEquals(SESS_BROWSER_HASNEXTMESSAGE, decodedPacket.getType());
    }
 
    public void testBrowserHasNextMessageResponse() throws Exception
    {
-      BrowserHasNextMessageResponse response = new BrowserHasNextMessageResponse(
+      SessionBrowserHasNextMessageResponseMessage response = new SessionBrowserHasNextMessageResponseMessage(
             false);
-      AbstractPacketCodec codec = new BrowserHasNextMessageResponseCodec();
+      AbstractPacketCodec codec = new SessionBrowserHasNextMessageResponseMessageCodec();
       SimpleRemotingBuffer buffer = encode(response, codec);
       checkHeader(buffer, response);
       checkBody(buffer, response.hasNext());
@@ -1062,18 +894,18 @@
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof BrowserHasNextMessageResponse);
-      BrowserHasNextMessageResponse decodedResponse = (BrowserHasNextMessageResponse) decodedPacket;
-      assertEquals(RESP_BROWSER_HASNEXTMESSAGE, decodedResponse.getType());
+      assertTrue(decodedPacket instanceof SessionBrowserHasNextMessageResponseMessage);
+      SessionBrowserHasNextMessageResponseMessage decodedResponse = (SessionBrowserHasNextMessageResponseMessage) decodedPacket;
+      assertEquals(SESS_BROWSER_HASNEXTMESSAGE_RESP, decodedResponse.getType());
       assertEquals(response.hasNext(), decodedResponse.hasNext());
    }
 
    public void testBrowserNextMessageRequest() throws Exception
    {
-      BrowserNextMessageRequest request = new BrowserNextMessageRequest();
+      SessionBrowserNextMessageMessage request = new SessionBrowserNextMessageMessage();
 
       AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            REQ_BROWSER_NEXTMESSAGE, BrowserNextMessageRequest.class);
+            SESS_BROWSER_NEXTMESSAGE, SessionBrowserNextMessageMessage.class);
       SimpleRemotingBuffer buffer = encode(request, codec);
       checkHeader(buffer, request);
       checkBodyIsEmpty(buffer);
@@ -1081,16 +913,16 @@
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof BrowserNextMessageRequest);
-      assertEquals(REQ_BROWSER_NEXTMESSAGE, decodedPacket.getType());
+      assertTrue(decodedPacket instanceof SessionBrowserNextMessageMessage);
+      assertEquals(SESS_BROWSER_NEXTMESSAGE, decodedPacket.getType());
    }
 
    public void testBrowserNextMessageResponse() throws Exception
    {
       Message msg = new MessageImpl();
-      BrowserNextMessageResponse response = new BrowserNextMessageResponse(msg);
+      SessionBrowserNextMessageResponseMessage response = new SessionBrowserNextMessageResponseMessage(msg);
 
-      AbstractPacketCodec codec = new BrowserNextMessageResponseCodec();
+      AbstractPacketCodec codec = new SessionBrowserNextMessageResponseMessageCodec();
       SimpleRemotingBuffer buffer = encode(response, codec);
       checkHeader(buffer, response);
       checkBody(buffer, encodeMessage(msg));
@@ -1098,19 +930,19 @@
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof BrowserNextMessageResponse);
-      BrowserNextMessageResponse decodedResponse = (BrowserNextMessageResponse) decodedPacket;
-      assertEquals(RESP_BROWSER_NEXTMESSAGE, decodedResponse.getType());
+      assertTrue(decodedPacket instanceof SessionBrowserNextMessageResponseMessage);
+      SessionBrowserNextMessageResponseMessage decodedResponse = (SessionBrowserNextMessageResponseMessage) decodedPacket;
+      assertEquals(SESS_BROWSER_NEXTMESSAGE_RESP, decodedResponse.getType());
       assertEquals(response.getMessage().getMessageID(), decodedResponse
             .getMessage().getMessageID());
    }
 
    public void testBrowserNextMessageBlockRequest() throws Exception
    {
-      BrowserNextMessageBlockRequest request = new BrowserNextMessageBlockRequest(
+      SessionBrowserNextMessageBlockMessage request = new SessionBrowserNextMessageBlockMessage(
             randomLong());
 
-      AbstractPacketCodec codec = new BrowserNextMessageBlockRequestCodec();
+      AbstractPacketCodec codec = new SessionBrowserNextMessageBlockMessageCodec();
       SimpleRemotingBuffer buffer = encode(request, codec);
       checkHeader(buffer, request);
       checkBody(buffer, request.getMaxMessages());
@@ -1118,98 +950,37 @@
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof BrowserNextMessageBlockRequest);
-      BrowserNextMessageBlockRequest decodedRequest = (BrowserNextMessageBlockRequest) decodedPacket;
-      assertEquals(REQ_BROWSER_NEXTMESSAGEBLOCK, decodedPacket.getType());
+      assertTrue(decodedPacket instanceof SessionBrowserNextMessageBlockMessage);
+      SessionBrowserNextMessageBlockMessage decodedRequest = (SessionBrowserNextMessageBlockMessage) decodedPacket;
+      assertEquals(SESS_BROWSER_NEXTMESSAGEBLOCK, decodedPacket.getType());
       assertEquals(request.getMaxMessages(), decodedRequest.getMaxMessages());
    }
 
    public void testBrowserNextMessageBlockResponse() throws Exception
    {
       Message[] messages = new Message[] { new MessageImpl(), new MessageImpl() };
-      BrowserNextMessageBlockResponse response = new BrowserNextMessageBlockResponse(
+      SessionBrowserNextMessageBlockResponseMessage response = new SessionBrowserNextMessageBlockResponseMessage(
             messages);
 
-      AbstractPacketCodec codec = new BrowserNextMessageBlockResponseCodec();
+      AbstractPacketCodec codec = new SessionBrowserNextMessageBlockResponseMessageCodec();
       SimpleRemotingBuffer buffer = encode(response, codec);
       checkHeader(buffer, response);
-      checkBody(buffer, messages.length, BrowserNextMessageBlockResponseCodec
+      checkBody(buffer, messages.length, SessionBrowserNextMessageBlockResponseMessageCodec
             .encode(messages));
       buffer.rewind();
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof BrowserNextMessageBlockResponse);
-      BrowserNextMessageBlockResponse decodedResponse = (BrowserNextMessageBlockResponse) decodedPacket;
-      assertEquals(RESP_BROWSER_NEXTMESSAGEBLOCK, decodedResponse.getType());
+      assertTrue(decodedPacket instanceof SessionBrowserNextMessageBlockResponseMessage);
+      SessionBrowserNextMessageBlockResponseMessage decodedResponse = (SessionBrowserNextMessageBlockResponseMessage) decodedPacket;
+      assertEquals(SESS_BROWSER_NEXTMESSAGEBLOCK_RESP, decodedResponse.getType());
       assertEquals(response.getMessages()[0].getMessageID(), decodedResponse
             .getMessages()[0].getMessageID());
       assertEquals(response.getMessages()[1].getMessageID(), decodedResponse
             .getMessages()[1].getMessageID());
    }
 
-   public void testUnsubscribeMessage() throws Exception
-   {
-      UnsubscribeMessage message = new UnsubscribeMessage(
-            "testUnsubscribeMessage");
-
-      AbstractPacketCodec codec = new UnsubscribeMessageCodec();
-      SimpleRemotingBuffer buffer = encode(message, codec);
-      checkHeader(buffer, message);
-      checkBody(buffer, message.getSubscriptionName());
-      buffer.rewind();
-
-      AbstractPacket decodedPacket = codec.decode(buffer);
-
-      assertTrue(decodedPacket instanceof UnsubscribeMessage);
-      UnsubscribeMessage decodedMessage = (UnsubscribeMessage) decodedPacket;
-      assertEquals(MSG_UNSUBSCRIBE, decodedMessage.getType());
-      assertEquals(decodedMessage.getSubscriptionName(), message
-            .getSubscriptionName());
-   }
-
-   public void testAddTemporaryDestinationMessage() throws Exception
-   {
-      Destination destination = new DestinationImpl(DestinationType.QUEUE,
-            "testAddTemporaryDestinationMessage", false);
-      AddTemporaryDestinationMessage message = new AddTemporaryDestinationMessage(
-            destination);
-
-      AbstractPacketCodec codec = new AddTemporaryDestinationMessageCodec();
-      SimpleRemotingBuffer buffer = encode(message, codec);
-      checkHeader(buffer, message);
-      checkBody(buffer, AbstractPacketCodec.encode(destination));
-      buffer.rewind();
-
-      AbstractPacket decodedPacket = codec.decode(buffer);
-
-      assertTrue(decodedPacket instanceof AddTemporaryDestinationMessage);
-      AddTemporaryDestinationMessage decodedMessage = (AddTemporaryDestinationMessage) decodedPacket;
-      assertEquals(MSG_ADDTEMPORARYDESTINATION, decodedMessage.getType());
-      assertEquals(message.getDestination(), decodedMessage.getDestination());
-   }
-
-   public void testDeleteTemporaryDestinationMessage() throws Exception
-   {
-      Destination destination = new DestinationImpl(DestinationType.QUEUE,
-            "testDeleteTemporaryDestinationMessage", false);
-      
-      DeleteTemporaryDestinationMessage message = new DeleteTemporaryDestinationMessage(
-            destination);
-
-      AbstractPacketCodec codec = new DeleteTemporaryDestinationMessageCodec();
-      SimpleRemotingBuffer buffer = encode(message, codec);
-      checkHeader(buffer, message);
-      buffer.rewind();
-
-      AbstractPacket decodedPacket = codec.decode(buffer);
-
-      assertTrue(decodedPacket instanceof DeleteTemporaryDestinationMessage);
-      DeleteTemporaryDestinationMessage decodedMessage = (DeleteTemporaryDestinationMessage) decodedPacket;
-      assertEquals(MSG_DELETETEMPORARYDESTINATION, decodedMessage.getType());
-      assertEquals(message.getDestination(), decodedMessage.getDestination());
-   }
-   
+  
    public void testSesssionXACommitMessageOnePhase() throws Exception
    {
       this.testSessionXACommitMessage(true);
@@ -1232,7 +1003,7 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
       assertTrue(decodedPacket instanceof SessionXACommitMessage);
       SessionXACommitMessage decodedMessage = (SessionXACommitMessage)decodedPacket;
-      assertEquals(PacketType.MSG_XA_COMMIT, decodedMessage.getType());
+      assertEquals(SESS_XA_COMMIT, decodedMessage.getType());
       assertEquals(xid, decodedMessage.getXid());      
       assertEquals(onePhase, decodedMessage.isOnePhase());
    }
@@ -1259,7 +1030,7 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
       assertTrue(decodedPacket instanceof SessionXAEndMessage);
       SessionXAEndMessage decodedMessage = (SessionXAEndMessage)decodedPacket;
-      assertEquals(PacketType.MSG_XA_END, decodedMessage.getType());
+      assertEquals(SESS_XA_END, decodedMessage.getType());
       assertEquals(xid, decodedMessage.getXid());      
       assertEquals(failed, decodedMessage.isFailed());
    }
@@ -1276,16 +1047,16 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
       assertTrue(decodedPacket instanceof SessionXAForgetMessage);
       SessionXAForgetMessage decodedMessage = (SessionXAForgetMessage)decodedPacket;
-      assertEquals(PacketType.MSG_XA_FORGET, decodedMessage.getType());
+      assertEquals(SESS_XA_FORGET, decodedMessage.getType());
       assertEquals(xid, decodedMessage.getXid());      
    }
    
    public void testSessionXAGetInDoubtXidsMessage() throws Exception
    {
-      SessionXAGetInDoubtXidsRequest request = new SessionXAGetInDoubtXidsRequest();
+      SessionXAGetInDoubtXidsMessage request = new SessionXAGetInDoubtXidsMessage();
 
       AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            PacketType.REQ_XA_INDOUBT_XIDS, SessionXAGetInDoubtXidsRequest.class);
+            SESS_XA_INDOUBT_XIDS, SessionXAGetInDoubtXidsMessage.class);
       SimpleRemotingBuffer buffer = encode(request, codec);
       checkHeader(buffer, request);
       checkBodyIsEmpty(buffer);
@@ -1293,8 +1064,8 @@
 
       AbstractPacket decodedPacket = codec.decode(buffer);
 
-      assertTrue(decodedPacket instanceof SessionXAGetInDoubtXidsRequest);
-      assertEquals(PacketType.REQ_XA_INDOUBT_XIDS, decodedPacket.getType());            
+      assertTrue(decodedPacket instanceof SessionXAGetInDoubtXidsMessage);
+      assertEquals(SESS_XA_INDOUBT_XIDS, decodedPacket.getType());            
    }
    
    public void testSessionGetInDoubtXidsResponse() throws Exception
@@ -1306,16 +1077,16 @@
          xids.add(generateXid());
       }
       
-      SessionXAGetInDoubtXidsResponse message = new SessionXAGetInDoubtXidsResponse(xids);
-      AbstractPacketCodec codec = new SessionXAGetInDoubtXidsResponseCodec();
+      SessionXAGetInDoubtXidsResponseMessage message = new SessionXAGetInDoubtXidsResponseMessage(xids);
+      AbstractPacketCodec codec = new SessionXAGetInDoubtXidsResponseMessageCodec();
       SimpleRemotingBuffer buffer = encode(message, codec);
       checkHeader(buffer, message);
       buffer.rewind();
       
       AbstractPacket decodedPacket = codec.decode(buffer);
-      assertTrue(decodedPacket instanceof SessionXAGetInDoubtXidsResponse);
-      SessionXAGetInDoubtXidsResponse decodedMessage = (SessionXAGetInDoubtXidsResponse)decodedPacket;
-      assertEquals(PacketType.RESP_XA_INDOUBT_XIDS, decodedMessage.getType());
+      assertTrue(decodedPacket instanceof SessionXAGetInDoubtXidsResponseMessage);
+      SessionXAGetInDoubtXidsResponseMessage decodedMessage = (SessionXAGetInDoubtXidsResponseMessage)decodedPacket;
+      assertEquals(SESS_XA_INDOUBT_XIDS_RESP, decodedMessage.getType());
            
       List<Xid> decodedXids = decodedMessage.getXids();
       assertNotNull(decodedXids);
@@ -1332,7 +1103,7 @@
       SessionXAGetTimeoutMessage message = new SessionXAGetTimeoutMessage();
 
       AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            PacketType.MSG_XA_GET_TIMEOUT, SessionXAGetTimeoutMessage.class);
+            PacketType.SESS_XA_GET_TIMEOUT, SessionXAGetTimeoutMessage.class);
       SimpleRemotingBuffer buffer = encode(message, codec);
       checkHeader(buffer, message);
       checkBodyIsEmpty(buffer);
@@ -1341,23 +1112,23 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
 
       assertTrue(decodedPacket instanceof SessionXAGetTimeoutMessage);
-      assertEquals(PacketType.MSG_XA_GET_TIMEOUT, decodedPacket.getType());     
+      assertEquals(SESS_XA_GET_TIMEOUT, decodedPacket.getType());     
    }
    
    public void testSessionXAGetTimeoutResponse() throws Exception
    {
       final int timeout = RandomUtil.randomInt();
       
-      SessionXAGetTimeoutResponse message = new SessionXAGetTimeoutResponse(timeout);
-      AbstractPacketCodec codec = new SessionXAGetTimeoutResponseCodec();
+      SessionXAGetTimeoutResponseMessage message = new SessionXAGetTimeoutResponseMessage(timeout);
+      AbstractPacketCodec codec = new SessionXAGetTimeoutResponseMessageCodec();
       SimpleRemotingBuffer buffer = encode(message, codec);
       checkHeader(buffer, message);
       buffer.rewind();
       
       AbstractPacket decodedPacket = codec.decode(buffer);
-      assertTrue(decodedPacket instanceof SessionXAGetTimeoutResponse);
-      SessionXAGetTimeoutResponse decodedMessage = (SessionXAGetTimeoutResponse)decodedPacket;
-      assertEquals(PacketType.MSG_XA_GET_TIMEOUT_RESPONSE, decodedMessage.getType());
+      assertTrue(decodedPacket instanceof SessionXAGetTimeoutResponseMessage);
+      SessionXAGetTimeoutResponseMessage decodedMessage = (SessionXAGetTimeoutResponseMessage)decodedPacket;
+      assertEquals(SESS_XA_GET_TIMEOUT_RESP, decodedMessage.getType());
            
       assertEquals(timeout, decodedMessage.getTimeoutSeconds());
    }
@@ -1374,7 +1145,7 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
       assertTrue(decodedPacket instanceof SessionXAJoinMessage);
       SessionXAJoinMessage decodedMessage = (SessionXAJoinMessage)decodedPacket;
-      assertEquals(PacketType.MSG_XA_JOIN, decodedMessage.getType());
+      assertEquals(SESS_XA_JOIN, decodedMessage.getType());
       assertEquals(xid, decodedMessage.getXid());      
    }
    
@@ -1390,7 +1161,7 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
       assertTrue(decodedPacket instanceof SessionXAPrepareMessage);
       SessionXAPrepareMessage decodedMessage = (SessionXAPrepareMessage)decodedPacket;
-      assertEquals(PacketType.REQ_XA_PREPARE, decodedMessage.getType());
+      assertEquals(SESS_XA_PREPARE, decodedMessage.getType());
       assertEquals(xid, decodedMessage.getXid());      
    }
    
@@ -1420,16 +1191,16 @@
       
       String str = nullString ? null : RandomUtil.randomString();
       
-      SessionXAResponse message = new SessionXAResponse(error, responseCode, str);
-      AbstractPacketCodec codec = new SessionXAResponseCodec();
+      SessionXAResponseMessage message = new SessionXAResponseMessage(error, responseCode, str);
+      AbstractPacketCodec codec = new SessionXAResponseMessageCodec();
       SimpleRemotingBuffer buffer = encode(message, codec);
       checkHeader(buffer, message);
       buffer.rewind();
       
       AbstractPacket decodedPacket = codec.decode(buffer);
-      assertTrue(decodedPacket instanceof SessionXAResponse);
-      SessionXAResponse decodedMessage = (SessionXAResponse)decodedPacket;
-      assertEquals(PacketType.RESP_XA, decodedMessage.getType());
+      assertTrue(decodedPacket instanceof SessionXAResponseMessage);
+      SessionXAResponseMessage decodedMessage = (SessionXAResponseMessage)decodedPacket;
+      assertEquals(SESS_XA_RESP, decodedMessage.getType());
       assertEquals(error, decodedMessage.isError());
       assertEquals(responseCode, decodedMessage.getResponseCode());
       assertEquals(str, decodedMessage.getMessage());
@@ -1447,7 +1218,7 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
       assertTrue(decodedPacket instanceof SessionXAResumeMessage);
       SessionXAResumeMessage decodedMessage = (SessionXAResumeMessage)decodedPacket;
-      assertEquals(PacketType.MSG_XA_RESUME, decodedMessage.getType());
+      assertEquals(SESS_XA_RESUME, decodedMessage.getType());
       assertEquals(xid, decodedMessage.getXid());      
    }
    
@@ -1463,7 +1234,7 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
       assertTrue(decodedPacket instanceof SessionXARollbackMessage);
       SessionXARollbackMessage decodedMessage = (SessionXARollbackMessage)decodedPacket;
-      assertEquals(PacketType.MSG_XA_ROLLBACK, decodedMessage.getType());
+      assertEquals(SESS_XA_ROLLBACK, decodedMessage.getType());
       assertEquals(xid, decodedMessage.getXid());      
    }
    
@@ -1479,7 +1250,7 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
       assertTrue(decodedPacket instanceof SessionXASetTimeoutMessage);
       SessionXASetTimeoutMessage decodedMessage = (SessionXASetTimeoutMessage)decodedPacket;
-      assertEquals(PacketType.MSG_XA_SET_TIMEOUT, decodedMessage.getType());
+      assertEquals(SESS_XA_SET_TIMEOUT, decodedMessage.getType());
       assertEquals(timeout, decodedMessage.getTimeoutSeconds());      
    }
    
@@ -1496,16 +1267,16 @@
    private void testSessionXASetTimeoutResponseMessage(boolean ok) throws Exception
    {
       final int timeout = RandomUtil.randomInt();
-      SessionXASetTimeoutResponse message = new SessionXASetTimeoutResponse(ok);
-      AbstractPacketCodec codec = new SessionXASetTimeoutResponseCodec();
+      SessionXASetTimeoutResponseMessage message = new SessionXASetTimeoutResponseMessage(ok);
+      AbstractPacketCodec codec = new SessionXASetTimeoutResponseMessageCodec();
       SimpleRemotingBuffer buffer = encode(message, codec);
       checkHeader(buffer, message);
       buffer.rewind();
       
       AbstractPacket decodedPacket = codec.decode(buffer);
-      assertTrue(decodedPacket instanceof SessionXASetTimeoutResponse);
-      SessionXASetTimeoutResponse decodedMessage = (SessionXASetTimeoutResponse)decodedPacket;
-      assertEquals(PacketType.MSG_XA_SET_TIMEOUT_RESPONSE, decodedMessage.getType());
+      assertTrue(decodedPacket instanceof SessionXASetTimeoutResponseMessage);
+      SessionXASetTimeoutResponseMessage decodedMessage = (SessionXASetTimeoutResponseMessage)decodedPacket;
+      assertEquals(SESS_XA_SET_TIMEOUT_RESP, decodedMessage.getType());
       assertEquals(ok, decodedMessage.isOK());      
    }
    
@@ -1521,7 +1292,7 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
       assertTrue(decodedPacket instanceof SessionXAStartMessage);
       SessionXAStartMessage decodedMessage = (SessionXAStartMessage)decodedPacket;
-      assertEquals(PacketType.MSG_XA_START, decodedMessage.getType());
+      assertEquals(SESS_XA_START, decodedMessage.getType());
       assertEquals(xid, decodedMessage.getXid());      
    }
    
@@ -1530,7 +1301,7 @@
       SessionXASuspendMessage message = new SessionXASuspendMessage();
 
       AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
-            PacketType.MSG_XA_SUSPEND, SessionXASuspendMessage.class);
+            PacketType.SESS_XA_SUSPEND, SessionXASuspendMessage.class);
       SimpleRemotingBuffer buffer = encode(message, codec);
       checkHeader(buffer, message);
       checkBodyIsEmpty(buffer);
@@ -1539,9 +1310,190 @@
       AbstractPacket decodedPacket = codec.decode(buffer);
 
       assertTrue(decodedPacket instanceof SessionXASuspendMessage);
-      assertEquals(PacketType.MSG_XA_SUSPEND, decodedPacket.getType());     
+      assertEquals(SESS_XA_SUSPEND, decodedPacket.getType());     
    }
    
+   
+   public void testSessionRemoveAddressMessage() throws Exception
+   {
+      SessionRemoveAddressMessage message = new SessionRemoveAddressMessage(randomString());
+
+      AbstractPacketCodec codec = new SessionRemoveAddressMessageCodec();
+      
+      SimpleRemotingBuffer buffer = encode(message, codec);
+      checkHeader(buffer, message);
+      buffer.rewind();
+
+      AbstractPacket decodedPacket = codec.decode(buffer);
+
+      assertTrue(decodedPacket instanceof SessionRemoveAddressMessage);
+      SessionRemoveAddressMessage decodedMessage = (SessionRemoveAddressMessage)decodedPacket;
+      assertEquals(SESS_REMOVE_ADDRESS, decodedMessage.getType());
+      
+      assertEquals(message.getAddress(), decodedMessage.getAddress());
+            
+   }
+   
+   public void testSessionCreateQueueRequest() throws Exception
+   {
+      SessionCreateQueueMessage message = new SessionCreateQueueMessage(randomString(), randomString(), randomString(), true, true);
+
+      AbstractPacketCodec codec = new SessionCreateQueueMessageCodec();
+      
+      SimpleRemotingBuffer buffer = encode(message, codec);
+      checkHeader(buffer, message);
+      buffer.rewind();
+
+      AbstractPacket decodedPacket = codec.decode(buffer);
+
+      assertTrue(decodedPacket instanceof SessionCreateQueueMessage);
+      SessionCreateQueueMessage decodedMessage = (SessionCreateQueueMessage)decodedPacket;
+      assertEquals(SESS_CREATEQUEUE, decodedMessage.getType());
+      
+      assertEquals(message.getAddress(), decodedMessage.getAddress());
+      assertEquals(message.getQueueName(), decodedMessage.getQueueName());
+      assertEquals(message.getFilterString(), decodedMessage.getFilterString());
+      assertEquals(message.isDurable(), decodedMessage.isDurable());
+      assertEquals(message.isTemporary(), decodedMessage.isDurable());
+            
+   }
+   
+   public void testSessionQueueQueryRequest() throws Exception
+   {
+      SessionQueueQueryMessage message = new SessionQueueQueryMessage(randomString());
+
+      AbstractPacketCodec codec = new SessionQueueQueryMessageCodec();
+      
+      SimpleRemotingBuffer buffer = encode(message, codec);
+      checkHeader(buffer, message);
+      buffer.rewind();
+
+      AbstractPacket decodedPacket = codec.decode(buffer);
+
+      assertTrue(decodedPacket instanceof SessionQueueQueryMessage);
+      SessionQueueQueryMessage decodedMessage = (SessionQueueQueryMessage)decodedPacket;
+      assertEquals(SESS_QUEUEQUERY, decodedMessage.getType());
+      
+      assertEquals(message.getQueueName(), decodedMessage.getQueueName());            
+   }
+   
+   public void testSessionQueueQueryResponse() throws Exception
+   {
+      SessionQueueQueryResponseMessage message = new SessionQueueQueryResponseMessage(true, true, randomInt(), randomInt(), randomInt(),
+                                                          randomString(), randomString());
+
+      AbstractPacketCodec codec = new SessionQueueQueryResponseMessageCodec();
+      
+      SimpleRemotingBuffer buffer = encode(message, codec);
+      checkHeader(buffer, message);
+      buffer.rewind();
+
+      AbstractPacket decodedPacket = codec.decode(buffer);
+
+      assertTrue(decodedPacket instanceof SessionQueueQueryResponseMessage);
+      SessionQueueQueryResponseMessage decodedMessage = (SessionQueueQueryResponseMessage)decodedPacket;
+      assertEquals(SESS_QUEUEQUERY_RESP, decodedMessage.getType());
+      
+      assertEquals(message.isExists(), decodedMessage.isExists());
+      assertEquals(message.isDurable(), decodedMessage.isDurable());
+      assertEquals(message.isTemporary(), decodedMessage.isTemporary());
+      assertEquals(message.getConsumerCount(), decodedMessage.getConsumerCount());
+      assertEquals(message.getMessageCount(), decodedMessage.getMessageCount());
+      assertEquals(message.getFilterString(), decodedMessage.getFilterString());
+      assertEquals(message.getAddress(), decodedMessage.getAddress());         
+   }
+   
+   public void testSessionAddAddressMessage() throws Exception
+   {
+      SessionAddAddressMessage message = new SessionAddAddressMessage(randomString());
+
+      AbstractPacketCodec codec = new SessionAddAddressMessageCodec();
+      
+      SimpleRemotingBuffer buffer = encode(message, codec);
+      checkHeader(buffer, message);
+      buffer.rewind();
+
+      AbstractPacket decodedPacket = codec.decode(buffer);
+
+      assertTrue(decodedPacket instanceof SessionAddAddressMessage);
+      SessionAddAddressMessage decodedMessage = (SessionAddAddressMessage)decodedPacket;
+      assertEquals(SESS_ADD_ADDRESS, decodedMessage.getType());
+      
+      assertEquals(message.getAddress(), decodedMessage.getAddress());        
+   }
+   
+   public void testBindingQueryRequest() throws Exception
+   {
+      SessionBindingQueryMessage message = new SessionBindingQueryMessage(randomString());
+
+      AbstractPacketCodec codec = new SessionBindingQueryMessageCodec();
+      
+      SimpleRemotingBuffer buffer = encode(message, codec);
+      checkHeader(buffer, message);
+      buffer.rewind();
+
+      AbstractPacket decodedPacket = codec.decode(buffer);
+
+      assertTrue(decodedPacket instanceof SessionBindingQueryMessage);
+      SessionBindingQueryMessage decodedMessage = (SessionBindingQueryMessage)decodedPacket;
+      assertEquals(SESS_BINDINGQUERY, decodedMessage.getType());
+      
+      assertEquals(message.getAddress(), decodedMessage.getAddress());        
+   }
+   
+   public void testBindingQueryResponse() throws Exception
+   {
+      boolean exists = true;
+      List<String> queueNames = new ArrayList<String>();
+      queueNames.add(randomString());
+      queueNames.add(randomString());
+      queueNames.add(randomString());
+      SessionBindingQueryResponseMessage message = new SessionBindingQueryResponseMessage(exists, queueNames);
+
+      AbstractPacketCodec codec = new SessionBindingQueryResponseMessageCodec();
+      
+      SimpleRemotingBuffer buffer = encode(message, codec);
+      checkHeader(buffer, message);
+      buffer.rewind();
+
+      AbstractPacket decodedPacket = codec.decode(buffer);
+
+      assertTrue(decodedPacket instanceof SessionBindingQueryResponseMessage);
+      SessionBindingQueryResponseMessage decodedMessage = (SessionBindingQueryResponseMessage)decodedPacket;
+      assertEquals(SESS_BINDINGQUERY_RESP, decodedMessage.getType());
+      
+      assertEquals(message.isExists(), decodedMessage.isExists());
+      
+      List<String> decodedNames = decodedMessage.getQueueNames();
+      assertEquals(queueNames.size(), decodedNames.size());
+      for (int i = 0; i < queueNames.size(); i++)
+      {
+         assertEquals(queueNames.get(i), decodedNames.get(i));
+      }
+   }
+   
+   
+   public void testDeleteQueueRequest() throws Exception
+   {
+      SessionDeleteQueueMessage message = new SessionDeleteQueueMessage(randomString());
+
+      AbstractPacketCodec codec = new SessionDeleteQueueMessageCodec();
+      
+      SimpleRemotingBuffer buffer = encode(message, codec);
+      checkHeader(buffer, message);
+      buffer.rewind();
+
+      AbstractPacket decodedPacket = codec.decode(buffer);
+
+      assertTrue(decodedPacket instanceof SessionDeleteQueueMessage);
+      SessionDeleteQueueMessage decodedMessage = (SessionDeleteQueueMessage)decodedPacket;
+      assertEquals(SESS_DELETE_QUEUE, decodedMessage.getType());
+      
+      assertEquals(message.getQueueName(), decodedMessage.getQueueName());        
+   }
+   
+   
+   
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------

Modified: trunk/tests/src/org/jboss/test/messaging/JBMBaseTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/JBMBaseTestCase.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/JBMBaseTestCase.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -275,6 +275,7 @@
       {
          return ((JBossConnection) conn).getServerID();
       }
+      
    protected Connection createConnectionOnServer(ConnectionFactory factory, int serverId)
       throws Exception
       {

Modified: trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -401,6 +401,7 @@
    
    public void createQueue(String name, int i) throws Exception
    {
+      log.info("********Creating queue " + name);
       servers.get(i).createQueue(name, null);      
    }
    
@@ -881,10 +882,10 @@
       servers.get(0).setRedeliveryDelayOnDestination(dest, isQueue, delay);
    }
 
-   protected void setDefaultRedeliveryDelay(long delay) throws Exception
-   {
-      servers.get(0).setDefaultRedeliveryDelay(delay);
-   }
+//   protected void setDefaultRedeliveryDelay(long delay) throws Exception
+//   {
+//      servers.get(0).setDefaultRedeliveryDelay(delay);
+//   }
 
    public TransactionManager getTransactionManager()
    {

Modified: trunk/tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -700,7 +700,9 @@
    {       
       final int BATCH_SIZE = 10;
 
+      log.info("*********** DEPLOYING CF");
       deployConnectionFactory(null,"mycf", new String[]{"mycf"}, -1, -1, -1, -1, false, false, false, BATCH_SIZE);
+      log.info("************ DONE DEPLOY");
       Connection conn = null;
       
       try
@@ -734,6 +736,8 @@
 	         m = consumer.receive(200);
 	         
 	         assertNotNull(m);
+	         
+	         log.info("Got message " + i);
 	          
 	         if (i == 9)
 	         {

Modified: trunk/tests/src/org/jboss/test/messaging/jms/DLQTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/DLQTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/jms/DLQTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -66,30 +66,6 @@
 
    // Public --------------------------------------------------------
 
-   public void testDLQAlreadyDeployed() throws Exception
-   {
-      if (ServerManagement.isRemote())
-      {
-         return;
-      }
-
-
-      assertNotNull(((MessagingServerImpl)getJmsServer()).getDefaultDLQInstance());
-
-      String name = getJmsServer().getConfiguration().getDefaultDLQ();
-
-      assertNotNull(name);
-
-      assertEquals("DLQ", name);
-
-      JBossQueue q = (JBossQueue) ic.lookup("/queue/DLQ");
-
-      assertNotNull(q);
-
-      assertEquals("DLQ", q.getName());
-   }
-
-
    public void testDefaultAndOverrideDLQ() throws Exception
    {
       if (ServerManagement.isRemote())

Modified: trunk/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -45,6 +45,7 @@
 import javax.jms.Topic;
 import javax.jms.TopicSubscriber;
 
+import org.jboss.jms.destination.JBossQueue;
 import org.jboss.jms.destination.JBossTopic;
 
 import EDU.oswego.cs.dl.util.concurrent.Latch;
@@ -540,7 +541,7 @@
    // Invalid destination test
    //
 
-   public void testCreateConsumerOnInexistentDestination() throws Exception
+   public void testCreateConsumerOnNonExistentTopic() throws Exception
    {
       Connection pconn = null;
       
@@ -569,6 +570,35 @@
       }
    }
    
+   public void testCreateConsumerOnNonExistentQueue() throws Exception
+   {
+      Connection pconn = null;
+      
+      try
+      {
+         pconn = cf.createConnection();
+
+         Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         try
+         {
+            ps.createConsumer(new JBossQueue("NoSuchQueue"));
+            fail("should throw exception");
+         }
+         catch(InvalidDestinationException e)
+         {
+            // OK
+         }
+      }
+      finally
+      {
+         if (pconn != null)
+         {
+            pconn.close();
+         }
+      }
+   }
+   
    //
    // closed consumer tests
    //
@@ -673,7 +703,7 @@
    			queueConsumer.receive(2000);
    			fail("should throw exception");
    		}
-   		catch(javax.jms.IllegalStateException e)
+   		catch (javax.jms.IllegalStateException e)
    		{
    			// OK
    		}

Modified: trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/jms/QueueTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -111,13 +111,20 @@
 	      
 	      conn.close();
 	      
+	      log.info("**** stopping");
 	      stop();
 	      
+	      	      
+	      log.info("*** restarting");
 	      startNoDelete();
 	      
+	      log.info("Redeploying objects");
+	      
 	      // Messaging server restart implies new ConnectionFactory lookup
 	      deployAndLookupAdministeredObjects();
 	      
+	      log.info("**** redeployed objects");
+	      
 	      conn = cf.createConnection();
 	      sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
 	      conn.start();

Modified: trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -38,9 +38,9 @@
 import javax.jms.XAConnectionFactory;
 import javax.jms.XASession;
 import javax.management.ObjectName;
+import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 
-import org.jboss.jms.exception.MessagingXAException;
 import org.jboss.jms.server.security.Role;
 import org.jboss.messaging.core.impl.XidImpl;
 import org.jboss.messaging.util.Logger;
@@ -1141,7 +1141,7 @@
             resource.prepare(xid);
             fail("Didn't throw expected exception!");
          }
-         catch (MessagingXAException expected)
+         catch (XAException expected)
          {
          }
       }

Modified: trunk/tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/jms/TemporaryDestinationTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -68,7 +68,9 @@
    		
    		Session consumerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    		
+   		log.info("** creating temp topic");
 	      TemporaryTopic tempTopic = producerSession.createTemporaryTopic();
+	      log.info("** created temp topic");
 	
 	      MessageProducer producer = producerSession.createProducer(tempTopic);
 	
@@ -93,7 +95,7 @@
 	         tempTopic.delete();
 	         fail();
 	      }
-	      catch (JMSException e)
+	      catch (javax.jms.IllegalStateException e)
 	      {
 	         //Can't delete temp dest if there are open consumers
 	      }

Modified: trunk/tests/src/org/jboss/test/messaging/jms/TopicTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/TopicTest.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/jms/TopicTest.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -55,6 +55,19 @@
       super(name);
    }
    
+   protected void setUp() throws Exception
+   {
+      
+      log.info("______________________Test starting");
+      super.setUp();
+   }
+
+   protected void tearDown() throws Exception
+   {      
+      super.tearDown();
+      log.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test endded");
+   }
+   
    // Public --------------------------------------------------------
 
    /**
@@ -86,78 +99,105 @@
          }
       }
    }
-
-   public void testTopicName() throws Exception
-   {
-      Topic topic = (Topic)ic.lookup("/topic/Topic1");
-      assertEquals("Topic1", topic.getTopicName());
-   }
    
-   /*
-    * See http://jira.jboss.com/jira/browse/JBMESSAGING-399
-    */
-   public void testRace() throws Exception
+   public void testTopic2() throws Exception
    {
       Connection conn = null;
       
       try
-      {	      
-	      conn = cf.createConnection();
-	      
-	      Session sSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-	      
-	      MessageProducer prod = sSend.createProducer(topic1);
-	      prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-	      
-	      Session s1 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-	      Session s2 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-	      Session s3 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-	      
-	      MessageConsumer c1 = s1.createConsumer(topic1);
-	      MessageConsumer c2 = s2.createConsumer(topic1);
-	      MessageConsumer c3 = s3.createConsumer(topic1);            
-	      
-	      final int numMessages = 500;
-         	    
-	      TestListener l1 = new TestListener(numMessages);
-	      TestListener l2 = new TestListener(numMessages);
-	      TestListener l3 = new TestListener(numMessages);
-	      
-	      c1.setMessageListener(l1);
-	      c2.setMessageListener(l2);
-	      c3.setMessageListener(l3);
-	            
-	      conn.start();
-	       	      
-	      for (int i = 0; i < numMessages; i++)
-	      {
-	         byte[] blah = new byte[10000];
-	         String str = new String(blah);
-	           
-	         Wibble2 w = new Wibble2();
-	         w.s = str;
-	         ObjectMessage om = sSend.createObjectMessage(w);
-	         
-	         prod.send(om);
-	      }          
-	      
-	      l1.waitForMessages();
-	      l2.waitForMessages();
-	      l3.waitForMessages();
-	      
-	      assertFalse(l1.failed);
-	      assertFalse(l2.failed);
-	      assertFalse(l3.failed);
+      {
+         conn = cf.createConnection();
+
+         Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageProducer p = s.createProducer(topic1);
+         MessageConsumer c = s.createConsumer(topic1);
+         conn.start();
+
+         p.send(s.createTextMessage("payload"));
+         TextMessage m = (TextMessage)c.receive();
+
+         assertEquals("payload", m.getText());
       }
       finally
       {
-      	if (conn != null)
-      	{
-      		conn.close();
-      	}
+         if (conn != null)
+         {
+            conn.close();
+         }
       }
    }
 
+//   public void testTopicName() throws Exception
+//   {
+//      Topic topic = (Topic)ic.lookup("/topic/Topic1");
+//      assertEquals("Topic1", topic.getTopicName());
+//   }
+//   
+//   /*
+//    * See http://jira.jboss.com/jira/browse/JBMESSAGING-399
+//    */
+//   public void testRace() throws Exception
+//   {
+//      Connection conn = null;
+//      
+//      try
+//      {	      
+//	      conn = cf.createConnection();
+//	      
+//	      Session sSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//	      
+//	      MessageProducer prod = sSend.createProducer(topic1);
+//	      prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+//	      
+//	      Session s1 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//	      Session s2 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//	      Session s3 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//	      
+//	      MessageConsumer c1 = s1.createConsumer(topic1);
+//	      MessageConsumer c2 = s2.createConsumer(topic1);
+//	      MessageConsumer c3 = s3.createConsumer(topic1);            
+//	      
+//	      final int numMessages = 500;
+//         	    
+//	      TestListener l1 = new TestListener(numMessages);
+//	      TestListener l2 = new TestListener(numMessages);
+//	      TestListener l3 = new TestListener(numMessages);
+//	      
+//	      c1.setMessageListener(l1);
+//	      c2.setMessageListener(l2);
+//	      c3.setMessageListener(l3);
+//	            
+//	      conn.start();
+//	       	      
+//	      for (int i = 0; i < numMessages; i++)
+//	      {
+//	         byte[] blah = new byte[10000];
+//	         String str = new String(blah);
+//	           
+//	         Wibble2 w = new Wibble2();
+//	         w.s = str;
+//	         ObjectMessage om = sSend.createObjectMessage(w);
+//	         
+//	         prod.send(om);
+//	      }          
+//	      
+//	      l1.waitForMessages();
+//	      l2.waitForMessages();
+//	      l3.waitForMessages();
+//	      
+//	      assertFalse(l1.failed);
+//	      assertFalse(l2.failed);
+//	      assertFalse(l3.failed);
+//      }
+//      finally
+//      {
+//      	if (conn != null)
+//      	{
+//      		conn.close();
+//      	}
+//      }
+//   }
+
    // Package protected ---------------------------------------------
    
    // Protected -----------------------------------------------------

Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -51,11 +51,8 @@
 import org.jboss.kernel.spi.deployment.KernelDeployment;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.core.Binding;
-import org.jboss.messaging.core.Condition;
-import org.jboss.messaging.core.DestinationType;
 import org.jboss.messaging.core.MessagingServer;
 import org.jboss.messaging.core.MessagingServerManagement;
-import org.jboss.messaging.core.impl.ConditionImpl;
 import org.jboss.messaging.core.remoting.RemotingConfiguration;
 import org.jboss.messaging.microcontainer.JBMBootstrapServer;
 import org.jboss.messaging.util.JNDIUtil;
@@ -445,7 +442,6 @@
       }
    }
 
-
    public boolean isServerPeerStarted() throws Exception
    {
       return this.getMessagingServerManagement().isStarted();
@@ -678,7 +674,7 @@
                                        boolean strictTck,
                                        int dupsOkBatchSize) throws Exception
    {
-      log.trace("deploying connection factory with name: " + objectName);
+      log.info("deploying connection factory with name: " + objectName + " and dupsok: " + dupsOkBatchSize);
       //ConnectionFactory connectionFactory = new ConnectionFactory(clientId);
       List<String> bindings = new ArrayList<String>();
       if (jndiBindings != null)
@@ -718,15 +714,15 @@
 
       ClientConnectionFactory delegate =
               new ClientConnectionFactoryImpl( getMessagingServer().getConfiguration().getMessagingServerID(),
-                      remotingConfiguration, version, useStrict, prefetchSize, dupsOkBatchSize, clientId);
+                      remotingConfiguration, version, useStrict, prefetchSize);
 
-      log.debug(this + " created local delegate " + delegate);
+      log.debug(this + " created local connectionFactory " + delegate);
 
       // Registering with the dispatcher should always be the last thing otherwise a client could
       // use a partially initialised object
 
       //getMessagingServer().getMinaService().getDispatcher().register(endpoint.newHandler());
-      JBossConnectionFactory jBossConnectionFactory = new JBossConnectionFactory(delegate);
+      JBossConnectionFactory jBossConnectionFactory = new JBossConnectionFactory(delegate, clientId, dupsOkBatchSize);
       for (String binding : bindings)
       {
          bindObject(binding, jBossConnectionFactory);
@@ -912,22 +908,14 @@
 
    public void setRedeliveryDelayOnDestination(String dest, boolean queue, long delay) throws Exception
    {
-      //getMessagingServer().getDestinationManager().getDestination(dest, queue).setRedeliveryDelay(delay);
+      String condition = (queue ? "queue." : "topic.") + dest;
+      
+      List<Binding> bindings = this.getMessagingServer().getPostOffice().getBindingsForAddress(condition);
 
-      Condition condition = new ConditionImpl(queue ? DestinationType.QUEUE : DestinationType.TOPIC, dest);
-
-      List<Binding> bindings = this.getMessagingServer().getPostOffice().getBindingsForCondition(condition);
-
       bindings.get(0).getQueue().setRedeliveryDelay(delay);
    }
 
 
-   public void setDefaultRedeliveryDelay(long delay) throws Exception
-   {
-      getMessagingServer().getConfiguration().setDefaultRedeliveryDelay(delay);
-   }
-
-
    // Inner classes --------------------------------------------------------------------------------
 
 }

Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/MBeanServerBuilder.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/MBeanServerBuilder.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/MBeanServerBuilder.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -34,9 +34,9 @@
 
    /*public MBeanServer newMBeanServer(String defaultDomain,
                                      MBeanServer outer,
-                                     MBeanServerDelegate delegate)
+                                     MBeanServerDelegate connectionFactory)
    {
-      return new MBeanServerImpl("jboss", outer, delegate);
+      return new MBeanServerImpl("jboss", outer, connectionFactory);
    }
 */
    public MBeanServerDelegate	newMBeanServerDelegate()

Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -600,10 +600,10 @@
    }
 
 
-   public void setDefaultRedeliveryDelay(long delay) throws Exception
-   {
-      server.setDefaultRedeliveryDelay(delay);
-   }
+//   public void setDefaultRedeliveryDelay(long delay) throws Exception
+//   {
+//      server.setDefaultRedeliveryDelay(delay);
+//   }
 
    public InitialContext getInitialContext() throws Exception
    {

Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java	2008-02-07 18:10:28 UTC (rev 3673)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java	2008-02-07 18:21:26 UTC (rev 3674)
@@ -299,5 +299,5 @@
 
    void setRedeliveryDelayOnDestination(String dest, boolean queue, long delay) throws Exception;
 
-   void setDefaultRedeliveryDelay(long delay) throws Exception;
+   //void setDefaultRedeliveryDelay(long delay) throws Exception;
 }




More information about the jboss-cvs-commits mailing list