Package org.hornetq.spi.core.remoting

Examples of org.hornetq.spi.core.remoting.Connection


                     Packet packet = new PacketImpl(PacketImpl.SESS_START);

                     packet.setChannelID(channel.getID());

                     Connection conn = channel.getConnection().getTransportConnection();

                     HornetQBuffer buffer = packet.encode(channel.getConnection());

                     conn.write(buffer, false, false);
                  }

                  resetCreditManager = true;
               }
View Full Code Here


   private void sendPacketWithoutLock(final Packet packet)
   {
      packet.setChannelID(channel.getID());

      Connection conn = channel.getConnection().getTransportConnection();

      HornetQBuffer buffer = packet.encode(channel.getConnection());

      conn.write(buffer, false, false);
   }
View Full Code Here

      this.channel = channel;

      this.remotingConnection = channel.getConnection();
     
      //TODO think of a better way of doing this
      Connection conn = remotingConnection.getTransportConnection();
     
      if (conn instanceof NettyConnection)
      {
         direct = ((NettyConnection)conn).isDirectDeliver();
      }
View Full Code Here

         return null;
      synchronized (connectionLock)
      {
         if (connection == null)
         {
            Connection tc = null;

            try
            {
               DelegatingBufferHandler handler = new DelegatingBufferHandler();

               connector = connectorFactory.createConnector(connectorConfig.getParams(),
                                                            handler,
                                                            this,
                                                            closeExecutor,
                                                            threadPool,
                                                            scheduledThreadPool);

               if (HornetQClientLogger.LOGGER.isDebugEnabled())
               {
                  HornetQClientLogger.LOGGER.debug("Trying to connect with connector = " + connectorFactory +
                                                      ", parameters = " +
                                                      connectorConfig.getParams() +
                                                      " connector = " +
                                                      connector);
               }

               if (connector != null)
               {
                  connector.start();

                  if (ClientSessionFactoryImpl.isDebug)
                  {
                     HornetQClientLogger.LOGGER.debug("Trying to connect at the main server using connector :" + connectorConfig);
                  }

                  tc = connector.createConnection();

                  if (tc == null)
                  {
                     if (ClientSessionFactoryImpl.isDebug)
                     {
                        HornetQClientLogger.LOGGER.debug("Main server is not up. Hopefully there's a backup configured now!");
                     }

                     try
                     {
                        connector.close();
                     }
                     catch (Throwable t)
                     {
                     }

                     connector = null;
                  }
               }
               // if connection fails we can try the backup in case it has come live
               if (connector == null)
               {
                  if (backupConfig != null)
                  {
                     if (ClientSessionFactoryImpl.isDebug)
                     {
                        HornetQClientLogger.LOGGER.debug("Trying backup config = " + backupConfig);
                     }
                     ConnectorFactory backupConnectorFactory = instantiateConnectorFactory(backupConfig.getFactoryClassName());
                     connector = backupConnectorFactory.createConnector(backupConfig.getParams(),
                                                                        handler,
                                                                        this,
                                                                        closeExecutor,
                                                                        threadPool,
                                                                        scheduledThreadPool);
                     if (connector != null)
                     {
                        connector.start();

                        tc = connector.createConnection();

                        if (tc == null)
                        {
                           if (ClientSessionFactoryImpl.isDebug)
                           {
                              HornetQClientLogger.LOGGER.debug("Backup is not active yet");
                           }

                           try
                           {
                              connector.close();
                           }
                           catch (Throwable t)
                           {
                           }

                           connector = null;
                        }
                        else
                        {
                        /*looks like the backup is now live, let's use that*/

                           if (ClientSessionFactoryImpl.isDebug)
                           {
                              HornetQClientLogger.LOGGER.debug("Connected to the backup at " + backupConfig);
                           }

                           connectorConfig = backupConfig;

                           backupConfig = null;

                           connectorFactory = backupConnectorFactory;
                        }
                     }
                  }
                  else
                  {
                     if (ClientSessionFactoryImpl.isTrace)
                     {
                        HornetQClientLogger.LOGGER.trace("No Backup configured!", new Exception("trace"));
                     }
                  }
               }
            }
            catch (Exception cause)
            {
               // Sanity catch for badly behaved remoting plugins

               HornetQClientLogger.LOGGER.createConnectorException(cause);

               if (tc != null)
               {
                  try
                  {
                     tc.close();
                  }
                  catch (Throwable t)
                  {
                  }
               }
View Full Code Here

                     Packet packet = new PacketImpl(PacketImpl.SESS_START);

                     packet.setChannelID(channel.getID());

                     Connection conn = channel.getConnection().getTransportConnection();

                     HornetQBuffer buffer = packet.encode(channel.getConnection());

                     conn.write(buffer, false, false);
                  }

                  resetCreditManager = true;
               }
View Full Code Here

   private void sendPacketWithoutLock(final Packet packet)
   {
      packet.setChannelID(channel.getID());

      Connection conn = channel.getConnection().getTransportConnection();

      HornetQBuffer buffer = packet.encode(channel.getConnection());

      conn.write(buffer, false, false);
   }
View Full Code Here

   public CoreRemotingConnection getConnection()
   {
      if (connection == null)
      {
         Connection tc = null;

         try
         {
            DelegatingBufferHandler handler = new DelegatingBufferHandler();

            connector = connectorFactory.createConnector(connectorConfig.getParams(),
                                                         handler,
                                                         this,
                                                         closeExecutor,
                                                         threadPool,
                                                         scheduledThreadPool);

            if (ClientSessionFactoryImpl.log.isDebugEnabled())
            {
               ClientSessionFactoryImpl.log.debug("Trying to connect with connector = " + connectorFactory +
                                                  ", parameters = " +
                                                  connectorConfig.getParams() +
                                                  " connector = " +
                                                  connector);
            }

            if (connector != null)
            {
               connector.start();

               if (ClientSessionFactoryImpl.isDebug)
               {
                  ClientSessionFactoryImpl.log.debug("Trying to connect at the main server using connector :" + connectorConfig);
               }

               tc = connector.createConnection();

               if (tc == null)
               {
                  if (ClientSessionFactoryImpl.isDebug)
                  {
                     ClientSessionFactoryImpl.log.debug("Main server is not up. Hopefully there's a backup configured now!");
                  }

                  try
                  {
                     connector.close();
                  }
                  catch (Throwable t)
                  {
                  }

                  connector = null;
               }
            }
            // if connection fails we can try the backup in case it has come live
            if (connector == null)
            {
               if (backupConfig != null)
               {
                  if (ClientSessionFactoryImpl.isDebug)
                  {
                     ClientSessionFactoryImpl.log.debug("Trying backup config = " + backupConfig);
                  }
                  ConnectorFactory backupConnectorFactory = instantiateConnectorFactory(backupConfig.getFactoryClassName());
                  connector = backupConnectorFactory.createConnector(backupConfig.getParams(),
                                                                     handler,
                                                                     this,
                                                                     closeExecutor,
                                                                     threadPool,
                                                                     scheduledThreadPool);
                  if (connector != null)
                  {
                     connector.start();

                     tc = connector.createConnection();

                     if (tc == null)
                     {
                        if (ClientSessionFactoryImpl.isDebug)
                        {
                           ClientSessionFactoryImpl.log.debug("Backup is not active yet");
                        }

                        try
                        {
                           connector.close();
                        }
                        catch (Throwable t)
                        {
                        }

                        connector = null;
                     }
                     else
                     {
                        /*looks like the backup is now live, lets use that*/

                        if (ClientSessionFactoryImpl.isDebug)
                        {
                           ClientSessionFactoryImpl.log.debug("Connected to the backup at " + backupConfig);
                        }

                        connectorConfig = backupConfig;

                        backupConfig = null;

                        connectorFactory = backupConnectorFactory;
                     }
                  }
               }
               else
               {
                  if (ClientSessionFactoryImpl.isTrace)
                  {
                     ClientSessionFactoryImpl.log.trace("No Backup configured!", new Exception("trace"));
                  }
               }
            }
         }
         catch (Exception e)
         {
            // Sanity catch for badly behaved remoting plugins

            ClientSessionFactoryImpl.log.warn("connector.create or connectorFactory.createConnector should never throw an exception, implementation is badly behaved, but we'll deal with it anyway.",
                                              e);

            if (tc != null)
            {
               try
               {
                  tc.close();
               }
               catch (Throwable t)
               {
               }
            }
View Full Code Here

                     Packet packet = new PacketImpl(PacketImpl.SESS_START);

                     packet.setChannelID(channel.getID());

                     Connection conn = channel.getConnection().getTransportConnection();

                     HornetQBuffer buffer = packet.encode(channel.getConnection());

                     conn.write(buffer, false, false);
                  }

                  resetCreditManager = true;
               }
View Full Code Here

   private void sendPacketWithoutLock(final Packet packet)
   {
      packet.setChannelID(channel.getID());

      Connection conn = channel.getConnection().getTransportConnection();

      HornetQBuffer buffer = packet.encode(channel.getConnection());

      conn.write(buffer, false, false);
   }
View Full Code Here

      this.channel = channel;

      this.remotingConnection = channel.getConnection();

      //TODO think of a better way of doing this
      Connection conn = remotingConnection.getTransportConnection();

      if (conn instanceof NettyConnection)
      {
         direct = ((NettyConnection)conn).isDirectDeliver();
      }
View Full Code Here

TOP

Related Classes of org.hornetq.spi.core.remoting.Connection

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.