Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Using RabbitMQ / AMQP with Xamarin.Forms

$
0
0

Hello,

in one of our projects we want to exchange messages between mobile devices and servers using RabbitMQ.
RabbitMQ provides a .net client library, but there is no PCL or compatible nuget packages available for it.

We tried building our own PCL from the .net client sources, but the client is using System.Net.Security and System.Net.Sockets and those are not available in the .net portable subset.

But there is another simple way to use the RabbitMQ Client in Xamarin.Forms by using a Shared Project.

You will need Visual Studio for this.

Here are the necessary steps:

  1. get the sources for the RabbitMQ .Net Client from their website at http://www.rabbitmq.com/download.html or github at https://github.com/rabbitmq/rabbitmq-dotnet-client

  2. find the file named "Local.props.examples" and rename it to "Local.props"

  3. Open the solution in Visual Studio

  4. Build the RabbitMQ.Client. This will generate a new source file in /gensrc/RabbitMQ.Client named autogenerated-api-0-9-1.cs

  5. Create your own Shared Project to use in your Xamarin.Forms projects

  6. Include all source files from /projects/client/RabbitMQ.Client/src in your Shared Project

  7. Include the autogenerated sourcefile from /gensrc/RabbitMQ.Client in your Shared Project

  8. Add a reference to your Shared Project to the platform specific projects.

Now to use the RabbitMQ.Client you will need to use the Xamarin.Forms DependencyService ( see https://developer.xamarin.com/guides/cross-platform/xamarin-forms/dependency-service/ ) and implement classes in the platform specific projects to connect to the RabbitMQ Servers to exchange messages.

I hope this helps other developers who want to use messaging services.

Regards,
Dirk


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>