There is no a lot of documentation and examples how to deal with AMQP filters by using qpid-proton (Proton C API).
Deffierent approaches for working with Azure Event Hub are well described by the following link: Using Amqp.Net Lite with Azure Service Bus Event Hubs.
In my practice I’m using qpid-proton 0.8. To set the filter for retriving messages from Event Hub by timestamp offsset:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
pn_messenger_t *m_messenger = pn_messenger(NULL); // ... // About addresses and filters for Azure Event Hubs: // https://amqpnetlite.codeplex.com/wikipage?title=Using%20Amqp.Net%20Lite%20with%20Azure%20Server%20Bus%20Event%20Hub&referringTitle=Documentation char address[] = "amqps://user:password@host:port/path"; char filter_section[] = "apache.org:selector-filter:string"; // timestamp in milliseconds char filter_value[] = "amqp.annotation.x-opt-enqueuedtimeutc >= '1422627183000'"; // ... pn_subscription_t *subsribtion = pn_messenger_subscribe(m_messenger, address); // get a link and the source endpoint (terminus) pn_link_t *link = pn_messenger_get_link(m_messenger, address, false); pn_terminus_t *link_source = pn_link_source(link); pn_data_t *link_source_filter_data = pn_terminus_filter(link_source); pn_data_put_map(link_source_filter_data); // add a filter entry pn_data_enter(link_source_filter_data); // symbol key pn_data_put_symbol(link_source_filter_data, pn_bytes(strlen(filter_section), filter_section)); // described value pn_data_put_described(link_source_filter_data); pn_data_enter(link_source_filter_data); pn_data_put_symbol(link_source_filter_data, pn_bytes(strlen(filter_section), filter_section)); // filter expression as a string pn_data_put_string(link_source_filter_data, pn_bytes(strlen(filter_value), filter_value)); pn_data_exit(link_source_filter_data); pn_messenger_start(m_messenger); // ... // here we'll receive only messages with annotation.x-opt-enqueuedtimeutc >= '1422627183000' pn_messenger_recv(m_messenger, MESSAGES_COUNT); // ... |
You can get binaries of qpid-proton 0.8 as NuGet package which are compiled for processors with IA32 instructions set (I need it for my Intel Galileo Gen2 projects).