Package org.hornetq.core.protocol.core

Examples of org.hornetq.core.protocol.core.Channel


         int lcid = channel.getLastConfirmedCommandID();

         Packet request = new ReattachSessionMessage(name, lcid);

         Channel channel1 = backupConnection.getChannel(1, -1);

         ReattachSessionResponseMessage response = (ReattachSessionResponseMessage)channel1.sendBlocking(request);

         if (response.isReattached())
         {
            // The session was found on the server - we reattached transparently ok

            channel.replayCommands(response.getLastConfirmedCommandID());
         }
         else
         {

            // The session wasn't found on the server - probably we're failing over onto a backup server where the
            // session won't exist or the target server has been restarted - in this case the session will need to be
            // recreated,
            // and we'll need to recreate any consumers

            // It could also be that the server hasn't been restarted, but the session is currently executing close, and
            // that
            // has already been executed on the server, that's why we can't find the session- in this case we *don't*
            // want
            // to recreate the session, we just want to unblock the blocking call
            if (!inClose)
            {
               Packet createRequest = new CreateSessionMessage(name,
                                                               channel.getID(),
                                                               version,
                                                               username,
                                                               password,
                                                               minLargeMessageSize,
                                                               xa,
                                                               autoCommitSends,
                                                               autoCommitAcks,
                                                               preAcknowledge,
                                                               confirmationWindowSize,
                                                               defaultAddress == null ? null
                                                                                     : defaultAddress.toString());
               boolean retry = false;
               do
               {
                  try
                  {
                     channel1.sendBlocking(createRequest);
                     retry = false;
                  }
                  catch (HornetQException e)
                  {
                     // the session was created while its server was starting, retry it:
View Full Code Here


            incomingInterceptors,
            outgoingInterceptors,
            config.isAsyncConnectionExecutionEnabled() ? connectionExecutor : null,
            server.getNodeID());

      Channel channel1 = rc.getChannel(CHANNEL_ID.SESSION.id, -1);

      ChannelHandler handler = new HornetQPacketHandler(this, server, channel1, rc);

      channel1.setHandler(handler);

      long ttl = HornetQClient.DEFAULT_CONNECTION_TTL;

      if (config.getConnectionTTLOverride() != -1)
      {
         ttl = config.getConnectionTTLOverride();
      }

      final ConnectionEntry entry = new ConnectionEntry(rc, connectionExecutor, System.currentTimeMillis(), ttl);

      final Channel channel0 = rc.getChannel(0, -1);

      channel0.setHandler(new LocalChannelHandler(config, entry, channel0, acceptorUsed, rc));

      return entry;
   }
View Full Code Here

            int lcid = channel.getLastConfirmedCommandID();

            Packet request = new ReattachSessionMessage(name, lcid);

            Channel channel1 = backupConnection.getChannel(1, -1);

            ReattachSessionResponseMessage response = (ReattachSessionResponseMessage)channel1.sendBlocking(request);

            if (response.isReattached())
            {
               if (HornetQClientLogger.LOGGER.isDebugEnabled())
               {
                  HornetQClientLogger.LOGGER.debug("ClientSession reattached fine, replaying commands");
               }
               // The session was found on the server - we reattached transparently ok

               channel.replayCommands(response.getLastConfirmedCommandID());
            }
            else
            {

               if (HornetQClientLogger.LOGGER.isDebugEnabled())
               {
                  HornetQClientLogger.LOGGER.debug("ClientSession couldn't be reattached, creating a new session");
               }

               // The session wasn't found on the server - probably we're failing over onto a backup server where the
               // session won't exist or the target server has been restarted - in this case the session will need to be
               // recreated,
               // and we'll need to recreate any consumers

               // It could also be that the server hasn't been restarted, but the session is currently executing close,
               // and
               // that
               // has already been executed on the server, that's why we can't find the session- in this case we *don't*
               // want
               // to recreate the session, we just want to unblock the blocking call
               if (!inClose)
               {
                  Packet createRequest = new CreateSessionMessage(name,
                                                                  channel.getID(),
                                                                  version,
                                                                  username,
                                                                  password,
                                                                  minLargeMessageSize,
                                                                  xa,
                                                                  autoCommitSends,
                                                                  autoCommitAcks,
                                                                  preAcknowledge,
                                                                  confirmationWindowSize,
                                                                  defaultAddress == null ? null
                                                                                        : defaultAddress.toString());
                  boolean retry = false;
                  do
                  {
                     try
                     {
                        channel1.sendBlocking(createRequest);
                        retry = false;
                     }
                     catch (HornetQException e)
                     {
                        // the session was created while its server was starting, retry it:
View Full Code Here

               liveServerSessionFactory.setReconnectAttempts(1);
               quorumManager.setSessionFactory(liveServerSessionFactory);
               //get the connection and request replication to live
               CoreRemotingConnection liveConnection = liveServerSessionFactory.getConnection();
               quorumManager.addAsFailureListenerOf(liveConnection);
               Channel pingChannel = liveConnection.getChannel(ChannelImpl.CHANNEL_ID.PING.id, -1);
               Channel replicationChannel = liveConnection.getChannel(ChannelImpl.CHANNEL_ID.REPLICATION.id, -1);
               connectToReplicationEndpoint(replicationChannel);
               replicationEndpoint.start();
               clusterManager.announceReplicatingBackupToLive(pingChannel, attemptFailBack);
            }
            catch (Exception e)
View Full Code Here

               liveServerSessionFactory.setReconnectAttempts(1);
               quorumManager.setSessionFactory(liveServerSessionFactory);
               //get the connection and request replication to live
               CoreRemotingConnection liveConnection = liveServerSessionFactory.getConnection();
               quorumManager.addAsFailureListenerOf(liveConnection);
               Channel pingChannel = liveConnection.getChannel(ChannelImpl.CHANNEL_ID.PING.id, -1);
               Channel replicationChannel = liveConnection.getChannel(ChannelImpl.CHANNEL_ID.REPLICATION.id, -1);
               connectToReplicationEndpoint(replicationChannel);
               replicationEndpoint.start();
               clusterManager.announceReplicatingBackupToLive(pingChannel, attemptFailBack);
            }
            catch (Exception e)
View Full Code Here

      return creationTime;
   }

   public synchronized Channel getChannel(final long channelID, final int confWindowSize)
   {
      Channel channel = channels.get(channelID);

      if (channel == null)
      {
         channel = new ChannelImpl(this, channelID, confWindowSize);
View Full Code Here

      callClosingListeners();
   }
  
   public void disconnect(final boolean criticalError)
   {
      Channel channel0 = getChannel(0, -1);

      // And we remove all channels from the connection, this ensures no more packets will be processed after this
      // method is
      // complete
     
      Set<Channel> allChannels = new HashSet<Channel>(channels.values());

      if (!criticalError)
      {
         removeAllChannels();
      }
      else
      {
         // We can't hold a lock if a critical error is happening...
         // as other threads will be holding the lock while hanging on IO
         channels.clear();
      }

      // Now we are 100% sure that no more packets will be processed we can flush then send the disconnect
     
      if (!criticalError)
      {
         for (Channel channel: allChannels)
         {
            channel.flushConfirmations();
         }
      }

      Packet disconnect = new DisconnectMessage(nodeID);
      channel0.sendAndFlush(disconnect);
   }
View Full Code Here

         }
      }

      synchronized (transferLock)
      {
         final Channel channel = channels.get(packet.getChannelID());

         if (channel != null)
         {
            channel.handlePacket(packet);
         }
      }
   }
View Full Code Here

            int lcid = channel.getLastConfirmedCommandID();

            Packet request = new ReattachSessionMessage(name, lcid);

            Channel channel1 = backupConnection.getChannel(1, -1);

            ReattachSessionResponseMessage response = (ReattachSessionResponseMessage)channel1.sendBlocking(request, PacketImpl.REATTACH_SESSION_RESP);

            if (response.isReattached())
            {
               if (HornetQClientLogger.LOGGER.isDebugEnabled())
               {
                  HornetQClientLogger.LOGGER.debug("ClientSession reattached fine, replaying commands");
               }
               // The session was found on the server - we reattached transparently ok

               channel.replayCommands(response.getLastConfirmedCommandID());
            }
            else
            {

               if (HornetQClientLogger.LOGGER.isDebugEnabled())
               {
                  HornetQClientLogger.LOGGER.debug("ClientSession couldn't be reattached, creating a new session");
               }

               for (ClientConsumerInternal consumer : cloneConsumers())
               {
                  consumer.clearAtFailover();
               }


               // The session wasn't found on the server - probably we're failing over onto a backup server where the
               // session won't exist or the target server has been restarted - in this case the session will need to be
               // recreated,
               // and we'll need to recreate any consumers

               // It could also be that the server hasn't been restarted, but the session is currently executing close,
               // and
               // that
               // has already been executed on the server, that's why we can't find the session- in this case we *don't*
               // want
               // to recreate the session, we just want to unblock the blocking call
               if (!inClose && mayAttemptToFailover)
               {
                  Packet createRequest = new CreateSessionMessage(name,
                                                                  channel.getID(),
                                                                  version,
                                                                  username,
                                                                  password,
                                                                  minLargeMessageSize,
                                                                  xa,
                                                                  autoCommitSends,
                                                                  autoCommitAcks,
                                                                  preAcknowledge,
                                                                  confirmationWindowSize,
                                                                  defaultAddress == null ? null
                                                                                        : defaultAddress.toString());
                  boolean retry = false;
                  do
                  {
                     try
                     {
                        channel1.sendBlocking(createRequest, PacketImpl.CREATESESSION_RESP);
                        retry = false;
                     }
                     catch (HornetQException e)
                     {
                        // the session was created while its server was starting, retry it:
View Full Code Here

      doTestClientVersionCompatibility(false);
   }

   private void doTestClientVersionCompatibility(boolean compatible) throws Exception
   {
      Channel channel1 = connection.getChannel(1, -1);
      long sessionChannelID = connection.generateChannelID();
      int version = VersionLoader.getVersion().getIncrementingVersion();
      if (!compatible)
      {
         version = -1;
      }
      Packet request = new CreateSessionMessage(randomString(),
                                                sessionChannelID,
                                                version,
                                                null,
                                                null,
                                                HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
                                                false,
                                                true,
                                                true,
                                                false,
                                                HornetQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE,
                                                null);

      if (compatible)
      {
         Packet packet = channel1.sendBlocking(request);
         assertNotNull(packet);
         assertTrue(packet instanceof CreateSessionResponseMessage);
         // 1 connection on the server
         assertEquals(1, server.getConnectionCount());
      }
      else
      {
         try
         {
            channel1.sendBlocking(request);
            fail();
         }
         catch (HornetQException e)
         {
            assertEquals(HornetQException.INCOMPATIBLE_CLIENT_SERVER_VERSIONS, e.getCode());
View Full Code Here

TOP

Related Classes of org.hornetq.core.protocol.core.Channel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.