activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gaohoward <...@git.apache.org>
Subject [GitHub] activemq-6 pull request: Fixing Proton CPP example
Date Tue, 17 Mar 2015 02:25:50 GMT
Github user gaohoward commented on a diff in the pull request:

    https://github.com/apache/activemq-6/pull/188#discussion_r26545193
  
    --- Diff: examples/jms/proton-cpp/src/main/java/org/apache/activemq/jms/example/ProtonCPPExample.java
---
    @@ -0,0 +1,141 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements. See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License. You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.activemq.jms.example;
    +
    +import javax.jms.Connection;
    +import javax.jms.ConnectionFactory;
    +import javax.jms.Message;
    +import javax.jms.MessageConsumer;
    +import javax.jms.MessageProducer;
    +import javax.jms.Queue;
    +import javax.jms.QueueConnection;
    +import javax.jms.QueueRequestor;
    +import javax.jms.QueueSession;
    +import javax.jms.Session;
    +import javax.jms.TextMessage;
    +import javax.naming.InitialContext;
    +
    +import org.apache.activemq.api.jms.ActiveMQJMSClient;
    +import org.apache.activemq.api.jms.ActiveMQJMSConstants;
    +import org.apache.activemq.api.jms.management.JMSManagementHelper;
    +
    +import org.apache.activemq.common.example.ActiveMQExample;
    +
    +/**
    + * This example demonstrates the use of ActiveMQ "pre-acknowledge" functionality where
    + * messages are acknowledged before they are delivered to the consumer.
    + *
    + * Please see the readme.html for more details.
    + */
    +public class ProtonCPPExample extends ActiveMQExample
    +{
    +   public static void main(final String[] args)
    +   {
    +      new ProtonCPPExample().run(args);
    +   }
    +
    +   @Override
    +   public boolean runExample() throws Exception
    +   {
    +      Connection connection = null;
    +
    +      InitialContext initialContext = null;
    +      try
    +      {
    +         // Step 1. Create an initial context to perform the JNDI lookup.
    +         initialContext = new InitialContext();
    +
    +         // Step 2. Perform the look-ups
    +         Queue queue = (Queue)initialContext.lookup("queue/exampleQueue");
    +
    +         ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("ConnectionFactory");
    +
    +         // Step 3. Create a the JMS objects
    +         connection = cf.createConnection();
    +
    +         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    +
    +         MessageConsumer messageConsumer = session.createConsumer(queue);
    +         
    +         MessageProducer producerAnswer = session.createProducer(queue);
    +
    +         // Step 4. Start the connection
    +         connection.start();
    +
    +         System.out.println("On a shell script, execute the following:");
    +
    +         System.out.println("./compile.sh");
    +
    +         System.out.println("./hello");
    +
    +         // Step 5. Finally, receive the message
    +         Message messageReceived = messageConsumer.receive(5000);
    --- End diff --
    
    Clebert can you make the timeout a litle longer? 5 sec is too short for running ./compile.sh
and ./hello in a separate terminal.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message