piotr-rojek / devopsifyme-sbemulator

MIT License
66 stars 12 forks source link

SessionId not supported #15

Closed WayneDT closed 1 year ago

WayneDT commented 1 year ago

In the code there does not seem to be any support for session Id.

Looking at the RabbitMqMapper.cs from line 99.

I am assuming this is because RabbitMQ doesn't have an exact parallel.

Proposal

Is it possible to add a mapping that will pull the session id from the Azure Servicebus message and set it as a Property on the RabbitMq message

image

then when reading the message you can look for that property and set the session id again

Our messages look like.

async function sendMessage(queueName, message, correlationId, sessionId, srcId) {
  const sender = sbClient.createSender(queueName);

  const message = {
    body: Buffer.from(message, 'utf-8'),
    sessionId: sessionId,
    applicationProperties: {
      sourceId: srcId
     },
     correlationId: correlationId, 
  };
  await sender.sendMessages(message);

  await sender.close();
}
piotr-rojek commented 1 year ago

Hey @WayneDT

This is already handled in the way that you proposed :) The only difference is that session-id is being sent in AMQP as a property called group-id, visible in rabbit as x-sb-group-id. Group ID is also sent back to the receiver.

But as you noted, this is not a proper implementation of sessions, as it barely passes values back and forth.

/Piotr

WayneDT commented 1 year ago

I am having trouble actually receiving messages with sessions. The code I am using is from the Microsoft SDK samples (https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/servicebus/service-bus/samples/v7/javascript/session.js)

It fails when const receiver = await sbClient.acceptSession(queueName, sessionId);

The error I get is TypeError: Cannot read properties of undefined (reading '4')

if you want to run this follow the instructions i put on issue #9 and then just paste the code from the same above into the index.js

piotr-rojek commented 1 year ago

This is expected, as both transaction and session support is not implemented ATM (see https://github.com/piotr-rojek/devopsifyme-sbemulator#not-supported-features). I cannot make any promises to the timeline, but some kind of session support will be implemented in near future.

/Piotr