Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ServiceBus] Rollup for browser #2555

Merged
merged 6 commits into from
Apr 30, 2019
Merged

[ServiceBus] Rollup for browser #2555

merged 6 commits into from
Apr 30, 2019

Conversation

bterlson
Copy link
Member

@bterlson bterlson commented Apr 29, 2019

This PR enables browser builds by copying the approach taken for amqp-common.

The global name is Azure.Messaging.ServiceBus.

  • See about removing package.json browser field for buffer since we do not have a direct depenency on buffer
  • Minification per template
  • Testing in browser (/cc @ramya0820)
  • Ignore circular reference errors.

@@ -17,6 +17,9 @@
},
"main": "./dist/index.js",
"module": "dist-esm/src/index.js",
"browser": {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May not need this, will try removing.

@bterlson
Copy link
Member Author

Latest commits work with all the non-AAD-using samples I've tested with. E.g. you can build this branch and create the following html file under samples/browser:

<script src="../../browser/service-bus.js"></script>
<script>
  const SBC = Azure.Messaging.ServiceBus.ServiceBusClient;
  const connectionString = "";
  const queueName = "";

  const listOfScientists = [
    { name: "Einstein", firstName: "Albert" },
    { name: "Heisenberg", firstName: "Werner" },
    { name: "Curie", firstName: "Marie" },
    { name: "Hawking", firstName: "Steven" },
    { name: "Newton", firstName: "Isaac" },
    { name: "Bohr", firstName: "Niels" },
    { name: "Faraday", firstName: "Michael" },
    { name: "Galilei", firstName: "Galileo" },
    { name: "Kepler", firstName: "Johannes" },
    { name: "Kopernikus", firstName: "Nikolaus" }
  ];

  async function main() {
    const ns = SBC.createFromConnectionString(connectionString);

    // If sending to a Topic, use `createTopicClient` instead of `createQueueClient`
    const client = ns.createQueueClient(queueName);
    const sender = client.createSender();

    try {
      for (let index = 0; index < listOfScientists.length; index++) {
        const scientist = listOfScientists[index];
        const message = {
          body: `${scientist.firstName} ${scientist.name}`,
          label: "Scientist"
        };

        console.log(`Sending message: ${message.body} - ${message.label}`);
        await sender.send(message);
      }

      await client.close();
    } finally {
      await ns.close();
    }
  }

  main().catch((err) => {
    console.log("Error occurred: ", err);
  });
</script>

Copy link
Member

@ramya0820 ramya0820 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on local that this works.

@bterlson
Copy link
Member Author

@ramya0820 this should be ready for you to build on!

Copy link
Member

@ramya0820 ramya0820 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can fix conflicts and merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants