Question

I'm trying to understand what's reasonable for integrating these technologies. How would I go about integrating NodeJS (currently using amqplib, but that could be changed) across RabbitMQ to EasyNetQ?

I have it sort of working, except EasyNetQ is expecting an object (I think) and Node/amqplib can only send strings.

C# code:

Bus.Subscribe<BusManifestHolla>(HollaID,
    msg => {
        Console.WriteLine("Received Manifest Holla ID {0}", msg.ManifestID.ToString());
        Console.WriteLine("Responding with Manifest Yo ID {0}", YoID_1);
        Bus.Publish(new BusManifestYo { ManifestID = msg.ManifestID, ServiceName = YoID_1 });
    }
);

NodeJS code:

var b = new Buffer(JSON.stringify(new dto.BusManifestHolla(uuid.v4())));
ch.publish(Play.exchangeName, '#', b);

The result:

DEBUG: HandleBasicDeliver on consumer: a60b7760-e22f-4685-9f65-039bef19f58c, deliveryTag: 1
DEBUG: Recieved
    RoutingKey: '#'
    CorrelationId: ''
    ConsumerTag: 'a60b7760-e22f-4685-9f65-039bef19f58c'
    DeliveryTag: 1
    Redelivered: False
ERROR: Exception thrown by subscription callback.
    Exchange:    'RabbitMon.BusManifestHolla:RabbitMon'
    Routing Key: '#'
    Redelivered: 'False'
Message:
{"Guid":"a6cf174d-9b77-4558-bbda-efe9d8451dff"}
BasicProperties:
ContentType=NULL, ContentEncoding=NULL, Headers=[], DeliveryMode=0, Priority=0,    CorrelationId=NULL, ReplyTo=NULL, Expiration=NULL, MessageId=NULL, Timestamp=0, Type=NULL, UserId=NULL, AppId=NULL, ClusterId=
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at EasyNetQ.TypeNameSerializer.DeSerialize(String typeName)
   at EasyNetQ.RabbitAdvancedBus.<>c__DisplayClass16.<Consume>b__15(Byte[] body, MessageProperties properties, MessageReceivedInfo messageRecievedInfo)
   at EasyNetQ.Consumer.HandlerRunner.InvokeUserMessageHandler(ConsumerExecutionContext context)

Is there not a way to send an object across the bus? How do you integrate these two?

Was it helpful?

Solution

It's failing on the TypeNameSerializer.DeSerialize call. In your node code you'll need to populate BasicProperties.Type with the type that EasyNetQ should expect at the other end. This needs to be a fully qualified name including the assembly name. Just look at the name that EasyNetQ has given to your BusManifestHolla queue minus the HollaID value (and underscore).

Admittedly that error message isn't very helpful. It probably could be improved.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top