activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Snyder <bruce.sny...@gmail.com>
Subject Re: how to create queue or topic at run time
Date Wed, 22 Sep 2010 17:38:19 GMT
On Wed, Sep 22, 2010 at 6:18 AM, pp <preeti.padalia@gmail.com> wrote:
>
> Hi
>
> i m trying to create topic or queue at run time but it is giving a null
> pointer exception. can anyone give me a sample code for it.

Destination creation uses the session object like so:

// Create the connection
ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory(user, password, url);
connection = connectionFactory.createConnection();
connection.start();

// Create the session
Session session = connection.createSession(transacted,
Session.AUTO_ACKNOWLEDGE);

// Create a queue
Destination destination = session.createQueue(subject);

// Create a topic
Destination destination = session.createTopic(subject);

This code is taken directly from the examples that come with ActiveMQ.
Here's the SVN URL to the examples:

https://svn.apache.org/repos/asf/activemq/trunk/assembly/src/release/example/src/

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

ActiveMQ in Action: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder

Mime
View raw message