Hi Gordon,
Thanks for the prompt reply, I would like to further clarify my problem.
I am currently running the QPID JMS client and QPID CPP API against JBOSS A-MQ 
6.1 on AMQP 1.0 protocol. I am still having trouble initiating a 1pub/2sub 
model where the pub is java and the sub is c++. I have tried different address 
options however I am still unable to emulate AMQP "private queue bound to 
exchange" approach to pub/sub.
Also JBOSS A-MQ seems to not like subjects, since every time I add "/<subject>" 
to the address, the sub application will fail to receive messages. Anyway here 
comes the code:
//Java code starts//using Qpid Java client 0.28 AMQP1.0 librariespackage 
org.apache.qpid.amqp_1_0.jms.example;import javax.jms.*;import 
javax.naming.Context;import javax.naming.InitialContext;import 
java.util.Hashtable;
public class Spout{    public Spout()    {    }
    @SuppressWarnings({ "rawtypes", "unchecked" })    public static void 
main(String[] args)    {        try        {            
Class.forName("org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory");
            Hashtable env = new Hashtable();            
env.put("java.naming.provider.url", "hello.properties");            
env.put("java.naming.factory.initial", 
"org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory");
            Context context = new InitialContext(env);                        
ConnectionFactory connectionFactory = (ConnectionFactory) 
context.lookup("localhost");            Connection connection = 
connectionFactory.createConnection();                       connection.start(); 
           
            Session producersession = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);            Destination topic = 
producersession.createTopic("news"); //if i change the address to 
"news/somestuff" sub can't see, even if addresses match
            int count = 2;
            MessageProducer producer = producersession.createProducer(topic);   
                              for (int i=0; i < count; i++)            {        
        Message msg = producersession.createTextMessage("Hello news!");         
       producer.send(msg);                System.out.println("\n------------- 
Msg -------------");                System.out.println(msg);                
System.out.println("-------------------------------\n");            }           
 producer.close();
            connection.close();            context.close();        }        
catch (Exception exp)        {            System.out.println("Caught exception: 
" + exp.getMessage());            exp.printStackTrace();        }    }}//Java 
code ends


//C++ code starts#include <qpid/messaging/Connection.h>#include 
<qpid/messaging/Message.h>#include <qpid/messaging/Message_io.h>#include 
<qpid/messaging/Receiver.h>#include <qpid/messaging/Session.h>
#include <iostream>
using namespace qpid::messaging;using namespace qpid::types;using namespace std;
int main(){    Connection connection;    try {        string url = 
"localhost:5672";        string connectionOptions = "{protocol:amqp1.0}";       
 string address = "news"; //if i change the address to "news/somestuff" sub 
can't see, even if addresses match
        connection = Connection(url, connectionOptions);        
connection.open();        Session session = connection.createSession();        
Receiver receiver = session.createReceiver(address);        Duration timeout = 
300 * Duration::SECOND;        int count = 5;        Message message;        
int i = 0;
        while (receiver.fetch(message, timeout)) {            std::cout << 
message << std::endl;            session.acknowledge();            if (count && 
(++i == count))                break;        }        receiver.close();        
session.close();        connection.close();        return 0;    } catch(const 
std::exception& error) {        std::cout << "Error: " << error.what() << 
std::endl;        connection.close();    }    return 1;}//C++ code ends

This email is from me, Quynh D. 
This is to make sure things are not screwed up by spammers. 

> Date: Wed, 2 Jul 2014 11:09:03 +0100
> From: g...@redhat.com
> To: dev@qpid.apache.org
> Subject: Re: qpid cpp pub/sub
> 
> On 07/02/2014 10:47 AM, Quynh Duong wrote:
> > I'm a cpp developer and new to the qpid world. I have spent over a day 
> > tooling around with qpid cpp api and I was wondering how can I create a 
> > pub/sub model, since all the examples that come with the package doesn't 
> > give any hints on how it can be done. Things like binding-keys and such 
> > that exist on the JMS client doesn't seem to be available in the cpp api, 
> > or I must have overlooked. I am running and building all this on CentOS 6.5.
> > Please help, thank you.
> 
> It depends on the broker (or equivalent) you want to run against. If you 
> are using one of the Qpid brokers, you can just send/receive to/from a 
> particular exchange.
> 
> E.g. if you specify amq.topic/*.news as the address for your receiver, 
> then you can e.g. send to amq.topic setting different subjects on the 
> message, and subjects like europe.news or usa.news would be received by 
> the receiver whereas as usa.weather would not.
> 
> A more simple case would just be using e.g. amq,fanout for both sender 
> and receivers and then all messages to the topic will be received by all 
> receivers, i.e. with no wildcard filtering.
> 
> Have a look at 
> http://qpid.apache.org/releases/qpid-0.28/programming/book/section-addresses.html
>  
> for a brief description, and feel free to ask any further questions you 
> have!
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
> For additional commands, e-mail: dev-h...@qpid.apache.org
> 
                                          

Reply via email to