If you have a reference to an existing Connection and you want to reuse it,
just use that instead of calling connectionFactory.createConnection() to
create a new connection (as stated right in the method name).  Nothing
requires you to create a new Connection if you already have one that will
meet your needs.
On Feb 10, 2016 10:52 AM, "Ramababu Bendalam" <haib....@gmail.com> wrote:

> Connection connection;
> Destination queue;
> Consumer consumer;
>
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("tcp://<hostname>:61616");
> connection = connectionFactory.createConnection();
> connection.start();
> session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> consumer = session.createConsumer(queue);
> consumer.setMessageListener(messageListener);
>
> While creating connection to connectionfactory, it creates a new connection
> with my localhostname.
> But i do not want that in my case. As i have already have a connection
> created. Is there is a way to use the existing connection instead of
> creating a new connection.
>
> In my case the given destination have two connections(one which already
> exists and the second one created during the test run) so the messages are
> distributed between the two connections and i could not able to retrieve
> the
> exact consumed messages count.
>
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Unable-to-consume-all-messages-from-the-existing-connection-tp4707311p4707385.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Reply via email to