0

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?

Michael
  • 4,010
  • 4
  • 28
  • 49

1 Answers1

2

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.

Mike Hadlow
  • 9,427
  • 4
  • 45
  • 37
  • Very excited to see this is an option (I was considering wrapping EasyNetQ in EdgeJS). The type, btw (for those curious) ended-up being 'RabbitMon.BusManifestHolla:RabbitMon'... – Michael May 08 '14 at 17:07
  • And is there a trick to the Subscribe/consume side of it? I briefly had it working and now I can't reproduce it. I'm happy to turn this into a question and provide more detail. In fact, I just did http://stackoverflow.com/questions/23554784/rabbitmq-easynetq-with-nodejs-amqplib-subscribing – Michael May 09 '14 at 00:19