This chapter describes the specific mappings between classes in the .NET Binding and the underlying C++ Messaging API.
Table 2.9. .NET Binding for the C++ Messaging API Class: Address
| .NET Binding Class: Address | |
|---|---|
| Language | Syntax |
| C++ | class Address |
| .NET | public ref class Address |
| Constructor | |
| C++ | Address(); |
| .NET | public Address(); |
| Constructor | |
| C++ | Address(const std::string& address); |
| .NET | public Address(string address); |
| Constructor | |
| C++ | Address(const std::string& name, const std::string& subject, const qpid::types::Variant::Map& options, const std::string& type = ""); |
| .NET | public Address(string name, string subject, Dictionary<string, object> options); |
| .NET | public Address(string name, string subject, Dictionary<string, object> options, string type); |
| Copy constructor | |
| C++ | Address(const Address& address); |
| .NET | public Address(Address address); |
| Destructor | |
| C++ | ~Address(); |
| .NET | ~Address(); |
| Finalizer | |
| C++ | n/a |
| .NET | !Address(); |
| Copy assignment operator | |
| C++ | Address& operator=(const Address&); |
| .NET | public Address op_Assign(Address rhs); |
| Property: Name | |
| C++ | const std::string& getName() const; |
| C++ | void setName(const std::string&); |
| .NET | public string Name { get; set; } |
| Property: Subject | |
| C++ | const std::string& getSubject() const; |
| C++ | void setSubject(const std::string&); |
| .NET | public string Subject { get; set; } |
| Property: Options | |
| C++ | const qpid::types::Variant::Map& getOptions() const; |
| C++ | qpid::types::Variant::Map& getOptions(); |
| C++ | void setOptions(const qpid::types::Variant::Map&); |
| .NET | public Dictionary<string, object> Options { get; set; } |
| Property: Type | |
| C++ | std::string getType() const; |
| C++ | void setType(const std::string&); |
| .NET | public string Type { get; set; } |
| Miscellaneous | |
| C++ | std::string str() const; |
| .NET | public string ToStr(); |
| Miscellaneous | |
| C++ | operator bool() const; |
| .NET | n/a |
| Miscellaneous | |
| C++ | bool operator !() const; |
| .NET | n/a |
Table 2.10. .NET Binding for the C++ Messaging API Class: Connection
| .NET Binding Class: Connection | |
|---|---|
| Language | Syntax |
| C++ | class Connection : public qpid::messaging::Handle<ConnectionImpl> |
| .NET | public ref class Connection |
| Constructor | |
| C++ | Connection(ConnectionImpl* impl); |
| .NET | n/a |
| Constructor | |
| C++ | Connection(); |
| .NET | n/a |
| Constructor | |
| C++ | Connection(const std::string& url, const qpid::types::Variant::Map& options = qpid::types::Variant::Map()); |
| .NET | public Connection(string url); |
| .NET | public Connection(string url, Dictionary<string, object> options); |
| Constructor | |
| C++ | Connection(const std::string& url, const std::string& options); |
| .NET | public Connection(string url, string options); |
| Copy Constructor | |
| C++ | Connection(const Connection&); |
| .NET | public Connection(Connection connection); |
| Destructor | |
| C++ | ~Connection(); |
| .NET | ~Connection(); |
| Finalizer | |
| C++ | n/a |
| .NET | !Connection(); |
| Copy assignment operator | |
| C++ | Connection& operator=(const Connection&); |
| .NET | public Connection op_Assign(Connection rhs); |
| Method: SetOption | |
| C++ | void setOption(const std::string& name, const qpid::types::Variant& value); |
| .NET | public void SetOption(string name, object value); |
| Method: open | |
| C++ | void open(); |
| .NET | public void Open(); |
| Property: isOpen | |
| C++ | bool isOpen(); |
| .NET | public bool IsOpen { get; } |
| Method: close | |
| C++ | void close(); |
| .NET | public void Close(); |
| Method: createTransactionalSession | |
| C++ | Session createTransactionalSession(const std::string& name = std::string()); |
| .NET | public Session CreateTransactionalSession(); |
| .NET | public Session CreateTransactionalSession(string name); |
| Method: createSession | |
| C++ | Session createSession(const std::string& name = std::string()); |
| .NET | public Session CreateSession(); |
| .NET | public Session CreateSession(string name); |
| Method: getSession | |
| C++ | Session getSession(const std::string& name) const; |
| .NET | public Session GetSession(string name); |
| Property: AuthenticatedUsername | |
| C++ | std::string getAuthenticatedUsername(); |
| .NET | public string GetAuthenticatedUsername(); |
Table 2.11. .NET Binding for the C++ Messaging API Class: Duration
| .NET Binding Class: Duration | |
|---|---|
| Language | Syntax |
| C++ | class Duration |
| .NET | public ref class Duration |
| Constructor | |
| C++ | explicit Duration(uint64_t milliseconds); |
| .NET | public Duration(ulong mS); |
| Copy constructor | |
| C++ | n/a |
| .NET | public Duration(Duration rhs); |
| Destructor | |
| C++ | default |
| .NET | default |
| Finalizer | |
| C++ | n/a |
| .NET | default |
| Property: Milliseconds | |
| C++ | uint64_t getMilliseconds() const; |
| .NET | public ulong Milliseconds { get; } |
| Operator: * | |
| C++ | Duration operator*(const Duration& duration, uint64_t multiplier); |
| .NET | public static Duration operator *(Duration dur, ulong multiplier); |
| .NET | public static Duration Multiply(Duration dur, ulong multiplier); |
| C++ | Duration operator*(uint64_t multiplier, const Duration& duration); |
| .NET | public static Duration operator *(ulong multiplier, Duration dur); |
| .NET | public static Duration Multiply(ulong multiplier, Duration dur); |
| Constants | |
| C++ | static const Duration FOREVER; |
| C++ | static const Duration IMMEDIATE; |
| C++ | static const Duration SECOND; |
| C++ | static const Duration MINUTE; |
| .NET | public sealed class DurationConstants |
| .NET | public static Duration FORVER; |
| .NET | public static Duration IMMEDIATE; |
| .NET | public static Duration MINUTE; |
| .NET | public static Duration SECOND; |
Table 2.12. .NET Binding for the C++ Messaging API Class: FailoverUpdates
| .NET Binding Class: FailoverUpdates | |
|---|---|
| Language | Syntax |
| C++ | class FailoverUpdates |
| .NET | public ref class FailoverUpdates |
| Constructor | |
| C++ | FailoverUpdates(Connection& connection); |
| .NET | public FailoverUpdates(Connection connection); |
| Destructor | |
| C++ | ~FailoverUpdates(); |
| .NET | ~FailoverUpdates(); |
| Finalizer | |
| C++ | n/a |
| .NET | !FailoverUpdates(); |
Table 2.13. .NET Binding for the C++ Messaging API Class: Message
| .NET Binding Class: Message | |
|---|---|
| Language | Syntax |
| C++ | class Message |
| .NET | public ref class Message |
| Constructor | |
| C++ | Message(const std::string& bytes = std::string()); |
| .NET | Message(); |
| .NET | Message(System::String ^ theStr); |
| .NET | Message(System::Object ^ theValue); |
| .NET | Message(array<System::Byte> ^ bytes); |
| Constructor | |
| C++ | Message(const char*, size_t); |
| .NET | public Message(byte[] bytes, int offset, int size); |
| Copy constructor | |
| C++ | Message(const Message&); |
| .NET | public Message(Message message); |
| Copy assignment operator | |
| C++ | Message& operator=(const Message&); |
| .NET | public Message op_Assign(Message rhs); |
| Destructor | |
| C++ | ~Message(); |
| .NET | ~Message(); |
| Finalizer | |
| C++ | n/a |
| .NET | !Message() |
| Property: ReplyTo | |
| C++ | void setReplyTo(const Address&); |
| C++ | const Address& getReplyTo() const; |
| .NET | public Address ReplyTo { get; set; } |
| Property: Subject | |
| C++ | void setSubject(const std::string&); |
| C++ | const std::string& getSubject() const; |
| .NET | public string Subject { get; set; } |
| Property: ContentType | |
| C++ | void setContentType(const std::string&); |
| C++ | const std::string& getContentType() const; |
| .NET | public string ContentType { get; set; } |
| Property: MessageId | |
| C++ | void setMessageId(const std::string&); |
| C++ | const std::string& getMessageId() const; |
| .NET | public string MessageId { get; set; } |
| Property: UserId | |
| C++ | void setUserId(const std::string&); |
| C++ | const std::string& getUserId() const; |
| .NET | public string UserId { get; set; } |
| Property: CorrelationId | |
| C++ | void setCorrelationId(const std::string&); |
| C++ | const std::string& getCorrelationId() const; |
| .NET | public string CorrelationId { get; set; } |
| Property: Priority | |
| C++ | void setPriority(uint8_t); |
| C++ | uint8_t getPriority() const; |
| .NET | public byte Priority { get; set; } |
| Property: Ttl | |
| C++ | void setTtl(Duration ttl); |
| C++ | Duration getTtl() const; |
| .NET | public Duration Ttl { get; set; } |
| Property: Durable | |
| C++ | void setDurable(bool durable); |
| C++ | bool getDurable() const; |
| .NET | public bool Durable { get; set; } |
| Property: Redelivered | |
| C++ | bool getRedelivered() const; |
| C++ | void setRedelivered(bool); |
| .NET | public bool Redelivered { get; set; } |
| Method: SetProperty | |
| C++ | void setProperty(const std::string&, const qpid::types::Variant&); |
| .NET | public void SetProperty(string name, object value); |
| Property: Properties | |
| C++ | const qpid::types::Variant::Map& getProperties() const; |
| C++ | qpid::types::Variant::Map& getProperties(); |
| .NET | public Dictionary<string, object> Properties { get; set; } |
| Method: SetContent | |
| C++ | void setContent(const std::string&); |
| C++ | void setContent(const char* chars, size_t count); |
| .NET | public void SetContent(byte[] bytes); |
| .NET | public void SetContent(string content); |
| .NET | public void SetContent(byte[] bytes, int offset, int size); |
| Method: GetContent | |
| C++ | std::string getContent() const; |
| .NET | public string GetContent(); |
| .NET | public void GetContent(byte[] arr); |
| .NET | public void GetContent(Collection<object> __p1); |
| .NET | public void GetContent(Dictionary<string, object> dict); |
| Method: GetContentPtr | |
| C++ | const char* getContentPtr() const; |
| .NET | n/a |
| Property: ContentSize | |
| C++ | size_t getContentSize() const; |
| .NET | public ulong ContentSize { get; } |
| Struct: EncodingException | |
| C++ | struct EncodingException : qpid::types::Exception |
| .NET | n/a |
| Method: decode | |
| C++ | void decode(const Message& message, qpid::types::Variant::Map& map, const std::string& encoding = std::string()); |
| C++ | void decode(const Message& message, qpid::types::Variant::List& list, const std::string& encoding = std::string()); |
| .NET | n/a |
| Method: encode | |
| C++ | void encode(const qpid::types::Variant::Map& map, Message& message, const std::string& encoding = std::string()); |
| C++ | void encode(const qpid::types::Variant::List& list, Message& message, const std::string& encoding = std::string()); |
| .NET | n/a |
| Method: AsString | |
| C++ | n/a |
| .NET | public string AsString(object obj); |
| .NET | public string ListAsString(Collection<object> list); |
| .NET | public string MapAsString(Dictionary<string, object> dict); |
Table 2.14. .NET Binding for the C++ Messaging API Class: Receiver
| .NET Binding Class: Receiver | |
|---|---|
| Language | Syntax |
| C++ | class Receiver |
| .NET | public ref class Receiver |
| Constructor | |
| .NET | Constructed object is returned by Session.CreateReceiver |
| Copy constructor | |
| C++ | Receiver(const Receiver&); |
| .NET | public Receiver(Receiver receiver); |
| Destructor | |
| C++ | ~Receiver(); |
| .NET | ~Receiver(); |
| Finalizer | |
| C++ | n/a |
| .NET | !Receiver() |
| Copy assignment operator | |
| C++ | Receiver& operator=(const Receiver&); |
| .NET | public Receiver op_Assign(Receiver rhs); |
| Method: Get | |
| C++ | bool get(Message& message, Duration timeout=Duration::FOREVER); |
| .NET | public bool Get(Message mmsgp); |
| .NET | public bool Get(Message mmsgp, Duration durationp); |
| Method: Get | |
| C++ | Message get(Duration timeout=Duration::FOREVER); |
| .NET | public Message Get(); |
| .NET | public Message Get(Duration durationp); |
| Method: Fetch | |
| C++ | bool fetch(Message& message, Duration timeout=Duration::FOREVER); |
| .NET | public bool Fetch(Message mmsgp); |
| .NET | public bool Fetch(Message mmsgp, Duration duration); |
| Method: Fetch | |
| C++ | Message fetch(Duration timeout=Duration::FOREVER); |
| .NET | public Message Fetch(); |
| .NET | public Message Fetch(Duration durationp); |
| Property: Capacity | |
| C++ | void setCapacity(uint32_t); |
| C++ | uint32_t getCapacity(); |
| .NET | public uint Capacity { get; set; } |
| Property: Available | |
| C++ | uint32_t getAvailable(); |
| .NET | public uint Available { get; } |
| Property: Unsettled | |
| C++ | uint32_t getUnsettled(); |
| .NET | public uint Unsettled { get; } |
| Method: Close | |
| C++ | void close(); |
| .NET | public void Close(); |
| Property: IsClosed | |
| C++ | bool isClosed() const; |
| .NET | public bool IsClosed { get; } |
| Property: Name | |
| C++ | const std::string& getName() const; |
| .NET | public string Name { get; } |
| Property: Session | |
| C++ | Session getSession() const; |
| .NET | public Session Session { get; } |
Table 2.15. .NET Binding for the C++ Messaging API Class: Sender
| .NET Binding Class: Sender | |
|---|---|
| Language | Syntax |
| C++ | class Sender |
| .NET | public ref class Sender |
| Constructor | |
| .NET | Constructed object is returned by Session.CreateSender |
| Copy constructor | |
| C++ | Sender(const Sender&); |
| .NET | public Sender(Sender sender); |
| Destructor | |
| C++ | ~Sender(); |
| .NET | ~Sender(); |
| Finalizer | |
| C++ | n/a |
| .NET | !Sender() |
| Copy assignment operator | |
| C++ | Sender& operator=(const Sender&); |
| .NET | public Sender op_Assign(Sender rhs); |
| Method: Send | |
| C++ | void send(const Message& message, bool sync=false); |
| .NET | public void Send(Message mmsgp); |
| .NET | public void Send(Message mmsgp, bool sync); |
| Method: Close | |
| C++ | void close(); |
| .NET | public void Close(); |
| Property: Capacity | |
| C++ | void setCapacity(uint32_t); |
| C++ | uint32_t getCapacity(); |
| .NET | public uint Capacity { get; set; } |
| Property: Available | |
| C++ | uint32_t getAvailable(); |
| .NET | public uint Available { get; } |
| Property: Unsettled | |
| C++ | uint32_t getUnsettled(); |
| .NET | public uint Unsettled { get; } |
| Property: Name | |
| C++ | const std::string& getName() const; |
| .NET | public string Name { get; } |
| Property: Session | |
| C++ | Session getSession() const; |
| .NET | public Session Session { get; } |
Table 2.16. .NET Binding for the C++ Messaging API Class: Session
| .NET Binding Class: Session | |
|---|---|
| Language | Syntax |
| C++ | class Session |
| .NET | public ref class Session |
| Constructor | |
| .NET | Constructed object is returned by Connection.CreateSession |
| Copy constructor | |
| C++ | Session(const Session&); |
| .NET | public Session(Session session); |
| Destructor | |
| C++ | ~Session(); |
| .NET | ~Session(); |
| Finalizer | |
| C++ | n/a |
| .NET | !Session() |
| Copy assignment operator | |
| C++ | Session& operator=(const Session&); |
| .NET | public Session op_Assign(Session rhs); |
| Method: Close | |
| C++ | void close(); |
| .NET | public void Close(); |
| Method: Commit | |
| C++ | void commit(); |
| .NET | public void Commit(); |
| Method: Rollback | |
| C++ | void rollback(); |
| .NET | public void Rollback(); |
| Method: Acknowledge | |
| C++ | void acknowledge(bool sync=false); |
| C++ | void acknowledge(Message&, bool sync=false); |
| .NET | public void Acknowledge(); |
| .NET | public void Acknowledge(bool sync); |
| .NET | public void Acknowledge(Message __p1); |
| .NET | public void Acknowledge(Message __p1, bool __p2); |
| Method: Reject | |
| C++ | void reject(Message&); |
| .NET | public void Reject(Message __p1); |
| Method: Release | |
| C++ | void release(Message&); |
| .NET | public void Release(Message __p1); |
| Method: Sync | |
| C++ | void sync(bool block=true); |
| .NET | public void Sync(); |
| .NET | public void Sync(bool block); |
| Property: Receivable | |
| C++ | uint32_t getReceivable(); |
| .NET | public uint Receivable { get; } |
| Property: UnsettledAcks | |
| C++ | uint32_t getUnsettledAcks(); |
| .NET | public uint UnsetledAcks { get; } |
| Method: NextReceiver | |
| C++ | bool nextReceiver(Receiver&, Duration timeout=Duration::FOREVER); |
| .NET | public bool NextReceiver(Receiver rcvr); |
| .NET | public bool NextReceiver(Receiver rcvr, Duration timeout); |
| Method: NextReceiver | |
| C++ | Receiver nextReceiver(Duration timeout=Duration::FOREVER); |
| .NET | public Receiver NextReceiver(); |
| .NET | public Receiver NextReceiver(Duration timeout); |
| Method: CreateSender | |
| C++ | Sender createSender(const Address& address); |
| .NET | public Sender CreateSender(Address address); |
| Method: CreateSender | |
| C++ | Sender createSender(const std::string& address); |
| .NET | public Sender CreateSender(string address); |
| Method: CreateReceiver | |
| C++ | Receiver createReceiver(const Address& address); |
| .NET | public Receiver CreateReceiver(Address address); |
| Method: CreateReceiver | |
| C++ | Receiver createReceiver(const std::string& address); |
| .NET | public Receiver CreateReceiver(string address); |
| Method: GetSender | |
| C++ | Sender getSender(const std::string& name) const; |
| .NET | public Sender GetSender(string name); |
| Method: GetReceiver | |
| C++ | Receiver getReceiver(const std::string& name) const; |
| .NET | public Receiver GetReceiver(string name); |
| Property: Connection | |
| C++ | Connection getConnection() const; |
| .NET | public Connection Connection { get; } |
| Property: HasError | |
| C++ | bool hasError(); |
| .NET | public bool HasError { get; } |
| Method: CheckError | |
| C++ | void checkError(); |
| .NET | public void CheckError(); |
The SessionReceiver class provides a convenient callback mechanism for Messages received by all Receivers on a given Session.
using Org.Apache.Qpid.Messaging;
using System;
namespace Org.Apache.Qpid.Messaging.SessionReceiver
{
public interface ISessionReceiver
{
void SessionReceiver(Receiver receiver, Message message);
}
public class CallbackServer
{
public CallbackServer(Session session, ISessionReceiver callback);
public void Close();
}
}
To use this class a client program includes references to both Org.Apache.Qpid.Messaging and Org.Apache.Qpid.Messaging.SessionReceiver. The calling program creates a function that implements the ISessionReceiver interface. This function will be called whenever message is received by the session. The callback process is started by creating a CallbackServer and will continue to run until the client program calls the CallbackServer.Close function.
A complete operating example of using the SessionReceiver callback is contained in cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver.
Apache Qpid, Messaging built on AMQP; Copyright © 2015 The Apache Software Foundation; Licensed under the Apache License, Version 2.0; Apache Qpid, Qpid, Qpid Proton, Proton, Apache, the Apache feather logo, and the Apache Qpid project logo are trademarks of The Apache Software Foundation; All other marks mentioned may be trademarks or registered trademarks of their respective owners