Skip to content

Commit

Permalink
fixing issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandoescolar committed Oct 16, 2024
1 parent 591d52b commit 7060cfc
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@ test/run:
./k6 run examples/topic_batch_string_message.js
./k6 run examples/topic_single_message.js
./k6 run examples/topic_single_string_message.js
./k6 run examples/bug_application_properties.js

local/compose/up:
docker compose up rabbit -d
docker compose up sbemulator -d
@export CONNECTION_STRING="Endpoint=sb://sbemulator/;SharedAccessKeyName=all;SharedAccessKey=CLwo3FQ3S39Z4pFOQDefaiUd1dSsli4XOAj3Y9Uh1E=;EnableAmqpLinkRedirect=false"

local/compose/down:
docker compose down

test/run/local: install compile local/compose/up test/run local/compose/down
49 changes: 49 additions & 0 deletions examples/bug_application_properties.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { sleep, check } from 'k6';
import { ServiceBus } from 'k6/x/azservicebus';
import { uuidv4 } from 'https://jslib.k6.io/k6-utils/1.4.0/index.js';

const config = {
connectionString: __ENV.CONNECTION_STRING,
timeout: 30000,
insecureSkipVerify: true, // the docker servicebus emulator uses a self-signed cert
};

const servicebus = new ServiceBus(config);
const sender = servicebus.createSender('test-topic');
const receiver = servicebus.createSubscriptionReceiver('test-topic', 'test-sub1');
const batch_message_count = 2;

export default function () {
const data = [];

for(let i = 0; i < batch_message_count; i++) {
var properties = {
'Type': "MessageType"
};

data.push({
messageID: uuidv4(),
applicationProperties: properties,
contentType: 'application/json',
subject: 'example',
bodyAsString: JSON.stringify({ Title: 'Example'}),
});
}

sender.sendBatchMessages(data);

sleep(1);

const messages = receiver.getMessages(batch_message_count);
console.log(messages);
console.log(`messages: ${messages.length}`)
check(messages, {
'Has the expected size': (m) => m.length === batch_message_count,
});
}

export function teardown() {
receiver.close();
sender.close();
servicebus.close();
}
1 change: 1 addition & 0 deletions sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func (s *Sender) createContext() (context.Context, context.CancelFunc) {
func mapMessageToSeriveBus(message *Message) *azservicebus.Message {
sbMessage := &azservicebus.Message{}
if message.ApplicationProperties != nil {
sbMessage.ApplicationProperties = make(map[string]any)
for k, v := range message.ApplicationProperties {
sbMessage.ApplicationProperties[k] = v
}
Expand Down

0 comments on commit 7060cfc

Please sign in to comment.