Branch | Status |
---|---|
master | |
dev |
The Azure Functions RabbitMQ Binding extensions allows you to send and receive messages using the RabbitMQ API but by writing Functions code. The RabbitMQ output binding sends messages to a specific queue. The RabbitMQ trigger fires when it receives a message from a specific queue.
RabbitMQ Documentation for the .NET Client
To get started with developing with this extension, make sure you first set up a RabbitMQ endpoint. Then you can go ahead and begin developing your functions in C#, JavaScript, or Python. If you would like a way to handle messages that error, check out our guide to configuring a dead letter exchange.
See the repository wiki for more detailed samples of bindings to different types.
public static void RabbitMQTrigger_RabbitMQOutput(
[RabbitMQTrigger("queue", ConnectionStringSetting = "RabbitMQConnection")] string inputMessage,
[RabbitMQ(
ConnectionStringSetting = "RabbitMQConnection",
QueueName = "hello")] out string outputMessage,
ILogger logger)
{
outputMessage = inputMessage;
logger.LogInformation($"RabittMQ output binding function sent message: {outputMessage}");
}
The above sample waits on a trigger from the queue named "queue" connected to the connection string value of key "RabbitMQConnection." The output binding takes the messages from the trigger queue and outputs them to queue "hello" connected to the connection configured by the key "RabibtMQConnection". When running locally, add the connection string setting to local.settings.json file. When running in Azure, add this setting as Application Setting for your app.
public static void RabbitMQTrigger_HeadersExchange(
[RabbitMQTrigger("headersExchange", "all", "{\"HeaderKey1\":\"fba410d3-b9bd-40c3-8e6c-d76981cd64af\",\"HeaderKey2\":\"events\"}", ConnectionStringSetting = "RabbitMQConnection")] string inputMessage,
ILogger logger)
{
logger.LogInformation($"RabittMQ header exchange input binding function received message: {intputMessage}");
}
The above sample waits on a trigger from an exchange named "headersExchange" connected to the connection string value of key "RabbitMQConnection.". This uses an x-match binding of "all" for the arguments "HeaderKey1" and "HeaderKey2", which for this example means that only events with the matching header keys will be received. If an x-match binding is not specified as per the RabbitMQ spec then all events will be received.
Property Name | Description | Example |
---|---|---|
ConnectionStringSetting | The connection string for the RabbitMQ queue | amqp://user:password@url:port |
HostName | (optional if using ConnectionStringSetting) Hostname of the queue | 10.26.45.210 |
UserName | (optional if using ConnectionStringSetting) User name to access queue | user |
Password | (optional if using ConnectionStringSetting) Password to access queue | password1 |
Property Name | Description | Example |
---|---|---|
QueueName | The name of the source or destination queue | myQueue |
DeadLetterExchangeName | The name of the deadletter exchange for poison queue patterns | dtxExchange |
Property Name | Description | Example |
---|---|---|
ExchangeName | The name of the source or destination queue | myExchange |
XMatch | Many any or all of the headers specified in the arguments | any |
Arguments | The headers to filter on if specified | "{\"HeaderKey\":\"HeaderValue\"}" |
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.