Ejemplo n.º 1
0
  public static void main(final String[] args) throws Exception {
    // New session factory
    final MessageSessionFactory sessionFactory =
        new MetaMessageSessionFactory(buildMetaClientConfig());
    // subscribed topic
    final String topic = "meta-test-20";
    // consumer group
    final String group = "meta-vintage-x-4";
    // create consumer
    final MessageConsumer consumer = sessionFactory.createConsumer(new ConsumerConfig(group));

    String[] types = {"type1", "type2"};
    // subscribe topic
    consumer.subscribe(
        topic,
        1024 * 1024,
        new MessageListener() {

          public void recieveMessages(final Message message) {
            System.out.println(
                "newId:" + message.getMsgNewId() + "\t attribute is:" + message.getAttribute());
          }

          public Executor getExecutor() {
            return null;
          }
        },
        types);
    // complete subscribe
    consumer.completeSubscribe();
  }
 public void subscribe() throws Exception {
   consumer.subscribe(topic, 1024 * 1024, new HbaseConsumer()).completeSubscribe();
 }