Assuming your Queue name is "my-queue" and is already bound to TopicExchange with an appropriate binding, you can do the following.
destination.my-queue = my-queue destination.topicExchange = TopicExchange/usa.news You create your consumer with "my-queue" and your producer with "topicExchange". Your producer will be sending to the TopicExchange with routing key as "usa.news" If you need to create a producer that can sent to "TopicExchange" with different topics, then you can do the following destination.topicExchange = topicExchange and in the code you can set the subject as follows, message.setStringProperty("qpid.subject", "usa.news"); message.setStringProperty("qpid.subject", "usa.weather"); HTH Rajith P.S 1. Instead of using cumin/QMF you could also create your queue to the topic exchange using the following address destination.my-queue = TopicExchange/usa.# --> This will create a temp queue that binds to TopicExchange using "usa.#" destination.my-queue = TopicExchange/usa.#; {link : {name : my-queue} } --> This will create the queue "my-queue" that binds to TopicExchange using "usa.#" The above is assuming that TopicExchange exists. 2. You can't use this to set the routing key message.setStringProperty("x-amqp-0-10.routing-key", "usa.news"); The "x-amqp-0-10.routing-key" is only there to retrieve the AMQP 0-10 routing-key from an incoming message. On Tue, Dec 20, 2011 at 12:51 PM, eugene <eugen.ra...@gmail.com> wrote: > Hello to all, > > Well here is my issue, probably too easy for some of you, but anyhow. > > I installed the MRG on a box and cumin. Everything seems to fine, and by > fine I mean I can send a message to a queue and retrieve it with Java JMS. > > Now the issue is when trying to use the Topic Exchange. > > Using cumin I created a new Topic Exchange and a new Queue, and a binding > between them : "usa.#" for example. > > Now, I send a message to the topic which I crated, but how am I supposed to > set the routing key? Googling did not help (so far at least). > > Here is my config: > > java.naming.factory.initial=org.apache.qpid.jndi.PropertiesFileInitialContextFactory > connectionfactory.qpidConnectionfactory=amqp://guest:guest@clientid/test?brokerlist='tcp://locahost:5672' > destination.topicExchange = TopicExchange > > > Properties properties = new Properties(); > > properties.load(this.getClass().getResourceAsStream("/topic-properties/topic.properties")); > Context context = new InitialContext(properties); > > ConnectionFactory connectionFactory = (ConnectionFactory) > context.lookup("qpidConnectionfactory"); > Connection connection = connectionFactory.createConnection(); > connection.start(); > > Session > session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE); > Destination destination = (Destination) > context.lookup("topicExchange"); > > > MessageProducer messageProducer = > session.createProducer(destination); > MessageConsumer messageConsumer = > session.createConsumer(destination); > > TextMessage message = session.createTextMessage("Hello world!"); > messageProducer.send(message); > > message.setStringProperty("x-amqp-0-10.routing-key", "usa.news"); > > message = (TextMessage)messageConsumer.receive(); > System.out.println(message.getText()); > > connection.close(); > context.close(); > > > Can anyone plz suggest a way? > > Thx! Eugene > > -- > View this message in context: > http://apache-qpid-developers.2158895.n2.nabble.com/AMQP-Java-JMS-Topic-Exchange-tp7112690p7112690.html > Sent from the Apache Qpid developers mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > Apache Qpid - AMQP Messaging Implementation > Project: http://qpid.apache.org > Use/Interact: mailto:dev-subscr...@qpid.apache.org > --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:dev-subscr...@qpid.apache.org