简体   繁体   中英

Using RabbitMQ C# and Elixir

I've never use RabbitMQ before and do not know, if it is the right tool for me. So I have some questions.

I have a C#.NET application and on other side I have an elixir application.

I want to exchange the data between them, for example, the elixir would ask for a list of person from C#.NET app and it will return a list(List) of person to elixir.

How I would receive the data in elixir? There is no objects in elixir.

If I would send an object Person from C#.NET to elixir, what I would get in elixir?

There is no objects in elixir.

Just because there are no objects in the sense of an Object Oriented (OO) language like C#, functional language still have constructs for collections of data. In Elixir's case, the big three are records, structs and maps. When you would use each is out of the scope of this answer.

How I would receive the data in elixir?

That depends entirely on the semantics of the application and how you are actually using the data in each application.

As an example, if application X needs to ask application Y for a certain subset of its information (Maybe a list of users between the age of 20-30), you may consider setting up some kind of web accessible endpoint in application Y that can filter this information down and return JSON, which application X can then consume and do whatever it needs to with.

An example of a reason you may want to use RabbitMQ, or any other message queue for that matter, would be if you want to do some sort of processing on an event on a different machine than the one the event originated from.

If I would send an object Person from C#.NET to elixir, what I would get in elixir?

C# cannot speak directly to Elixir.

In addition to Justin's answer you may also want to research Erlang Term Format which is another option for interop between Elixir and other languages. There is one implementation of ETF for C# here but I have no idea of the quality of the library.

Besides Justin's suggestion, you also want to think not in terms of sending an "object" but instead in terms of sending the data in the object instance. Rather than sending Person and then trying to pick out the data on the Elixir side, send pieces of the data from Person in discrete calls--eg Person.FirstName, Person.LastName etc. You can pass data from the specific instance without having to pass the entire object. ETF will help with the communication of the data between C# and Elixir. Even if you stuff data into a RabbitMQ queue, you can place it on the queue as discrete pieces of data rather than an "object".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM