Reuse session from previous service task - camunda

I’m developing a custom connector via ssh using host, user, password, port and command as input parameters, in order to establish a connection, and as output parameter, a parameter to retrieve the response (command response).
At this point, I could make the connection and retrieve the response, the problem is that I would like to reuse the session created, if there is another service task using the same connector in the bpmn process.
But in Camunda Modeler, I could only retrieve text (not objects).
In the image below I describe the flow, as well as the parameters I’m using.

Related

Django, socket.io, node.js - Manage private messages and group conversations

I am in the process of writing a back-end for a service such as Facebook Messenger or WhatsApp.
I started out following this splendid tutorial.
I do this with an API written in Python (Django).
Along side with this API, I have a Redis process and a node.js server running (localhost only). The node.js server uses the socket.io library for real-time communication through websockets
An HTTP-request containing a message can be sent from any client to the Django API, which in turn publishes the message to Redis on a certain channel.
The node.js server has subscribed to the Redis channel, and gets notified when such a message is published. Node keeps track of which sockets that are currently connected with an array of socket ids keyed with some user identifier.
I have a few questions about this:
1. Private messages
I would like to send a message targeted to a certain user. My initial approach is to have the HTTP-request (sent to Django) include which user that the message should reach. When this message reaches the node.js server (through redis), node can find that user in an array of clients. Django obviously(?) needs to know which socket.io socket belongs to which user. i.e. Django needs to know which user identifying key that node should use to grab the right socket.
Is this a good approach? Will the redis-server be a bottleneck since I only use one publishing channel? What happens if the target user of the message is offline when the source user sends the message? I would like to grab that event and send a push-notification.
2. Rooms
This service wouldn't be any good if there was not functionality for starting and maintaining group conversations. From what I have read, I should create socket.io:s rooms for this. My question is then, how do i maintain the room between sessions? What if every user participating in a group conversation goes offline and are thereby removed from the node.js server:s array of clients. Can I somehow store rooms between sessions in the Django server?.
Any help and/or feedback/thoughts is greatly appreciated.
Thanks
Private messages
Node keeps track of which sockets that are currently connected with an array of socket ids keyed with some user identifier.
You pretty much said it there. Django does not need to know the socket id of the target user, but node.js does. If you want to send a message to user 3 you would sent to message + target user (or any other meta data you want) to redis. Node.js will look up the user by reading the element with the id 3 from the socket array and send the message to this connection. If there is no element with id = 3, the user is offline and you can send your push notification. Eather in node.js or by notifying the django server.
Rooms
Since you want your rooms to be persistant you should store them in some kind of database like mysql or mongodb. The node.js server would create all the rooms and if a user connects you can look up in which rooms they participated using their user id. If they join a new room you have to update the database. If a new room is created, node.js needs to create the socket.io room and the database needs to be updated as well.

Asyc API method

I'am working on a project that exposes a Web Api for Encrypting files and doing other tasks. What I want is to make the encryption task async, this is because files could be of size more than 1GB, and I donot want the client to keep waiting for the file to be encrypted. What I want is that once request for encryption is sent to the api the client is notified that your request is accepted and when it finishes a notification about success or failure is sent to the client again. Meanwhile client can do anything.
What are the best practices for this, moreover Iam working in asp.net mvc
You need to off load the encryption task to another thread in your serve. This will free up (complete) the request processing thread, and the client can continue with other stuff. You can wrap the encryption task such that after successful completion or failure, a callback is invoked. This callback must be responsible for notifying the client back.
To notify the client back, upon completion of the encryption task, you have several options, that you must code within your callback:
Email the client of the result.
If the client is a service and listens on a specific port, you can accept a callback URL in the initial encryption request, and can invoke this URL after encryption task. The assumption is that the client is running a http Service.
If there are any other integration points with the client (like filesystem, database, message oriented middleware), then use those to notify of task completion.

Rest API that needs a connection

I have a system where the user needs to connect to first and then based on the connection fetch some data. For e.g. you connect to a database and then fetch say metadata about a table say.
I was planning to expose this via REST API. So in this case, you need to first connect and then use that connection to fetch the metadata.
Two options come to my mind:
a. Have a url say /connect where you post the connection parameters to and it returns a conneciton id. This id is then encoded in subsequent URL to identify the connection.
b. Second option is to post the connection parameters everytime.
What are the pros/cons of these approaches? Are there any other alternatives?
One constraint is that the authentication mechanism to connect to the system is not in my control, I am just exposing some data from the systems via webservices and I am exploring using REST.
Do you really need to expose the connection?
I think it may just be semantic prejudice - but usually connection details are hidden by the service.
Does the connection have business value?!
If the connection does have business value, then treat it like a resource:
i.e.
do a post on /connections to return a new connection
then do a get on /connection//metadata to get the metadata about that connection.

Filtering data with Microsoft Sync Framework

Context: I'm working on a project that use Offline Application Architecture. Our client program has 2 modes: connected and disconnected. When user in disconnected mode, they will use their local database (SQL CE) for retrieving and storing data. When user connects to application server again, the local database will be synchronized with central database as well. The transport layer in this project is WCF, we implement a proxy class to expose SQLSyncProvider on client for Sync Framework to sync data.
Question: How could I implement data filtering with MSF? In our project, each client will has a role, and each role will have access to different number of tables as well as rows in table. As far as I know, MSF allows us to filter data with a parameter column however, the provision for users will be same. In my case, the provision for each user will be so different, it depends on user's role.
Thanks.
You can use adapter filters on server side, and can send some parameter to fetch data on client bases from client.
Client
this.Configuration.SyncParameters.Add(
new SyncParameter("#CustomerName", "Sharp Bikes"));
Server
SqlSyncAdapterBuilder

How to communicate between service controller and a service/daemon?

It is easy to display the status of a Windows service or to control it (start/stop) from a GUI application but the question if how about receiving/sending notifications from the service? Like: service telling to the user monitoring it that it needs attention.
Please consider that you can have several controllers started at any time in a multi-user environment.
Do you know an example(open source) for this kind of communication?
Extra points for a platform independent solution :)
If the "user" monitoring the service is a person, how about writing to an event log and then having your enterprise event monitoring system send alerts. Alternatively, have the service log the issue to the event log and then send an email.
If the "user" or client of the service is a separate or multiple applications here are a couple thoughts without fully understadning your problem.
Write to file. Have the client tell the service what file or some agreed token to create a file for that particular client instance and then have the service write to the file. The client can then monitor the file.
Status Ping. Have the client ping the service on a regular basis in a background thread to ask the service how it is doing. If unhealthy, then the client could ping the service for more information. Kind of like getting the LastMessage.
Open Sockets or End Point. Find a way to setup communication back from the service so that the service can call the client. This may be initiated by the client first telling the service where it is so it can call back. I forget the specifics, but WCF should be able to handle this out of the box for you. If you want something more generic you may need to roll your own.
Hope these ideas help.
As an option, use our MsgConnect (free with source) to send messages between services and controllers (crossplatform). Communication between services and controllers is possible both locally (via MMF or socket transport) and remotely (via socket transport).