Meteor - calling serverside methods from client - meteor

Are Meteor.methods they only way to call server-side functions from the client?
http://docs.meteor.com/#/full/meteor_methods
the docs don't make it clear that they are they only way, but the fact that they exist seems to imply they are the only way. What is their purpose?

There are several ways to communicate back and forth between the server and client in Meteor :
Using Meteor.methods to perform Remote Method Invokation on the server, these calls are initiated by the client, ask for a computation to be performed on the server and receive a result.
Using the Pub/Sub mechanism, the server publishes a set of data and the client is subscribing to a subset of this data, being notified in real-time of data-updates taking place in the server and thus receiving modifications.
Using plain old HTTP requests with the HTTP module.
So Meteor.methods are not the only way to execute some code on the server upon a client request.
Their purpose is usually to update the database by providing new values for server-side collections, as a matter of fact, client-side collection inserts and updates are implemented as Meteor.methods.
The Pub/Sub mechanism is used to propagate DB updates to every connected client and to make sure they receive only the minimal subset they need.
The HTTP communication is used by the server to send the initial source code (HTML/JS/CSS) of the app on load time as well as performing standard operations such as requesting and downloading a file.

Related

Better Event centric way to solve request-reply problem in Kafka or any streaming service

I am stuck in a problem while using Kafka in a microservice architecture . I am not able to understand how a microservice handling HTTP requests will be able to send a response to the user. I want to take data from HTTP and then publish it to topic named A then another validator service will validate it and publish it on another topic named B. I want to send processed data to HTTP response from subscribed data from topic B.
In my experience, one option is to respond immediately with 201 accepted, or embed a blocking validator library into your API, and properly return a 400 Bad Request.
Then future GET calls are required to read eventually consistent data that might come back from any consumer. E.g. the consumer process is Kafka Connector that writes to some database, or is a Kafka Streams/KSQL table, future API queries will return data from that. Your original client may need to make periodic HTTP calls until that data is available.

Does Meteor.call affect optimistic UI?

When I do a Meteor.call instead of a direct collection manipulation on both client and server. Does it remove the optimistic UI changes, aka minimongo changes and simply does direct to server change and wait for update on server before updating the UI?
Read the last section of this Meteor doc about 'How latency compensation works'
In Summary
You do lose optimistic data changes as you suspected if your Meteor.method is defined server-side only. In this case, when your client calls the method, you are essentially calling an REST service and waiting for the server-side response before your client can process the response.
When you do a client-side collection manipulation, client-side simulates the changes in minimongo, then tells the server to change the collection, then server updates the client with the server side changes (accepted or rejected).
Note: If you share Meteor.method to client and server, you can get optimistic nature. I've never done this, but read the link

Implementing callback from DB layer into App layer

I have a Java Servlet which writes a message to the database. Some other tier picks up this message from the DB and processes it and updates the status of this message in the database. Meanwhile in the servlet, I have to keep polling the database to get an update on status of the message which was written earlier.
How can I implement a Callback instead of polls so that unnecessary database queries are avoided?
I suppose you're talking about server push technologies. I suggest you to use HTML5 websockets for this. Use your same servlet with a websocket to communicate between both ends.
There are so many examples out there.
Java WebSockets - In this example he uses jetty, but you can
use jboss or tomcat for this.
StackOverFlow post describe the same.
pushing data for multiple clients from a server via websockets
try above links and it is worth for trying.

Invoke client side method synchronously with SignalR

How can the web server invoke a method on the client synchronously using SignalR? The key part here is that the server should wait for client to send data back to the server before continuing on?
Basically I'm looking to treat a client method invoke like a WCF service request. Invoke the client and wait for the data to be returned.
SignalR does not provide a way to synchronously invoke client-side methods.
To achieve the same functionality as a synchronous call, you could pass some sort of invocation ID as an argument to your client-side method. The client could then invoke a server-side method like ClientMethodCompleted with its invocation ID when the client-side method is done. Basically you will be implementing your own ACK.
If you go this route, you will have to track the client invocations along with their respective ID's on the server. You can then execute whatever logic you would have done after a synchronous call in the ClientMethodCompleted method on the server.
This should be fairly simple if you are invoking the method on only one client. If you are invoking the method on multiple clients you will have to keep track of which clients you are invoking your method on so you can ensure all the clients have acknowledged the invocation before running your followup code.
I would also make sure that you periodically clean up the data structure storing unacknowledged client invocations if you are at all worried about a DOS attack, since this would be an obvious attack vector that could allow a malicious client blowup memory consumption.

Is it possible to call aspx page via HTTP Endpoint in SQL server 2008/5

Is it possible to call (Post to) a Method in a ASPX (Code behind) page via HTTP endpoint in Sql server 2008/2005.
HTTP endpoints are first of all, deprecated. No new development should rely on them. Second, they have been, even for their brief lifetime, exclusively for incomming HTTP requests. HTTP endpoints can only serve a SOAP response, can never make an outbound call (GET or POST, mathers not). And last, all the points #gbn already made: never block a transaction on an outbound call. Do the business validation from a process call, before insert into the DB.
At worst, if no validation is possible before the insert, queue up a request for validation and place the data in a 'pending' state in the trigger, then commit. Then an external process can scan that queue and service the validation requests. You can Use Tables as Queues.
And no, CLR Web calls from triggers are no a solution (I'm sure some will mention them)...

Resources