EventHubProducerClient for publishing events regularly - azure-eventhub

My application creates a new EventHubClientBuilder() every time it sends an event to EventHub.
EventHubProducerClient producer = new EventHubClientBuilder()
.connectionString(connectionString, eventHubName)
.buildProducerClient();
I followed this quick start guide when building this application. I don't think it is best practice to create a new client if the application is expected to be publishing an event regularly (every 2-3 min) however, I cannot find any documentation that explains how to keep the client connection open aside from this .NET guide but my application is using Java.
Can someone explain how I could use a single producer client for the duration of the application? The application is consuming messages from another application and needs to published each message to EventHub.

Related

Process Instance Migration with boundary events

I am going through the Risks and limitations of Version Migration topic in the Camunda guide at the following link:
docs.camunda.org
User Guide | camunda BPM docs
documentation of the camunda BPM platform
I tried to test out the first point which says:
** If the new version introduces a new (message / signal / timer) boundary event attached to an activity, process instances which are waiting at this activity cannot be migrated (since the activity is a scope in the new version and not a scope in the old version).*
To test this , I created a simple process with a user task and created few instances:
Then I added a timer boundary event with this task and migrated instances from previous process to the updated process using REST API:
But contrary to this concept, I was able to migrate the process instance successfully and the timer triggered with no issue.
Is the given concept in the guide still valid or this is no longer valid ?
Thanks

Communication with Camunda process engine

An external service can receive a message from Camunda process engine using below piece of code. Does client polling Camunda process engine periodically to get messages ?
ExternalTaskClient client = ExternalTaskClient.create().baseUrl(“http://localhost:8080/engine-rest”)
.asyncResponseTimeout(10000)
.build();
client.subscribe(“AdlDMNOtherClient”).lockDuration(1000)…
It uses "long polling", so it does not open new requests but tries to keep a single connection as long as possible, see https://github.com/camunda/camunda-external-task-client-java/blob/master/examples/order-handling/src/main/java/org/camunda/bpm/App.java
So if your question is: "will my code get notified automatically when a new task is created", the answer is YES.
If your question is: Will I have many HTTP request, the answer is NO, normally not.
Yes. The architecture, interaction patter (incl. long polling) and ways to communicate errors or results back to the process engine are described with a few diagrams here:
https://docs.camunda.org/manual/latest/user-guide/process-engine/external-tasks/
and here:
https://docs.camunda.org/manual/latest/user-guide/ext-client/

Running Task In The Background

What is the technology which allows the web application to process the task in the background without holding user to wait until the task to finish.
Example, as a user,
1. I want to submit a form which requires heavy processing. (Assume it requires to checking or actions, upload documentation or etc)
2. After submitting the form, the task will be running in the background, then I can go to other page and do something else.
2.1 At the same time, I might submit another form to the server.
The request can be process at the same time or can be queue under a queue system
3. I will receive a notification from the system whenever the server return a response. (Regardless it is success or failure)
This feature is similar to Google Cloud Platform.
Try Kue or any other similar libraries. The term to "google" is "[language] task queue"
You can of course roll your own. Though it will be much easier if you make use of an existing server such as redis or rabbitmq. So that queuing part is handled for you by the server and you could concentrate on your business logic.

How to send a "you haven't used your app in a while " push notification in React Native using AWS?

Just wanted to know from a high level how I would accomplish this.
I thought that when a user opens the application, I will keep track of the last opened time in a Dynamo DB table.
Then I could have a background worker constantly check and see if anybody hasn't used their app in 3 or 4 days and then send a push notification, ie, "you haven't used your app in a while, why don't you open it up and do XYZ."
From a very high level, there are two possible ways:
1.) Local notifications (you don't need AWS for this):
You can schedule a local notification, every time the user opens up the app (or better - every time the user brings the app to foreground). It works like: User opens app -> cancel old scheduled notification if existing -> schedule new notification for "in 3 or 4 days" -> ready :-)
You can use something like this: https://github.com/zo0r/react-native-push-notification (see section Sheduled Notifications).
2.) You could do it with remote notifications (https://aws.amazon.com/sns/):
You can go the way you proposed. Then you have to store an entry in your db with the push notification token of the device and the last time the app was opened. Your worker then has to check and send the push message to the device using a service like SNS.
I would recommend 1.) over 2.) because you are independent from the users internet connection when getting the app opening info. In 2.) you can miss the opening info, when the user opens the app without internet connection. Also 2.) is more expensive then 1.) when you scale your app.
An advantage of 2.) would be, that you are more flexible when and what you send in your notification, since you can edit it on server side. 1.) would mean that it is coded in your app (at least until you build a synchronization mechanism for the variables) :-)

Automate Suspended orchestrations to be resumed automatically

We have a BizTalk application which sends XML files to external applications by using a web-service.
BizTalk calls the web-services method by passing XML file and destination application URL as parameters.
If the external applications are not able to receive the XML, or if there is no response received from the web-service back to BizTalk the message gets suspended in BizTalk.
Presently for this situation we manually go to BizTalk admin and resume each suspended message.
Our clients want this process to be automated all, they want an dashboard which shows list of message details and a button, on its click all the suspended messages have to be resumed.
If you are doing this within an orchestration and catching the connection error, just add a delay shape configured to 5 hours. Or set a retry interval to 300 minutes and multiple retries on the send port if that makes sense. You can do this using the rule engine as well.
Why not implement an asynchronous pattern?
You make it so, so that the orchestration sends the file out via a send shape while initializing a certain correlation set.
You then put a listen shape with at one end:
- the receive (following the initialized correlation set)
- a delay shape set to 5 hours.
When you receive the message, your orchestration can handle it gracefully.
When you don't, the delay shape will kick in and you handle accordingly.
Benefit to this solution in comparison to the solution of 40Alpha will be that your orchestration will only 'wake up' from a dehydrated state if the timeout kicks in OR when the response is received. In the example of 40Alpha, the orchestration would wake up a lot of times, consuming extra resources.
You may want to look a product like BizTalk 360. It has those sort of monitoring and command built into it. I'm not sure it works with BizTalk 2006R2 though, but you should be thinking about moving off that platform anyway as it is going out of Microsoft support.