Re: CorrelationId

2014-12-09 Thread Dominic Evans
Hi Xavier,


xavier wrote
 I posted my solution, it works, but I did some performance test, and it's
 not very good, I found why. In my solution, I start, and stop for any
 receiver the messenger, because if I don't do this, with my code (posted)
 I receive one time, the message with a filter (attached to the link) but
 for the second message, (I change the filter before) I don't receive the
 message.
 
 I have not the competency on the engine, so I am lost how do this without
 start and stop messenger on each reception

So the behaviour you are seeing is because for the AMQP 1.0 protocol your
selector filter is set on the Link at attachment time, and I don't believe
there is any action that allows you to modify a filter once the link has
been established.

Theoretically, rather than doing a full pn_messenger_stop +
pn_messenger_start, you should be able to just do a pn_link_detach(link); /*
modify the filter */ ; pn_link_open(link); and that might give you
*slightly* better  performance. But I think if you are going to be doing
this on a per-message basis then you would be better of receiving all
messages on the Link and just accepting those that you are interested in via
correl id 



--
View this message in context: 
http://qpid.2158936.n2.nabble.com/CorrelationId-tp7614606p7617293.html
Sent from the Apache Qpid Proton mailing list archive at Nabble.com.


Re: CorrelationId

2014-12-09 Thread xavier
Hi Dominic

unfortunately, it 's does not work!!
I try your idea, see my code (I move the pn_link_detach() and pn_link_open()
in all my code, but .)
Here my code:

// Init one time to use many time
pn_messenger_t* msgConsumer= pn_messenger(NULL);
pn_messenger_set_timeout (msgConsumer, 1000);
pn_messenger_set_blocking (msgConsumer, true);
pn_messenger_set_incoming_window (msgConsumer, 1);

// After in a method
pn_messenger_subscribe(msgConsumer,
amqp://127.0.0.1:5672/queue://myqueue);
pn_link_t* link = pn_messenger_get_link(msgConsumer,
(amqp://127.0.0.1:5672/queue://myqueue).c_str(), false);

*pn_link_detach(link);*

pn_terminus_t* terminus = pn_link_source(link);
pn_data_t* data = pn_terminus_filter (terminus);
/* Map creation with selector*/
std::string selector = jms-selector;
pn_data_put_map(data);
pn_data_enter(data);
pn_data_put_symbol(data, pn_bytes(selector.size(), selector.c_str()));
// Described
std::string filter = JMSCorrelationID='12346789';
pn_data_put_described(data);
pn_data_enter(data);
pn_data_put_string(data, pn_bytes(6, string));
pn_data_put_string(data, pn_bytes(filter.size(), filter.c_str()));
pn_data_exit(data);

*pn_link_open(link);*

pn_messenger_recv(msgConsumer, -1);
if (pn_messenger_incoming(msgConsumer))
{
// The message is arrived
pn_message_t* message = pn_message();
pn_messenger_get(msgConsumer, message);
.
.
pn_message_free(message);
}


And unfortunately, I have a time out, the message is on the queue, and like
before (if I do pn_messenger_start  before pn_messenger_recv and
pn_messenger_stop after, it's works!!!


Your help is very important, I believe, I am not very far, but.

So what do you thinks Dominic???

Thanks a lot








--
View this message in context: 
http://qpid.2158936.n2.nabble.com/CorrelationId-tp7614606p7617311.html
Sent from the Apache Qpid Proton mailing list archive at Nabble.com.