Hello! First post here.

AMQ v5.7
Java v1.6
IDE: Eclipse Indigo

Goal:
I have an existing java application and I want to incorporate an instance of
ProducerTool in it. To do that, I should first be able to instantiate
ProducerTool without the ant script, so I modified the main method in
ProducerTool.java.

Setup:
-running the example using 'ant producer' works fine and I see 2000 messages
go by. That should give you an idea that I have completed the initial amq
setup properly.
-included the amq lib directory and specified the source code folder in the
eclipse project. This was so that I could build the project without ant
-Used ProducerTool.java as the main class in my run configuration.

-Ascertaining the default arguments from the build.xml, I modified the main
method as follows:

-------------
public static void main(String[] args)
    {
        int parallelThreads = 1;
        ArrayList<ProducerTool> threads = new ArrayList();
        ProducerTool producerTool = new ProducerTool();

        if (args.length == 0)
        {

            producerTool.setUrl("tcp://localhost:61616");
            producerTool.setTopic(false);
            producerTool.setSubject("TEST.FOO");
            producerTool.setPersistent(false);
            producerTool.setMessageCount(2);
            producerTool.setMessageSize(1000);
            producerTool.setParallelThreads(parallelThreads);
            producerTool.setTimeToLive(0);
            producerTool.setSleepTime(0);
            producerTool.setTransacted(false);
            producerTool.setVerbose(true);
        }
        else
        {
            String[] unknown = CommandLineSupport.setOptions(producerTool, 
args);
            if (unknown.length > 0)
            {
                System.out.println("Unknown options: " + 
Arrays.toString(unknown));
                System.exit(-1);
            }
        }

        producerTool.showParameters();
        ...
        ... (rest of the example code is unmodified)
-------------


Results:

When I run it, this is the output:

-------------
Connecting to URL: tcp://localhost:61616 (null:null)
Publishing a Message with size 1000 to queue: TEST.FOO
Using non-persistent messages
Sleeping between publish 0 ms
Running 1 parallel threads
log4j:WARN No appenders could be found for logger
(org.apache.activemq.thread.TaskRunnerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more info.
[Thread-1] Sending message: 'Message: 0 sent at: Mon Feb 04 09:46:49 CST
2013  ...'
[Thread-1] Sending message: 'Message: 1 sent at: Mon Feb 04 09:46:49 CST
2013  ...'
[Thread-1] Sending message: 'Message: 2 sent at: Mon Feb 04 09:46:49 CST
2013  ...'
[Thread-1] Sending message: 'Message: 3 sent at: Mon Feb 04 09:46:49 CST
2013  ...'
[Thread-1] Sending message: 'Message: 4 sent at: Mon Feb 04 09:46:49 CST
2013  ...'
[Thread-1] Sending message: 'Message: 5 sent at: Mon Feb 04 09:46:49 CST
2013  ...'
[Thread-1] Sending message: 'Message: 6 sent at: Mon Feb 04 09:46:49 CST
2013  ...'
[Thread-1] Sending message: 'Message: 7 sent at: Mon Feb 04 09:46:49 CST
2013  ...'
[Thread-1] Sending message: 'Message: 8 sent at: Mon Feb 04 09:46:49 CST
2013  ...'
[Thread-1] Sending message: 'Message: 9 sent at: Mon Feb 04 09:46:49 CST
2013  ...'
[Thread-1] Done.
[Thread-1] Results:

connection {
  session {
    messageCount{ count: 0 unit: count startTime: 1359992809453
lastSampleTime: 1359992809453 description: Number of messages exchanged }
    messageRateTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1359992809453
lastSampleTime: 1359992809453 description: Time taken to process a message
(thoughtput rate) }
    pendingMessageCount{ count: 0 unit: count startTime: 1359992809453
lastSampleTime: 1359992809453 description: Number of pending messages }
    expiredMessageCount{ count: 0 unit: count startTime: 1359992809453
lastSampleTime: 1359992809453 description: Number of expired messages }
    messageWaitTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1359992809453
lastSampleTime: 1359992809453 description: Time spent by a message before
being delivered }
    durableSubscriptionCount{ count: 0 unit: count startTime: 1359992809453
lastSampleTime: 1359992809453 description: The number of durable
subscriptions }

    producers {
      producer queue://TOOL.DEFAULT {
        messageCount{ count: 0 unit: count startTime: 1359992809464
lastSampleTime: 1359992809464 description: Number of messages processed }
        messageRateTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1359992809464
lastSampleTime: 1359992809464 description: Time taken to process a message
(thoughtput rate) }
        pendingMessageCount{ count: 0 unit: count startTime: 1359992809464
lastSampleTime: 1359992809464 description: Number of pending messages }
        messageRateTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1359992809464
lastSampleTime: 1359992809464 description: Time taken to process a message
(thoughtput rate) }
        expiredMessageCount{ count: 0 unit: count startTime: 1359992809464
lastSampleTime: 1359992809464 description: Number of expired messages }
        messageWaitTime{ count: 0 maxTime: 0 minTime: 0 totalTime: 0
averageTime: 0.0 averageTimeExMinMax: 0.0 averagePerSecond: 0.0
averagePerSecondExMinMax: 0.0 unit: millis startTime: 1359992809464
lastSampleTime: 1359992809464 description: Time spent by a message before
being delivered }
      }
    }
    consumers {
    }
  }
}
All threads completed their work
--------------

Issue:
The problem here is that it only sends 9 messages. What did I do wrong?

Of course, it could be that I am going about this all wrong. How then should
I integrate a ProducerTool with my existing code?


Thanks very much for your replies!



--
View this message in context: 
http://activemq.2283324.n4.nabble.com/How-to-instantiate-ProducerTool-without-using-the-ant-build-script-tp4662724.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to