Package org.apache.activemq.advisory

Examples of org.apache.activemq.advisory.ConsumerEventSource


   
    protected void assertConsumersConnect(String brokerName, Destination destination, final int count, long timeout) throws Exception {
        BrokerItem brokerItem = brokers.get(brokerName);
        Connection conn = brokerItem.createConnection();
        conn.start();
        ConsumerEventSource ces = new ConsumerEventSource(conn, destination);

        try {
          final AtomicInteger actualConnected = new AtomicInteger();
          final CountDownLatch latch = new CountDownLatch(1);       
          ces.setConsumerListener(new ConsumerListener(){
        public void onConsumerEvent(ConsumerEvent event) {
          if( actualConnected.get() < count ) {
            actualConnected.set(event.getConsumerCount());
          }
          if( event.getConsumerCount() >= count ) {
            latch.countDown();
          }       
        }
      });
          ces.start();
         
          latch.await(timeout, TimeUnit.MILLISECONDS);
          assertTrue("Expected at least "+count+" consumers to connect, but only "+actualConnected.get()+" connectect within "+timeout+" ms", actualConnected.get() >= count);
         
        } finally {
            ces.stop();
            conn.close();
            brokerItem.connections.remove(conn);
        }
    }
View Full Code Here


        final AtomicInteger rc = new AtomicInteger(0);
        Connection connection = cf.createConnection();
        connections.add(connection);
        connection.start();

        ConsumerEventSource source = new ConsumerEventSource(connection, destination);
        source.setConsumerListener(new ConsumerListener() {
            public void onConsumerEvent(ConsumerEvent event) {
                rc.set(event.getConsumerCount());
            }
        });
        source.start();

        return rc;
    }
View Full Code Here

        final AtomicInteger rc = new AtomicInteger(0);
        Connection connection = cf.createConnection();
        connections.add(connection);
        connection.start();

        ConsumerEventSource source = new ConsumerEventSource(connection, destination);
        source.setConsumerListener(new ConsumerListener() {
            public void onConsumerEvent(ConsumerEvent event) {
                rc.set(event.getConsumerCount());
            }
        });
        source.start();

        return rc;
    }
View Full Code Here

   
    protected void assertConsumersConnect(String brokerName, Destination destination, final int count, long timeout) throws Exception {
        BrokerItem brokerItem = brokers.get(brokerName);
        Connection conn = brokerItem.createConnection();
        conn.start();
        ConsumerEventSource ces = new ConsumerEventSource(conn, destination);

        try {
          final AtomicInteger actualConnected = new AtomicInteger();
          final CountDownLatch latch = new CountDownLatch(1);       
          ces.setConsumerListener(new ConsumerListener(){
        public void onConsumerEvent(ConsumerEvent event) {
          if( actualConnected.get() < count ) {
            actualConnected.set(event.getConsumerCount());
          }
          if( event.getConsumerCount() >= count ) {
            latch.countDown();
          }       
        }
      });
          ces.start();
         
          latch.await(timeout, TimeUnit.MILLISECONDS);
          assertTrue("Expected at least "+count+" consumers to connect, but only "+actualConnected.get()+" connectect within "+timeout+" ms", actualConnected.get() >= count);
         
        } finally {
            ces.stop();
            conn.close();
            brokerItem.connections.remove(conn);
        }
    }
View Full Code Here

        final AtomicInteger rc = new AtomicInteger(0);
        Connection connection = cf.createConnection();
        connections.add(connection);
        connection.start();

        ConsumerEventSource source = new ConsumerEventSource(connection, destination);
        source.setConsumerListener(new ConsumerListener() {
            public void onConsumerEvent(ConsumerEvent event) {
                rc.set(event.getConsumerCount());
            }
        });
        source.start();

        return rc;
    }
View Full Code Here

        final AtomicInteger rc = new AtomicInteger(0);
        Connection connection = cf.createConnection();
        connections.add(connection);
        connection.start();

        ConsumerEventSource source = new ConsumerEventSource(connection, destination);
        source.setConsumerListener(new ConsumerListener() {
            public void onConsumerEvent(ConsumerEvent event) {
                rc.set(event.getConsumerCount());
            }
        });
        source.start();

        return rc;
    }
View Full Code Here

   
    protected void assertConsumersConnect(String brokerName, Destination destination, final int count, long timeout) throws Exception {
        BrokerItem brokerItem = brokers.get(brokerName);
        Connection conn = brokerItem.createConnection();
        conn.start();
        ConsumerEventSource ces = new ConsumerEventSource(conn, destination);

        try {
          final AtomicInteger actualConnected = new AtomicInteger();
          final CountDownLatch latch = new CountDownLatch(1);       
          ces.setConsumerListener(new ConsumerListener(){
        public void onConsumerEvent(ConsumerEvent event) {
          if( actualConnected.get() < count ) {
            actualConnected.set(event.getConsumerCount());
          }
          if( event.getConsumerCount() >= count ) {
            latch.countDown();
          }       
        }
      });
          ces.start();
         
          latch.await(timeout, TimeUnit.MILLISECONDS);
          assertTrue("Expected at least "+count+" consumers to connect, but only "+actualConnected.get()+" connectect within "+timeout+" ms", actualConnected.get() >= count);
         
        } finally {
            ces.stop();
            conn.close();
            brokerItem.connections.remove(conn);
        }
    }
View Full Code Here

        final AtomicInteger rc = new AtomicInteger(0);
        Connection connection = cf.createConnection();
        connections.add(connection);
        connection.start();

        ConsumerEventSource source = new ConsumerEventSource(connection, destination);
        source.setConsumerListener(new ConsumerListener() {
            public void onConsumerEvent(ConsumerEvent event) {
                rc.set(event.getConsumerCount());
            }
        });
        source.start();

        return rc;
    }
View Full Code Here

 
  @Override
  protected void start() throws PublisherRegistrationFailedFault {
    if (demand) {
      try {
        advisory = new ConsumerEventSource(connection, jmsTopic);
        advisory.setConsumerListener(this);
        advisory.start();
      } catch (Exception e) {
        PublisherRegistrationFailedFaultType fault = new PublisherRegistrationFailedFaultType();
        throw new PublisherRegistrationFailedFault("Error starting demand-based publisher", fault, e);
View Full Code Here

   
    protected void assertConsumersConnect(String brokerName, Destination destination, final int count, long timeout) throws Exception {
        BrokerItem brokerItem = brokers.get(brokerName);
        Connection conn = brokerItem.createConnection();
        conn.start();
        ConsumerEventSource ces = new ConsumerEventSource(conn, destination);

        try {
          final AtomicInteger actualConnected = new AtomicInteger();
          final CountDownLatch latch = new CountDownLatch(1);       
          ces.setConsumerListener(new ConsumerListener(){
        public void onConsumerEvent(ConsumerEvent event) {
          if( actualConnected.get() < count ) {
            actualConnected.set(event.getConsumerCount());
          }
          if( event.getConsumerCount() >= count ) {
            latch.countDown();
          }       
        }
      });
          ces.start();
         
          latch.await(timeout, TimeUnit.MILLISECONDS);
          assertTrue("Expected at least "+count+" consumers to connect, but only "+actualConnected.get()+" connectect within "+timeout+" ms", actualConnected.get() >= count);
         
        } finally {
            ces.stop();
            conn.close();
            brokerItem.connections.remove(conn);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.advisory.ConsumerEventSource

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.