Giter Site home page Giter Site logo

Comments (11)

ahmedanwar100 avatar ahmedanwar100 commented on June 10, 2024

i think we have to serialize the object like this
_rabbitTemplate.ConvertAndSend(RECEIVE_AND_CONVERT_QUEUE, JsonConvert.SerializeObject(customMsg));

and then make Listner like this

[RabbitListener(RECEIVE_AND_CONVERT_QUEUE)] public void ListenForAMessage(string msg) { var x=JsonConvert.DeserializeObject<CustomQueue>(msg); _logger.LogInformation($"Received the message '{msg}' from the queue."); }

from samples.

dtillman avatar dtillman commented on June 10, 2024

@bradLucifer : Yes, the problem you are seeing is that by default we use BinaryFormatter to serialize objects. As a result on the receiving side the deserialization attempts to deserialize the payload and expects to find the type available so that it can create an instance of it. The type if finds is not the same one that is being sent because the assemblies they are in are different. So you have a couple options:

  1. Put the common type CustomQueue in a separate project and reference it the other two rabbitmq projects. That way the type will be common and in a shared assembly accessible by both.
  2. Switch to using Json for the serialization protocol.
    Dave

from samples.

ahmedanwar100 avatar ahmedanwar100 commented on June 10, 2024

from samples.

dtillman avatar dtillman commented on June 10, 2024

@bradLucifer : Which do you prefer .. 1. Common project/.NET Serialization 2. JSON?

from samples.

ahmedanwar100 avatar ahmedanwar100 commented on June 10, 2024

from samples.

dtillman avatar dtillman commented on June 10, 2024

@bradLucifer : https://github.com/SteeltoeOSS/Samples/tree/main/Messaging/src/RabbitMQWeb2

I think this should help... See the Startup.cs file in each project for how to enable/disable the .NET serialization vs JSON.

from samples.

ahmedanwar100 avatar ahmedanwar100 commented on June 10, 2024

from samples.

dtillman avatar dtillman commented on June 10, 2024

In the startup.cs files for both projects, see the following comments.:

// Add Steeltoe Rabbit services, use default .NET serialization
//services.AddRabbitServices();

// Add Steeltoe Rabbit services, use JSON serialization
services.AddRabbitServices(true);

from samples.

ahmedanwar100 avatar ahmedanwar100 commented on June 10, 2024

from samples.

ahmedanwar100 avatar ahmedanwar100 commented on June 10, 2024

from samples.

ahmedanwar100 avatar ahmedanwar100 commented on June 10, 2024

from samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.