NServicebus JavaScript message handler: Enhancing Communication

I am in the process of developing a JavaScript event subscriber for NServicebus, and I am seeking feedback on my approach as well as any potential pitfalls to watch out for in this design.

My proposed components are as follows:

  1. ASP.NET MVC BusController (ASyncController)

    • Receives subscriptions from JavaScript clients and provides a sessionId for further communication.
    • Async ActionMethod Receive returns a JSON serialized EventMessage.
    • Utilizes a generic message handler to filter and queue events for subscribed clients.
  2. JavaScript client

    • Can subscribe to one or multiple events using the subscribe method on the BusController.
    • Receive events through long-polling of the Receive method on the BusController with the assigned sessionId.

However, there are a couple of concerns:

  1. How to detect when a client disconnects?
    • Considering implementing a timeout system that prompts the client to reconnect with the Receive ActionMethod.
  2. Concerns about the performance of a generic message handler in the buscontroller handling all messages in the system. Has anyone encountered this issue before?

Answer №1

If you're looking for a solution that works seamlessly, consider trying out pServiceBus. Their JavaScript API allows for easy implementation of pub-sub functionalities, similar to what you would do in .net code.

pServiceBus is designed to automatically adapt to different browser capabilities, utilizing Http Streaming/Comet and switching to long polling if necessary.

For a demonstration of the pub-sub capabilities using the JavaScript API, check out this sample:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Enable the button if at least one checkbox has been selected

I've written some code similar to this: $('input[type=checkbox]').click(function(event) { $('.chuis').each(function() { if(this.checked) { $('#delete_all_vm').prop("disabled",false); } ...

capture the element with the specified #hash using Jquery

Illustration: Assuming I visit google.com/#search function checkHash(){ if(window.location.hash != hash) { $("elementhashed").animate( { backgroundColor: "#ff4500" }, 1 ).animate( { backgroundColor: "FFF" }, 1500 ); hash = window.location.hash; } t=se ...

Guide to developing JavaScript code that moves information from one local website to a different one

Here's the scenario: You input text into a field on website A and click a button. Upon clicking that button, the entered text should appear in website B. I attempted to use localStorage for this functionality, but unfortunately it was not successful. ...

What is the reason for the error that is being caused by using arrow functions in my code

I'm currently working on a React application, but I keep running into errors that are causing issues. Here is the code snippet in question: import React from 'react'; import { Link } from 'react-router-dom'; const LINKS = [ { to ...

The `getScript` function in jQuery is not working as expected, even though the path is accurate and the script was successfully downloaded

Recently, I created a website using Mustache.js and incorporated templates loaded via AJAX with jQuery. During the testing phase on my local environment, everything worked perfectly. However, upon uploading the site to my school server, an issue arose whe ...

"Unlocking the door: a step-by-step guide to logging in with ajax and json for your hybrid

As a beginner coder, I am currently working on a project to create a mobile web login form using json and ajax. To test my code, I followed the tutorial provided here. This is the code I have developed: <!DOCTYPE html> <html> <head> ...

Troubden array filtration in Angular is malfunctioning

I recently developed an angular "filter component" intended to filter an array and display its contents. The keyword used to filter the array, value, is obtained from another component through a service. While the HTML displays both the value and the entir ...

What is the best way to prevent handleSubmit from triggering a re-render when moved to a different

Just started experimenting with React and ran into an issue that I can't seem to find a solution for anywhere. I have a basic search form that interacts with an API. If an invalid value is returned, it displays an H3 element with an error message lik ...

Is there a tool available on the command line to detect simple Javascript syntax mistakes?

Is there a command-line tool in Linux that can identify basic syntax errors and compile time errors in JavaScript files intended for web browsers? Usually, I write my JavaScript code alongside server-side languages like Ruby or Perl. It would be beneficia ...

Can someone explain why Array.from(classList)[0] is not changing to 'className'?

HTML Design <div class="custom-container color-red"> <h3>Hello, I am a customized container</h3> </div> Javascript Logic let element = document.getElementsByClassName('custom-container')[0]; let clas ...

`req.user` seems to be unresolved, but it is actually defined

Currently, I am working on developing an Express.js application that utilizes Passport.js for authentication in an administration panel. The program is functioning correctly at the moment, with my app.js initializing passport and setting up sessions proper ...

Utilize toggle functionality for page rotation with rxjs in Angular framework

Managing a project that involves a container holding multiple cards across different pages can be overwhelming. To address this, the screen automatically rotates to the next page after a set time interval or when the user presses the space bar. To enhance ...

Generating a Json Array using SQL data in C#

I need to retrieve data from a SQL database and send it as a JSON array to the frontend of my app. I'm not very familiar with C# so I was experimenting with it. Currently, the JSON output is not valid: [ {"name":"Perez","company":"test"}, {"name" ...

Establishing the request body for RESTful web services utilizing the POST technique

Hey there, I'm currently working on creating a REST response using the POST method. I want to pass variables dynamically instead of hardcoding them. However, I am encountering an issue when trying to send an array as a parameter to the REST web servic ...

How to highlight text within an iframe using the mouse and displaying the selected text in a separate div

I'm currently able to select text with the mouse and display that selection in a div. However, I'm struggling to do the same thing when dealing with an iframe displaying a page on the same domain. Despite trying various solutions found here, I h ...

Export default does not actually yield a function; rather, it returns an object

I recently developed a function that is responsible for importing a script from a specified source, calling its exported function, and handling the returned result. To simplify things, I have streamlined the code to focus solely on returning the result. co ...

Iterating through the elements to append a new value to a JSON array

I am looking to enhance my JSON array by introducing a new variable (score). The database contains information on the 1st, 2nd, and 3rd points received by each member. My goal is to calculate the total score for each member and showcase the top ten members ...

Ways to confirm if a video has sound

There is a video that has an audio track, yet the volume is not zero or muted, resulting in the video being silent. I am looking for a way to determine if a video is audible so that I can perform specific functions accordingly. I came across a method to c ...

Clearing LocalStorage and Cache upon initial loading in Next.js

Our project requires continuous updates, and currently users are required to manually clear their cache and localStorage data after each update in order to access the new features. Is there a solution to automatically clear all cached data upon user visi ...

Calculate the length of a JSON array by using the value of one of its

What is the most efficient way to obtain the length of a JSON array in jQuery, based on the value of its attribute? As an illustration, consider the following array: var arr = [{ "name":"amit", "online":true },{ "name":"rohit", "online":f ...