Qpid Proton C API  0.18.0
messenger.h
Go to the documentation of this file.
1 #ifndef PROTON_MESSENGER_H
2 #define PROTON_MESSENGER_H 1
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include <proton/import_export.h>
26 #include <proton/message.h>
27 #include <proton/selectable.h>
28 #include <proton/link.h>
29 #include <proton/transport.h>
30 #include <proton/ssl.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
155 
164 
169 typedef int64_t pn_tracker_t;
170 
175 typedef enum {
186 } pn_status_t;
187 
197 PNX_EXTERN pn_messenger_t *pn_messenger(const char *name);
198 
205 PNX_EXTERN const char *pn_messenger_name(pn_messenger_t *messenger);
206 
216 PNX_EXTERN int pn_messenger_set_certificate(pn_messenger_t *messenger, const char *certificate);
217 
225 PNX_EXTERN const char *pn_messenger_get_certificate(pn_messenger_t *messenger);
226 
235 PNX_EXTERN int pn_messenger_set_private_key(pn_messenger_t *messenger, const char *private_key);
236 
243 PNX_EXTERN const char *pn_messenger_get_private_key(pn_messenger_t *messenger);
244 
253 PNX_EXTERN int pn_messenger_set_password(pn_messenger_t *messenger, const char *password);
254 
261 PNX_EXTERN const char *pn_messenger_get_password(pn_messenger_t *messenger);
262 
274 PNX_EXTERN int pn_messenger_set_trusted_certificates(pn_messenger_t *messenger, const char *cert_db);
275 
282 PNX_EXTERN const char *pn_messenger_get_trusted_certificates(pn_messenger_t *messenger);
283 
296 PNX_EXTERN int pn_messenger_set_timeout(pn_messenger_t *messenger, int timeout);
297 
306 PNX_EXTERN int pn_messenger_get_timeout(pn_messenger_t *messenger);
307 
314 PNX_EXTERN bool pn_messenger_is_blocking(pn_messenger_t *messenger);
315 
324 PNX_EXTERN int pn_messenger_set_blocking(pn_messenger_t *messenger, bool blocking);
325 
338 PNX_EXTERN bool pn_messenger_is_passive(pn_messenger_t *messenger);
339 
350 PNX_EXTERN int pn_messenger_set_passive(pn_messenger_t *messenger, bool passive);
351 
357 PNX_EXTERN void pn_messenger_free(pn_messenger_t *messenger);
358 
372 PNX_EXTERN int pn_messenger_errno(pn_messenger_t *messenger);
373 
385 PNX_EXTERN pn_error_t *pn_messenger_error(pn_messenger_t *messenger);
386 
402 PNX_EXTERN int pn_messenger_get_outgoing_window(pn_messenger_t *messenger);
403 
414 PNX_EXTERN int pn_messenger_set_outgoing_window(pn_messenger_t *messenger, int window);
415 
434 PNX_EXTERN int pn_messenger_get_incoming_window(pn_messenger_t *messenger);
435 
446 PNX_EXTERN int pn_messenger_set_incoming_window(pn_messenger_t *messenger,
447  int window);
448 
457 PNX_EXTERN int pn_messenger_start(pn_messenger_t *messenger);
458 
473 PNX_EXTERN int pn_messenger_stop(pn_messenger_t *messenger);
474 
482 PNX_EXTERN bool pn_messenger_stopped(pn_messenger_t *messenger);
483 
491 PNX_EXTERN pn_subscription_t *pn_messenger_subscribe(pn_messenger_t *messenger, const char *source);
492 
503 PNX_EXTERN pn_subscription_t *
504 pn_messenger_subscribe_ttl(pn_messenger_t *messenger, const char *source,
505  pn_seconds_t timeout);
506 
516 PNX_EXTERN pn_link_t *pn_messenger_get_link(pn_messenger_t *messenger,
517  const char *address, bool sender);
518 
527 PNX_EXTERN void *pn_subscription_get_context(pn_subscription_t *sub);
528 
535 PNX_EXTERN void pn_subscription_set_context(pn_subscription_t *sub, void *context);
536 
543 PNX_EXTERN const char *pn_subscription_address(pn_subscription_t *sub);
544 
555 PNX_EXTERN int pn_messenger_put(pn_messenger_t *messenger, pn_message_t *msg);
556 
568 PNX_EXTERN pn_status_t pn_messenger_status(pn_messenger_t *messenger, pn_tracker_t tracker);
569 
581 PNX_EXTERN pn_delivery_t *pn_messenger_delivery(pn_messenger_t *messenger,
582  pn_tracker_t tracker);
583 
596 PNX_EXTERN bool pn_messenger_buffered(pn_messenger_t *messenger, pn_tracker_t tracker);
597 
610 PNX_EXTERN int pn_messenger_settle(pn_messenger_t *messenger, pn_tracker_t tracker, int flags);
611 
625 PNX_EXTERN pn_tracker_t pn_messenger_outgoing_tracker(pn_messenger_t *messenger);
626 
637 PNX_EXTERN int pn_messenger_work(pn_messenger_t *messenger, int timeout);
638 
650 PNX_EXTERN int pn_messenger_interrupt(pn_messenger_t *messenger);
651 
684 PNX_EXTERN int pn_messenger_send(pn_messenger_t *messenger, int n);
685 
710 PNX_EXTERN int pn_messenger_recv(pn_messenger_t *messenger, int limit);
711 
722 PNX_EXTERN int pn_messenger_receiving(pn_messenger_t *messenger);
723 
738 PNX_EXTERN int pn_messenger_get(pn_messenger_t *messenger, pn_message_t *message);
739 
753 PNX_EXTERN pn_tracker_t pn_messenger_incoming_tracker(pn_messenger_t *messenger);
754 
765 
769 #define PN_CUMULATIVE (0x1)
770 
792 PNX_EXTERN int pn_messenger_accept(pn_messenger_t *messenger, pn_tracker_t tracker, int flags);
793 
815 PNX_EXTERN int pn_messenger_reject(pn_messenger_t *messenger, pn_tracker_t tracker, int flags);
816 
824 PNX_EXTERN pn_link_t *pn_messenger_tracker_link(pn_messenger_t *messenger,
825  pn_tracker_t tracker);
826 
834 PNX_EXTERN int pn_messenger_outgoing(pn_messenger_t *messenger);
835 
842 PNX_EXTERN int pn_messenger_incoming(pn_messenger_t *messenger);
843 
906 PNX_EXTERN int pn_messenger_route(pn_messenger_t *messenger, const char *pattern,
907  const char *address);
908 
931 PNX_EXTERN int pn_messenger_rewrite(pn_messenger_t *messenger, const char *pattern,
932  const char *address);
933 
960 PNX_EXTERN pn_selectable_t *pn_messenger_selectable(pn_messenger_t *messenger);
961 
969 
970 #define PN_FLAGS_CHECK_ROUTES \
971  (0x1)
975 #define PN_FLAGS_ALLOW_INSECURE_MECHS \
976  (0x2)
988 PNX_EXTERN int pn_messenger_set_flags(pn_messenger_t *messenger,
989  const int flags);
990 
997 PNX_EXTERN int pn_messenger_get_flags(pn_messenger_t *messenger);
998 
1005 PNX_EXTERN int pn_messenger_set_snd_settle_mode(pn_messenger_t *messenger,
1006  const pn_snd_settle_mode_t mode);
1007 
1014 PNX_EXTERN int pn_messenger_set_rcv_settle_mode(pn_messenger_t *messenger,
1015  const pn_rcv_settle_mode_t mode);
1016 
1023 PNX_EXTERN void pn_messenger_set_tracer(pn_messenger_t *messenger,
1024  pn_tracer_t tracer);
1025 
1033 PNX_EXTERN pn_millis_t
1035  const char *address);
1036 
1046 PNX_EXTERN int
1048  const pn_ssl_verify_mode_t mode);
1049 
1054 #ifdef __cplusplus
1055 }
1056 #endif
1057 
1058 #endif /* messenger.h */
int pn_messenger_get_timeout(pn_messenger_t *messenger)
Gets the timeout for a messenger object.
pn_subscription_t * pn_messenger_incoming_subscription(pn_messenger_t *messenger)
Get the subscription of the message most recently retrieved by pn_messenger_get().
const char * pn_messenger_get_private_key(pn_messenger_t *messenger)
Gets the private key file for a messenger.
pn_error_t * pn_messenger_error(pn_messenger_t *messenger)
Get a messenger&#39;s error object.
uint32_t pn_millis_t
A span of time in milliseconds.
Definition: types.h:145
const char * pn_messenger_get_password(pn_messenger_t *messenger)
Gets the private key file password for a messenger.
int pn_messenger_set_private_key(pn_messenger_t *messenger, const char *private_key)
Set path to the private key that was used to sign the certificate.
pn_tracker_t pn_messenger_incoming_tracker(pn_messenger_t *messenger)
Get a tracker for the message most recently retrieved by pn_messenger_get().
int pn_messenger_set_trusted_certificates(pn_messenger_t *messenger, const char *cert_db)
Sets the trusted certificates database for a messenger.
A network channel supporting an AMQP connection.
int pn_messenger_receiving(pn_messenger_t *messenger)
Get the capacity of the incoming message queue of a messenger.
int pn_messenger_set_snd_settle_mode(pn_messenger_t *messenger, const pn_snd_settle_mode_t mode)
Set the local sender settle mode for the underlying link.
const char * pn_messenger_get_certificate(pn_messenger_t *messenger)
Get the certificate path.
const char * pn_subscription_address(pn_subscription_t *sub)
Get the source address of a subscription.
pn_subscription_t * pn_messenger_subscribe_ttl(pn_messenger_t *messenger, const char *source, pn_seconds_t timeout)
Subscribes a messenger to messages from the specified source with the given timeout for the subscript...
int pn_messenger_interrupt(pn_messenger_t *messenger)
Interrupt a messenger object that may be blocking in another thread.
bool pn_messenger_is_passive(pn_messenger_t *messenger)
Check if a messenger is in passive mode.
struct pn_message_t pn_message_t
An AMQP Message object.
Definition: message.h:51
bool pn_messenger_stopped(pn_messenger_t *messenger)
Returns true if a messenger is in the stopped state.
int pn_messenger_set_outgoing_window(pn_messenger_t *messenger, int window)
Set the size of a messenger&#39;s outgoing window.
int pn_messenger_set_rcv_settle_mode(pn_messenger_t *messenger, const pn_rcv_settle_mode_t mode)
Set the local receiver settle mode for the underlying link.
int pn_messenger_send(pn_messenger_t *messenger, int n)
Send messages from a messenger&#39;s outgoing queue.
int pn_messenger_errno(pn_messenger_t *messenger)
Get the code for a messenger&#39;s most recent error.
int64_t pn_tracker_t
Trackers provide a lightweight handle used to track the status of incoming and outgoing deliveries...
Definition: messenger.h:169
pn_status_t pn_messenger_status(pn_messenger_t *messenger, pn_tracker_t tracker)
Track the status of a delivery.
pn_ssl_verify_mode_t
Determines the level of peer validation.
Definition: ssl.h:195
struct pn_error_t pn_error_t
An int error code and some string text to describe the error.
Definition: error.h:44
A mutable holder of application content.
void * pn_subscription_get_context(pn_subscription_t *sub)
Get a subscription&#39;s application context.
pn_status_t
Describes all the possible states for a message associated with a given tracker.
Definition: messenger.h:175
bool pn_messenger_is_blocking(pn_messenger_t *messenger)
Check if a messenger is in blocking mode.
int pn_messenger_set_ssl_peer_authentication_mode(pn_messenger_t *messenger, const pn_ssl_verify_mode_t mode)
Sets the SSL peer authentiacation mode required when a trust certificate is used. ...
int pn_messenger_work(pn_messenger_t *messenger, int timeout)
Sends or receives any outstanding messages queued for a messenger.
struct pn_subscription_t pn_subscription_t
A subscription is a request for incoming messages.
Definition: messenger.h:163
const char * pn_messenger_name(pn_messenger_t *messenger)
Get the name of a messenger.
int pn_messenger_accept(pn_messenger_t *messenger, pn_tracker_t tracker, int flags)
Signal successful processing of message(s).
The message was accepted.
Definition: messenger.h:180
int pn_messenger_settle(pn_messenger_t *messenger, pn_tracker_t tracker, int flags)
Frees a Messenger from tracking the status associated with a given tracker.
pn_selectable_t * pn_messenger_selectable(pn_messenger_t *messenger)
Extract selectables from a passive messenger.
int pn_messenger_put(pn_messenger_t *messenger, pn_message_t *msg)
Puts a message onto the messenger&#39;s outgoing queue.
int pn_messenger_set_incoming_window(pn_messenger_t *messenger, int window)
Set the size of a messenger&#39;s incoming window.
int pn_messenger_rewrite(pn_messenger_t *messenger, const char *pattern, const char *address)
Rewrite message addresses prior to transmission.
int pn_messenger_stop(pn_messenger_t *messenger)
Stops a messenger.
The message is in flight.
Definition: messenger.h:177
struct pn_delivery_t pn_delivery_t
An AMQP Delivery object.
Definition: types.h:401
pn_link_t * pn_messenger_get_link(pn_messenger_t *messenger, const char *address, bool sender)
Get a link based on link name and whether the link is a sender or receiver.
int pn_messenger_set_certificate(pn_messenger_t *messenger, const char *certificate)
Sets the path that will be used to get the certificate that will be used to identify this messenger t...
int pn_messenger_route(pn_messenger_t *messenger, const char *pattern, const char *address)
Adds a routing rule to a Messenger&#39;s internal routing table.
pn_millis_t pn_messenger_get_remote_idle_timeout(pn_messenger_t *messenger, const char *address)
Gets the remote idle timeout for the specified remote service address.
The message was rejected.
Definition: messenger.h:181
int pn_messenger_start(pn_messenger_t *messenger)
Currently a no-op placeholder.
pn_link_t * pn_messenger_tracker_link(pn_messenger_t *messenger, pn_tracker_t tracker)
Get link for the message referenced by the given tracker.
The message was modified.
Definition: messenger.h:183
The remote party has settled the message.
Definition: messenger.h:185
bool pn_messenger_buffered(pn_messenger_t *messenger, pn_tracker_t tracker)
Check if the delivery associated with a given tracker is still waiting to be sent.
const char * pn_messenger_get_trusted_certificates(pn_messenger_t *messenger)
Gets the trusted certificates database for a messenger.
void pn_subscription_set_context(pn_subscription_t *sub, void *context)
Set an application context for a subscription.
uint32_t pn_seconds_t
A span of time in seconds.
Definition: types.h:159
pn_messenger_t * pn_messenger(const char *name)
Construct a new pn_messenger_t with the given name.
int pn_messenger_recv(pn_messenger_t *messenger, int limit)
Retrieve messages into a messenger&#39;s incoming queue.
The message was aborted.
Definition: messenger.h:184
The tracker is unknown.
Definition: messenger.h:176
int pn_messenger_set_passive(pn_messenger_t *messenger, bool passive)
Set the passive mode for a messenger.
int pn_messenger_get_incoming_window(pn_messenger_t *messenger)
Get the size of a messenger&#39;s incoming window.
int pn_messenger_incoming(pn_messenger_t *messenger)
Get the number of messages in the incoming message queue of a messenger.
void(* pn_tracer_t)(pn_transport_t *transport, const char *message)
Callback for customizing logging behaviour.
Definition: transport.h:62
int pn_messenger_outgoing(pn_messenger_t *messenger)
Get the number of messages in the outgoing message queue of a messenger.
void pn_messenger_free(pn_messenger_t *messenger)
Frees a Messenger.
The message was released.
Definition: messenger.h:182
int pn_messenger_get_flags(pn_messenger_t *messenger)
Gets the flags for a Messenger.
SSL secure transport layer.
int pn_messenger_set_timeout(pn_messenger_t *messenger, int timeout)
Set the default timeout for a messenger.
pn_tracker_t pn_messenger_outgoing_tracker(pn_messenger_t *messenger)
Get a tracker for the outgoing message most recently given to pn_messenger_put.
struct pn_messenger_t pn_messenger_t
A pn_messenger_t provides a high level interface for sending and receiving messages (See pn_message_t...
Definition: messenger.h:154
pn_subscription_t * pn_messenger_subscribe(pn_messenger_t *messenger, const char *source)
Subscribes a messenger to messages from the specified source.
pn_delivery_t * pn_messenger_delivery(pn_messenger_t *messenger, pn_tracker_t tracker)
Get delivery information about a delivery.
pn_timestamp_t pn_messenger_deadline(pn_messenger_t *messenger)
Get the nearest deadline for selectables associated with a messenger.
void pn_messenger_set_tracer(pn_messenger_t *messenger, pn_tracer_t tracer)
Set the tracer associated with a messenger.
int64_t pn_timestamp_t
A 64-bit timestamp in milliseconds since the Unix epoch.
Definition: types.h:166
int pn_messenger_set_blocking(pn_messenger_t *messenger, bool blocking)
Enable or disable blocking behavior for a messenger during calls to pn_messenger_send and pn_messenge...
int pn_messenger_reject(pn_messenger_t *messenger, pn_tracker_t tracker, int flags)
Signal unsuccessful processing of message(s).
int pn_messenger_get_outgoing_window(pn_messenger_t *messenger)
Get the size of a messenger&#39;s outgoing window.
int pn_messenger_set_password(pn_messenger_t *messenger, const char *password)
Sets the private key password for a messenger.
int pn_messenger_get(pn_messenger_t *messenger, pn_message_t *message)
Get the next message from the head of a messenger&#39;s incoming queue.