messenger.h
Go to the documentation of this file.
#ifndef PROTON_MESSENGER_H
#define PROTON_MESSENGER_H 1
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
#include <proton/import_export.h>
#include <proton/message.h>
#include <proton/selectable.h>
#include <proton/link.h>
#include <proton/transport.h>
#include <proton/ssl.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct pn_messenger_t pn_messenger_t;
typedef struct pn_subscription_t pn_subscription_t;
typedef int64_t pn_tracker_t;
typedef enum {
PN_STATUS_UNKNOWN = 0,
PN_STATUS_PENDING = 1,
PN_STATUS_ACCEPTED = 2,
PN_STATUS_REJECTED = 3,
PN_STATUS_RELEASED = 4,
PN_STATUS_MODIFIED = 5,
PN_STATUS_ABORTED = 6,
PN_STATUS_SETTLED = 7
} pn_status_t;
PNX_EXTERN pn_messenger_t *pn_messenger(const char *name);
PNX_EXTERN const char *pn_messenger_name(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_set_certificate(pn_messenger_t *messenger, const char *certificate);
PNX_EXTERN const char *pn_messenger_get_certificate(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_set_private_key(pn_messenger_t *messenger, const char *private_key);
PNX_EXTERN const char *pn_messenger_get_private_key(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_set_password(pn_messenger_t *messenger, const char *password);
PNX_EXTERN const char *pn_messenger_get_password(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_set_trusted_certificates(pn_messenger_t *messenger, const char *cert_db);
PNX_EXTERN const char *pn_messenger_get_trusted_certificates(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_set_timeout(pn_messenger_t *messenger, int timeout);
PNX_EXTERN int pn_messenger_get_timeout(pn_messenger_t *messenger);
PNX_EXTERN bool pn_messenger_is_blocking(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_set_blocking(pn_messenger_t *messenger, bool blocking);
PNX_EXTERN bool pn_messenger_is_passive(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_set_passive(pn_messenger_t *messenger, bool passive);
PNX_EXTERN void pn_messenger_free(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_errno(pn_messenger_t *messenger);
PNX_EXTERN pn_error_t *pn_messenger_error(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_get_outgoing_window(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_set_outgoing_window(pn_messenger_t *messenger, int window);
PNX_EXTERN int pn_messenger_get_incoming_window(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_set_incoming_window(pn_messenger_t *messenger,
int window);
PNX_EXTERN int pn_messenger_start(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_stop(pn_messenger_t *messenger);
PNX_EXTERN bool pn_messenger_stopped(pn_messenger_t *messenger);
PNX_EXTERN pn_subscription_t *pn_messenger_subscribe(pn_messenger_t *messenger, const char *source);
PNX_EXTERN pn_subscription_t *
pn_messenger_subscribe_ttl(pn_messenger_t *messenger, const char *source,
pn_seconds_t timeout);
PNX_EXTERN pn_link_t *pn_messenger_get_link(pn_messenger_t *messenger,
const char *address, bool sender);
PNX_EXTERN void *pn_subscription_get_context(pn_subscription_t *sub);
PNX_EXTERN void pn_subscription_set_context(pn_subscription_t *sub, void *context);
PNX_EXTERN const char *pn_subscription_address(pn_subscription_t *sub);
PNX_EXTERN int pn_messenger_put(pn_messenger_t *messenger, pn_message_t *msg);
PNX_EXTERN pn_status_t pn_messenger_status(pn_messenger_t *messenger, pn_tracker_t tracker);
PNX_EXTERN pn_delivery_t *pn_messenger_delivery(pn_messenger_t *messenger,
pn_tracker_t tracker);
PNX_EXTERN bool pn_messenger_buffered(pn_messenger_t *messenger, pn_tracker_t tracker);
PNX_EXTERN int pn_messenger_settle(pn_messenger_t *messenger, pn_tracker_t tracker, int flags);
PNX_EXTERN pn_tracker_t pn_messenger_outgoing_tracker(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_work(pn_messenger_t *messenger, int timeout);
PNX_EXTERN int pn_messenger_interrupt(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_send(pn_messenger_t *messenger, int n);
PNX_EXTERN int pn_messenger_recv(pn_messenger_t *messenger, int limit);
PNX_EXTERN int pn_messenger_receiving(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_get(pn_messenger_t *messenger, pn_message_t *message);
PNX_EXTERN pn_tracker_t pn_messenger_incoming_tracker(pn_messenger_t *messenger);
PNX_EXTERN pn_subscription_t *pn_messenger_incoming_subscription(pn_messenger_t *messenger);
#define PN_CUMULATIVE (0x1)
PNX_EXTERN int pn_messenger_accept(pn_messenger_t *messenger, pn_tracker_t tracker, int flags);
PNX_EXTERN int pn_messenger_reject(pn_messenger_t *messenger, pn_tracker_t tracker, int flags);
PNX_EXTERN pn_link_t *pn_messenger_tracker_link(pn_messenger_t *messenger,
pn_tracker_t tracker);
PNX_EXTERN int pn_messenger_outgoing(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_incoming(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_route(pn_messenger_t *messenger, const char *pattern,
const char *address);
PNX_EXTERN int pn_messenger_rewrite(pn_messenger_t *messenger, const char *pattern,
const char *address);
PNX_EXTERN pn_selectable_t *pn_messenger_selectable(pn_messenger_t *messenger);
PNX_EXTERN pn_timestamp_t pn_messenger_deadline(pn_messenger_t *messenger);
#define PN_FLAGS_CHECK_ROUTES \
(0x1)
#define PN_FLAGS_ALLOW_INSECURE_MECHS \
(0x2)
PNX_EXTERN int pn_messenger_set_flags(pn_messenger_t *messenger,
const int flags);
PNX_EXTERN int pn_messenger_get_flags(pn_messenger_t *messenger);
PNX_EXTERN int pn_messenger_set_snd_settle_mode(pn_messenger_t *messenger,
const pn_snd_settle_mode_t mode);
PNX_EXTERN int pn_messenger_set_rcv_settle_mode(pn_messenger_t *messenger,
const pn_rcv_settle_mode_t mode);
PNX_EXTERN void pn_messenger_set_tracer(pn_messenger_t *messenger,
pn_tracer_t tracer);
PNX_EXTERN pn_millis_t
pn_messenger_get_remote_idle_timeout(pn_messenger_t *messenger,
const char *address);
PNX_EXTERN int
pn_messenger_set_ssl_peer_authentication_mode(pn_messenger_t *messenger,
const pn_ssl_verify_mode_t mode);
#ifdef __cplusplus
}
#endif
#endif /* messenger.h */
pn_timestamp_t
int64_t pn_timestamp_t
A 64-bit timestamp in milliseconds since the Unix epoch.
Definition: types.h:166
pn_millis_t
uint32_t pn_millis_t
A span of time in milliseconds.
Definition: types.h:145
pn_seconds_t
uint32_t pn_seconds_t
A span of time in seconds.
Definition: types.h:159
pn_delivery_t
struct pn_delivery_t pn_delivery_t
An AMQP Delivery object.
Definition: types.h:401
pn_error_t
struct pn_error_t pn_error_t
An int error code and some string text to describe the error.
Definition: error.h:44
pn_snd_settle_mode_t
pn_snd_settle_mode_t
Describes the permitted/expected settlement behaviours of a sending link.
Definition: link.h:474
pn_link_t
struct pn_link_t pn_link_t
An AMQP Link object.
Definition: types.h:311
pn_rcv_settle_mode_t
pn_rcv_settle_mode_t
Describes the permitted/expected settlement behaviours of a receiving link.
Definition: link.h:491
pn_message_t
struct pn_message_t pn_message_t
An AMQP Message object.
Definition: message.h:51
pn_messenger_outgoing_tracker
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.
pn_messenger_error
pn_error_t * pn_messenger_error(pn_messenger_t *messenger)
Get a messenger's error object.
pn_messenger_set_timeout
int pn_messenger_set_timeout(pn_messenger_t *messenger, int timeout)
Set the default timeout for a messenger.
pn_messenger_set_private_key
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_messenger_outgoing
int pn_messenger_outgoing(pn_messenger_t *messenger)
Get the number of messages in the outgoing message queue of a messenger.
pn_messenger_get_timeout
int pn_messenger_get_timeout(pn_messenger_t *messenger)
Gets the timeout for a messenger object.
pn_messenger_t
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_messenger_accept
int pn_messenger_accept(pn_messenger_t *messenger, pn_tracker_t tracker, int flags)
Signal successful processing of message(s).
pn_messenger_buffered
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.
pn_messenger_recv
int pn_messenger_recv(pn_messenger_t *messenger, int limit)
Retrieve messages into a messenger's incoming queue.
pn_messenger_get_certificate
const char * pn_messenger_get_certificate(pn_messenger_t *messenger)
Get the certificate path.
pn_messenger_deadline
pn_timestamp_t pn_messenger_deadline(pn_messenger_t *messenger)
Get the nearest deadline for selectables associated with a messenger.
pn_messenger_reject
int pn_messenger_reject(pn_messenger_t *messenger, pn_tracker_t tracker, int flags)
Signal unsuccessful processing of message(s).
pn_status_t
pn_status_t
Describes all the possible states for a message associated with a given tracker.
Definition: messenger.h:175
pn_subscription_set_context
void pn_subscription_set_context(pn_subscription_t *sub, void *context)
Set an application context for a subscription.
pn_messenger_get_password
const char * pn_messenger_get_password(pn_messenger_t *messenger)
Gets the private key file password for a messenger.
pn_messenger_incoming
int pn_messenger_incoming(pn_messenger_t *messenger)
Get the number of messages in the incoming message queue of a messenger.
pn_messenger_get_incoming_window
int pn_messenger_get_incoming_window(pn_messenger_t *messenger)
Get the size of a messenger's incoming window.
pn_messenger_settle
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_messenger_work
int pn_messenger_work(pn_messenger_t *messenger, int timeout)
Sends or receives any outstanding messages queued for a messenger.
pn_messenger_subscribe_ttl
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...
pn_messenger_free
void pn_messenger_free(pn_messenger_t *messenger)
Frees a Messenger.
pn_messenger_set_ssl_peer_authentication_mode
int pn_messenger_set_ssl_peer_authentication_mode(pn_messenger_t *messenger, const pn_ssl_verify_mode_t mode)
Sets the SSL peer authentication mode required when a trust certificate is used.
pn_messenger_is_passive
bool pn_messenger_is_passive(pn_messenger_t *messenger)
Check if a messenger is in passive mode.
pn_messenger_delivery
pn_delivery_t * pn_messenger_delivery(pn_messenger_t *messenger, pn_tracker_t tracker)
Get delivery information about a delivery.
pn_messenger_set_password
int pn_messenger_set_password(pn_messenger_t *messenger, const char *password)
Sets the private key password for a messenger.
pn_messenger_set_tracer
void pn_messenger_set_tracer(pn_messenger_t *messenger, pn_tracer_t tracer)
Set the tracer associated with a messenger.
pn_messenger_route
int pn_messenger_route(pn_messenger_t *messenger, const char *pattern, const char *address)
Adds a routing rule to a Messenger's internal routing table.
pn_messenger_start
int pn_messenger_start(pn_messenger_t *messenger)
Currently a no-op placeholder.
pn_messenger_name
const char * pn_messenger_name(pn_messenger_t *messenger)
Get the name of a messenger.
pn_messenger_get_link
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.
pn_messenger_set_snd_settle_mode
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.
pn_messenger_selectable
pn_selectable_t * pn_messenger_selectable(pn_messenger_t *messenger)
Extract selectables from a passive messenger.
pn_subscription_get_context
void * pn_subscription_get_context(pn_subscription_t *sub)
Get a subscription's application context.
pn_subscription_address
const char * pn_subscription_address(pn_subscription_t *sub)
Get the source address of a subscription.
pn_messenger_get_trusted_certificates
const char * pn_messenger_get_trusted_certificates(pn_messenger_t *messenger)
Gets the trusted certificates database for a messenger.
pn_messenger_set_outgoing_window
int pn_messenger_set_outgoing_window(pn_messenger_t *messenger, int window)
Set the size of a messenger's outgoing window.
pn_messenger_get_remote_idle_timeout
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.
pn_messenger_interrupt
int pn_messenger_interrupt(pn_messenger_t *messenger)
Interrupt a messenger object that may be blocking in another thread.
pn_messenger_get_flags
int pn_messenger_get_flags(pn_messenger_t *messenger)
Gets the flags for a Messenger.
pn_messenger_get
int pn_messenger_get(pn_messenger_t *messenger, pn_message_t *message)
Get the next message from the head of a messenger's incoming queue.
pn_tracker_t
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_messenger_get_private_key
const char * pn_messenger_get_private_key(pn_messenger_t *messenger)
Gets the private key file for a messenger.
pn_subscription_t
struct pn_subscription_t pn_subscription_t
A subscription is a request for incoming messages.
Definition: messenger.h:163
pn_messenger
pn_messenger_t * pn_messenger(const char *name)
Construct a new pn_messenger_t with the given name.
pn_messenger_get_outgoing_window
int pn_messenger_get_outgoing_window(pn_messenger_t *messenger)
Get the size of a messenger's outgoing window.
pn_messenger_subscribe
pn_subscription_t * pn_messenger_subscribe(pn_messenger_t *messenger, const char *source)
Subscribes a messenger to messages from the specified source.
pn_messenger_rewrite
int pn_messenger_rewrite(pn_messenger_t *messenger, const char *pattern, const char *address)
Rewrite message addresses prior to transmission.
pn_messenger_set_passive
int pn_messenger_set_passive(pn_messenger_t *messenger, bool passive)
Set the passive mode for a messenger.
pn_messenger_set_flags
int pn_messenger_set_flags(pn_messenger_t *messenger, const int flags)
Sets control flags to enable additional function for the Messenger.
pn_messenger_errno
int pn_messenger_errno(pn_messenger_t *messenger)
Get the code for a messenger's most recent error.
pn_messenger_status
pn_status_t pn_messenger_status(pn_messenger_t *messenger, pn_tracker_t tracker)
Track the status of a delivery.
pn_messenger_set_certificate
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...
pn_messenger_set_trusted_certificates
int pn_messenger_set_trusted_certificates(pn_messenger_t *messenger, const char *cert_db)
Sets the trusted certificates database for a messenger.
pn_messenger_stop
int pn_messenger_stop(pn_messenger_t *messenger)
Stops a messenger.
pn_messenger_set_incoming_window
int pn_messenger_set_incoming_window(pn_messenger_t *messenger, int window)
Set the size of a messenger's incoming window.
pn_messenger_stopped
bool pn_messenger_stopped(pn_messenger_t *messenger)
Returns true if a messenger is in the stopped state.
pn_messenger_send
int pn_messenger_send(pn_messenger_t *messenger, int n)
Send messages from a messenger's outgoing queue.
pn_messenger_incoming_subscription
pn_subscription_t * pn_messenger_incoming_subscription(pn_messenger_t *messenger)
Get the subscription of the message most recently retrieved by pn_messenger_get().
pn_messenger_tracker_link
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.
pn_messenger_set_blocking
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...
pn_messenger_set_rcv_settle_mode
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.
pn_messenger_receiving
int pn_messenger_receiving(pn_messenger_t *messenger)
Get the capacity of the incoming message queue of a messenger.
pn_messenger_is_blocking
bool pn_messenger_is_blocking(pn_messenger_t *messenger)
Check if a messenger is in blocking mode.
pn_messenger_incoming_tracker
pn_tracker_t pn_messenger_incoming_tracker(pn_messenger_t *messenger)
Get a tracker for the message most recently retrieved by pn_messenger_get().
pn_messenger_put
int pn_messenger_put(pn_messenger_t *messenger, pn_message_t *msg)
Puts a message onto the messenger's outgoing queue.
PN_STATUS_UNKNOWN
@ PN_STATUS_UNKNOWN
The tracker is unknown.
Definition: messenger.h:176
PN_STATUS_SETTLED
@ PN_STATUS_SETTLED
The remote party has settled the message.
Definition: messenger.h:185
PN_STATUS_ABORTED
@ PN_STATUS_ABORTED
The message was aborted.
Definition: messenger.h:184
PN_STATUS_PENDING
@ PN_STATUS_PENDING
The message is in flight.
Definition: messenger.h:177
PN_STATUS_RELEASED
@ PN_STATUS_RELEASED
The message was released.
Definition: messenger.h:182
PN_STATUS_ACCEPTED
@ PN_STATUS_ACCEPTED
The message was accepted.
Definition: messenger.h:180
PN_STATUS_MODIFIED
@ PN_STATUS_MODIFIED
The message was modified.
Definition: messenger.h:183
PN_STATUS_REJECTED
@ PN_STATUS_REJECTED
The message was rejected.
Definition: messenger.h:181
pn_ssl_verify_mode_t
pn_ssl_verify_mode_t
Determines the level of peer validation.
Definition: ssl.h:195
pn_tracer_t
void(* pn_tracer_t)(pn_transport_t *transport, const char *message)
Callback for customizing logging behaviour.
Definition: transport.h:62
link.h
A channel for transferring messages.
message.h
A mutable holder of application content.
ssl.h
SSL secure transport layer.
transport.h
A network channel supporting an AMQP connection.