Package org.apache.activemq.network

Examples of org.apache.activemq.network.NetworkConnector


   
    // Get JMS Broker
    BrokerService broker = ClusterManager.getInstance().getBrokerService();
   
    // Peer Network Connection
    NetworkConnector con = null;
   
    try {
     
      log.debug("[PeerService] Connecting with Peer Cluster on " + url);
      con = broker.addNetworkConnector(url);
     
      if (con==null) {
        throw new Exception("NetworkConnector Null");
      }
     
      // Configure Network Connection
      con.addStaticallyIncludedDestination(new ActiveMQTopic("nebula.cluster.service.topic"));
      con.setConduitSubscriptions(false);
      con.setDynamicOnly(true)// Do not forward if no consumers
      con.addExcludedDestination(new ActiveMQQueue("nebula.cluster.registration.queue"));
      con.addExcludedDestination(new ActiveMQQueue("nebula.cluster.services.facade.queue"));
      con.setNetworkTTL(128);    // Default TTL
      con.setDuplex(true);    // Full-duplex communication
      con.start();

      peers.put(url, con);
      log.info("[PeerService] Connected with Peer Cluster on " + url);
     
      // Notify Event Hooks
      ServiceMessage message = new ServiceMessage(url, ServiceMessageType.PEER_CONNECTION);
      ServiceEventsSupport.getInstance().onServiceMessage(message);
     
    } catch (Exception e) {
      log.warn("[PeerService] Unable to connect with Cluster " + url, e);
      if (con!=null) {  // If Connection was created
        try {
          // Try to Stop
          con.stop();
        } catch (Exception e1) {
          log.warn("[PeerService] Unable to Stop Connector " + url, e1);
        }
        broker.removeNetworkConnector(con);
      }
View Full Code Here


  /**
   * {@inheritDoc}
   */
  public void removeCluster(String url) {
   
    NetworkConnector con = peers.get(url);
   
    if (con==null) return;
   
    log.debug("[PeerService] Disconnecting from Peer Cluster on " + url);
   
    BrokerService broker = ClusterManager.getInstance().getBrokerService();
   
    try {
      // Stop Network Connection
      con.stop();
    } catch (Exception e) {
      log.warn("[PeerService] Unable to Stop Network Connector");
    }
   
    // Remove Network Connector
View Full Code Here

    BrokerService broker = (BrokerService) Grid.getApplicationContext().getBean("broker");
   
    System.out.println("Press any key to Add new Network Broker");
    System.in.read();
   
    NetworkConnector con = broker.addNetworkConnector("static://(tcp://excalibur:61616)");
   
    if (con!=null) {
      // con.addExcludedDestination(new ActiveMQQueue(">"));
      con.addStaticallyIncludedDestination(new ActiveMQTopic("nebula.cluster.service.topic"));
      con.setConduitSubscriptions(false);
      con.setDynamicOnly(true);
      con.addExcludedDestination(new ActiveMQQueue("nebula.cluster.registration.queue"));
      con.addExcludedDestination(new ActiveMQQueue("nebula.cluster.services.facade.queue"));
      con.setNetworkTTL(128);
      con.start();
    }

//    System.out.println("Press any key to Shutdown");
//    System.in.read();
//   
View Full Code Here

     *
     * @return the newly created and added network connector
     * @throws Exception
     */
    public NetworkConnector addNetworkConnector(URI discoveryAddress) throws Exception {
        NetworkConnector connector = new DiscoveryNetworkConnector(discoveryAddress);
        return addNetworkConnector(connector);
    }
View Full Code Here

     * @org.apache.xbean.Property
     *                            nestedType="org.apache.activemq.network.NetworkConnector"
     */
    public void setNetworkConnectors(List networkConnectors) throws Exception {
        for (Iterator iter = networkConnectors.iterator(); iter.hasNext();) {
            NetworkConnector connector = (NetworkConnector) iter.next();
            addNetworkConnector(connector);
        }
    }
View Full Code Here

        }
    }

    public void stopAllConnectors(ServiceStopper stopper) {
        for (Iterator<NetworkConnector> iter = getNetworkConnectors().iterator(); iter.hasNext();) {
            NetworkConnector connector = iter.next();
            unregisterNetworkConnectorMBean(connector);
            stopper.stop(connector);
        }
        for (Iterator<ProxyConnector> iter = getProxyConnectors().iterator(); iter.hasNext();) {
            ProxyConnector connector = iter.next();
View Full Code Here

                                }
                            });
                }

                for (Iterator<NetworkConnector> iter = getNetworkConnectors().iterator(); iter.hasNext();) {
                    final NetworkConnector connector = iter.next();
                    connector.setLocalUri(uri);
                    connector.setBrokerName(getBrokerName());
                    connector.setDurableDestinations(durableDestinations);
                    if (getDefaultSocketURIString() != null) {
                        connector.setBrokerURL(getDefaultSocketURIString());
                    }
                    if (networkConnectorStartExecutor != null) {
                        networkConnectorStartExecutor.execute(new Runnable() {
                            public void run() {
                                try {
                                    LOG.info("Async start of " + connector);
                                    connector.start();
                                } catch(Exception e) {
                                    LOG.error("Async start of network connector: " + connector + " failed", e);
                                }
                            }
                        });
                    } else {
                        connector.start();
                    }
                }
                if (networkConnectorStartExecutor != null) {
                    // executor done when enqueued tasks are complete
                    networkConnectorStartExecutor.shutdown();
                    networkConnectorStartExecutor = null;
                }

                for (Iterator<ProxyConnector> iter = getProxyConnectors().iterator(); iter.hasNext();) {
                    ProxyConnector connector = iter.next();
                    connector.start();
                }
                for (Iterator<JmsConnector> iter = jmsConnectors.iterator(); iter.hasNext();) {
                    JmsConnector connector = iter.next();
                    connector.start();
                }
                for (Service service : services) {
                    configureService(service);
                    service.start();
                }
View Full Code Here

    public void testSendToRemovedTemp() throws Exception {

        ActiveMQQueue requestReplyDest = new ActiveMQQueue("RequestReply");

        NetworkConnector nc = bridgeBrokers("BrokerA", "BrokerB");
        if (useDuplex) {
            nc.setDuplex(true);
        } else {
            bridgeBrokers("BrokerB", "BrokerA");
        }

        // destination advisory can loose the race with message dispatch, so we need to allow replies on network broker
View Full Code Here

       
        BrokerService broker = new BrokerService();
        broker.setDedicatedTaskRunner(true);
        broker.setPersistent(false);
        broker.addConnector("tcp://localhost:61616");
        NetworkConnector networkConnector = broker.addNetworkConnector("static:(tcp://wrongHostname1:61617,tcp://wrongHostname2:61618)?useExponentialBackOff=false");
        networkConnector.setDuplex(true);
        broker.start();
       
        ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(new URI(VM_BROKER_URI));
        Connection connection = cf.createConnection("system", "manager");
        connection.start();
View Full Code Here

        connector.start();
        return connector.getName();
    }

    public String addNetworkConnector(String discoveryAddress) throws Exception {
        NetworkConnector connector = brokerService.addNetworkConnector(discoveryAddress);
        if (connector == null) {
            throw new NoSuchElementException("Not connector matched the given name: " + discoveryAddress);
        }
        connector.start();
        return connector.getName();
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.network.NetworkConnector

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.