qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Barker" <mark.bar...@shaw.ca>
Subject New User JMS API Questions
Date Wed, 12 Feb 2014 03:14:24 GMT
Apologies in advance if this shows up twice, but I seem to have had problems 
sending from my work account...



I have been playing around with the Hello.java example that came with 
I have installed the qpidd package (the broker) on a Ubuntu 12.04 LTS 
platform along with the qpid-tools package
(from the Ubuntu Software Centre).

I am looking to try and integrate the Qpid broker with JMS-based clients. I 
am brand new to all of the concepts and my
understanding is possibly being confused by the differences in terminology 
between JMS and Qpid elements.
I would greatly appreciate if you can indulge a few questions arising from 
my initial foray...

By modifying the code to use the pub/sub API, I have arrived at this source 

package org.apache.qpid.example;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;

public class Hello2
    public Hello2()
    public static void main(String[] args)
        Hello2 hello2 = new Hello2();
    private void runTest()
        try {
            Properties properties = new Properties();
            Context context = new InitialContext(properties);
            TopicConnectionFactory topicConnectionFactory = 
(TopicConnectionFactory) context.lookup("qpidConnectionfactory");
            TopicConnection topicConnection = 
            TopicSession topicSession = 
topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            Topic topic = (Topic) context.lookup("topicExchange");

            TopicPublisher topicPublisher = 
            TopicSubscriber topicSubscriber = 
            TextMessage message = topicSession.createTextMessage("Hello 
            message = (TextMessage)topicSubscriber.receive();
        catch (Exception exp)

Now, hello2.properties looks like this:
java.naming.factory.initial = 
# register some connection factories
# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.qpidConnectionfactory = 
# Register an AMQP destination in JNDI
# destination.[jniName] = [Address Format]
destination.topicExchange = news-service2
#topic.topicExchange = news-service2

Before running the program, I adminstratively create the topic exchange via 
% qpid-config add exchange topic news-service2

Now... "AS-IS", the above code/properties combination "works" - i.e. when I 
compile and run Hello2.jar, I see this output:
Hello world!

If I use the command-line "qpid-stat -e", I do indeed see msgIn and msgOut 
counters incrementing for the "news-service2"
topic exchange.
What I don't understand (my first question) here is why the 
"topic.getTopicName()" call is returning "null" in this instance?

When I substitute "topic.topicExchange" for "destination.topicExchange" in 
the hello2.properties file, I get this output:
Hello world!

Here, "topic.getTopicName()" actually returns the expected string 
However, in this case "qpid-stat-e" shows that the corresponding topic 
exchange "news-service2" has NOT changed its
msgIn/msgOut counters, BUT the counts for amq.topic have changed instead. My 
second question therefore is why have these
messages ended up in amq.topic?

A final question (more of a related query). If I use the default (original) 
example code Hello.java, but in hello.properties
substitute "destination.topicExchange = amq.topic" for "queue.topicExchange 
= some_queue_name", I note that even if
"some_queue_name" did not exist in the broker prior to running Hello, then 
it is created. This behaviour doesn't seem to work
for "topic.topicExchange" so I was wondering why the discrepancy.

Thanks for indulging these newbie questions!


To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org

View raw message