Code Monkey home page Code Monkey logo

solace-samples-javascript's Introduction

Getting Started Examples

Solace JavaScript API

The "Getting Started" tutorials will get you up to speed and sending messages with Solace technology as quickly as possible. There are three ways you can get started:

  • Follow these instructions to quickly spin up a cloud-based Solace messaging service for your applications.
  • Follow these instructions to start the Solace PubSub+ software event broker in leading Clouds, Container Platforms or Hypervisors. The tutorials outline where to download and how to install the Solace PubSub+ software event broker.
  • If your company has Solace PubSub+ Event Brokers deployed, contact your middleware team to obtain the host name or IP address of a Solace PubSub+ Event Broker to test against, a username and password to access it, and a VPN in which you can produce and consume messages.

Contents

This repository contains:

  • Code and matching tutorial walk throughs for five different basic Solace messaging patterns. For a nice introduction to the Solace API and associated tutorials, check out the tutorials home page.

    See the individual tutorials for details:

    • Publish/Subscribe: Learn how to set up pub/sub messaging on a Solace PubSub+ software event broker.
    • Persistence: Learn how to set up persistence for guaranteed delivery.
    • Request/Reply: Learn how to set up request/reply messaging.
    • Confirmed Delivery: Learn how to confirm that your messages are received by a Solace PubSub+ Event Broker.
    • Topic to Queue Mapping: Learn how to map existing topics to Solace queues.
  • The following additional samples showing how to make use of advanced features of the Solace PubSub+ Event Broker.

    • Secure Session: Learn how to use secure connection to the server and server and client certificate authentication.
    • Active Consumer Indication: Learn how multiple consumers can bind to an exclusive queue, but only one client at a time can actively receive messages.
    • Durable Topic Endpoint Consumer: Learn how to consume messages from a Durable Topic Endpoint (DTE).
    • Event Monitor: Learn how to monitor message router generated events.
    • GuaranteedRequestor/Replier: Learn how to set up guaranteed request/reply messaging.
    • NoLocal Pub-Sub: Learn how to prevent messages published on a session or consumer received on that same session or consumer.
    • Message Replay: Learn how to initiate and process the replay of previously published messages, as well as deal with an externally initiated replay.

Checking out

To check out the project, clone this GitHub repository:

git clone https://github.com/SolaceSamples/solace-samples-javascript
cd solace-samples-javascript

Note: the code in the master branch of this repository depends on Solace JavaScript API version 10 or later. If you want to work with an older version clone the branch that corresponds your version.

Download the Solace JavaScript API

These samples depend on version 10 or later of the Solace JavaScript API library.

The Solace JavaScript API (Browser) library can be downloaded here. The instructions in this tutorial assume you have downloaded the Web Messaging API for JavaScript library and unpacked it to a known location. The samples assume a lib directory containing the API libraries will be installed in the current solace-samples-javascript directory at the root of the cloned repo:

cp -R <path_to_unzipped_API_distribution_package>/lib .

Running the Samples

The samples are found in the src/basic-samples and src/features directories. Each sample is in it's own subdirectory. Within each sample subdirectory there is an html file which you load to launch the sample.

For example the TopicPublisher is found here: src/basic-samples/TopicPublisher

And it is launched by running the following in your browser:

TopicPublisher.html

See the tutorials for more details.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

See the list of contributors who participated in this project.

License

This project is licensed under the Apache License, Version 2.0. - See the LICENSE file for details.

Resources

For more information try these resources:

solace-samples-javascript's People

Contributors

aaron-613 avatar alyrasmy avatar arshrai17 avatar bczoma avatar brandonto avatar evenjessie avatar gszol avatar gvensan avatar macstewart avatar mdspielman avatar mrc0113 avatar shalin1738 avatar solace-dmckay avatar tamimigithub avatar thrillstone avatar tomfairbairnsolace avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

solace-samples-javascript's Issues

If solace queue is restarted, the consumer not reconnect

After the consumer is connected to a solace queue, and the solace queue server is restarted, the consumer will disconnected to this queue forever.

This is the consumer would output.

=== An error happened, the message consumer is down ===

And you can see there will have no consumer though the queue monitor.

This was happend in PRODUCT ENVIRONMENT, and when I restart the progress which is consumming the msg, it reconnected again.

Typo in BasicRequestor.html comment

BasicRequestor.html has a typo in the comment:
Solace eb Messaging API for JavaScript

Should say:
Solace Web Messaging API for JavaScript

Web UI is not given as an option to create a queue

In the persistence with queues sample, there is a prerequisite section that mentions you must create a queue and that you can do so using SolAdmin or SEMP. It fails to mention that you could also do so using the Web UI. The Web UI should be one of the options.

It would also make sense if the section linked to the instructions to create a queue, although I'm not sure if we have such a sample online.

Handle connection establishment in-progress: enhance all buttons in all samples

A connection can take a long time to fail because of the defaults:

Class solace.SessionProperties 
Number | connectRetries        = 20
Number | connectRetriesPerHost = 0
Number | connectTimeoutInMsecs = 8000

Example:

[10:46:50] Connecting to Solace message router using url: wss://random-service.messaging.solace.cloud:random-port
[10:46:50] Client username: solace-cloud-client
[10:46:50] Solace message router VPN name: msgvpn-random
[10:48:18] Connection failed to the message router: Unauthorized - check correct parameter values and connectivity!

Until the following line appears, we shouldn't click on anything else:

[10:41:08] === Successfully connected and ready to publish messages. ===

Otherwise, we get confusing messages, especially for first-time users. The following examples are for TopicPublisher.html.

Example 1: Clicking the "connect" button again tells you you're already connected when you're actually NOT:

[10:40:51] Connecting to Solace message router using url: wss://random-service.messaging.solace.cloud:random-port
[10:40:51] Client username: solace-cloud-client
[10:40:51] Solace message router VPN name: msgvpn-random
[10:40:56] Already connected and ready to publish messages.

Example 2: Clicking the "publish" button before actually connected gives "state WaitingForInterconnectTimeout" which can be confusing:

[11:04:43] Connecting to Solace message router using url: wss://random-service.messaging.solace.cloud:random-port
[11:04:43] Client username: solace-cloud-client
[11:04:43] Solace message router VPN name: msgvpn-random
[11:04:45] Publishing message "Sample Message" to topic "tutorial/topic"...
[11:04:45] OperationError: Cannot perform operation SEND while in state WaitingForInterconnectTimeout

Example 3: Clicking "Connect" again after a failed connection actually requires the user to click "Disconnect", otherwise you'll get this:

[10:46:50] Connecting to Solace message router using url: wss://random-service.messaging.solace.cloud:random-port
[10:46:50] Client username: solace-cloud-client
[10:46:50] Solace message router VPN name: msgvpn-random
[10:48:18] Connection failed to the message router: Unauthorized - check correct parameter values and connectivity!
[11:03:36] Already connected and ready to publish messages.

Of course, the defaults can be adjusted for responsiveness but I think a better way is to have the buttons be greyed out appropriately in the samples. This can also help illustrate event handling in the API.

Index page for JS Samples

Can we have an index page for the samples which has links to the various samples. Currently, all the samples are within their own /src folder. This is to harmonize the differences between the samples on the download page and in Solace Labs.

Similar to the index page for the JavaScript Samples downloaded from dev.solace.com:
screen shot 2017-11-02 at 2 37 31 pm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.