Last active
August 29, 2015 14:14
-
-
Save ivanignatiev/3ac6b4bafd1d98022c95 to your computer and use it in GitHub Desktop.
Setting AMQP filter with Apache Qpid Proton C API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment