Warmup of a Spring cloud functions based solution in azure - spring

We are working in a spring cloud functions based solution, this solution will be deployed into azure.
We have implemented several functions but we have some warmup time when we start the spring context that we would like to remove.
I have been following Microsoft documentation (https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/azure-functions/functions-bindings-warmup.md)
I have created trigger that is called when the instances are created but I am unable to load the spring context.
Is there any support for this type of binding in the azure java libraries or in spring cloud functions?

Related

Access remote Camunda service programmatically

I have a remote server installation of the Camunda BPM Platform (installed using the Camunda BPM Platform Helm Chart - https://github.com/camunda-community-hub/camunda-helm/tree/main/charts/camunda-bpm-platform). It is working as expected and, while new to BPM, I have been able to try out some workflows and examples successfully.
I am now trying to connect to it remotely and register for thrown events. I've been following https://docs.camunda.org/manual/7.15/reference/bpmn20/events/signal-events/ however I am stumped as to how I can get a handle to runtimeService. Other than using the REST API is there another way to connect to a remote Camunda service? I've tried using the camunda-bpm-spring-boot-starter-external-task-client but no RuntimeService gets initialized. Perhaps I'm missing some remote-specific configuration but I have not found anything in the documentation so far. Based on https://camunda.com/best-practices/deciding-about-your-stack/ I understand that this should be possible - however, all examples I've found deal with an embedded service. Any help is appreciated!
CAMUNDA offers a Java API and a REST API. In addition there are official or community client libraries, which all rely on the REST API. The Java API is only available to code which gets deployed inside the CAMUNDA JVM.
To interact with the engine from outside the JVM you have to use the REST API. The endpoints are named after the resources, not after the Java API services. Hence you You will not find a RuntimeService endpoint on the REST API, but you will find all the functionality the RuntimeService offers, e.g. start via process-definition.
If you do not want to deploy code in the CAMUNDA JVM, then service integration is done preferably using the external task pattern. If you want to use Java, especially the new Spring Boot Starter for external task clients is fun to work with. If you prefer other languages, check out https://github.com/camunda/awesome-camunda-external-clients.
Unfortunately there currently is no implementation type external for signal events so far. Ootb you can work with signal events for 1:n communication between different BPMN processes on the same environment. If you want to send the signal to an external event bus, then you need to add this functionality to the same JVM as a one-time effort. Here is an example for Azure event bus: https://github.com/camunda-consulting/code/tree/master/snippets/engine-plugin-signal-to-azure-eventhub. The implementation would look very similar for SQS or other alternatives.
If you need to modify the container image to include custom code then you can either just add own jars to e.g. the CAMUNDA RUN Docker image as shown here: https://github.com/rob2universe/bpmrun-add-to-dockerimg
or you could build your own image based on the Spring Boot Starter as shown here: https://github.com/rob2universe/camunda-aks

Can we deploy spring micro services on AWS Lambda?

Is it recommended to deploy spring micro services on Lambda. I have recently deployed a sample spring boot app returning a sample data from AWS RDS Oracle DB on Lambda, Just analyzing the possibility if we could deploy two micro services in different Lambda functions and configure them using API gateway.
I am entirely new to it and trying to understand if Lambda can really support micro services patterns like Service discovery/Circuit breaker or Saga patterns if I deploy two or more services on different lambda functions. Would Lambda be used for such scenarios in Real Time ?
Can anyone help me if there would be limitations other than package/payload size limit or timeout limitations ?
Thanks in Advance
If you use java for serverless application like AWS lambdas I would recommend for looking a framework which supports Ahead-of-Time compilation which will boost a lot your application start. If your application is not bit it will be very easy to be rewritten with Micronaut (very similar to Spring boot development)
For instance have a look at Micronaut, Quarkus using with Graalvm. Spring Boot is not the best option using with directly with AWS lambdas, it is big package size + really a lot of initial time, not good for API services.
Target of max package sizes of 25 MB for small cold start with adjustable memory starting from 256MB, with spring boot this is not doable.
In case you are referring to Spring Boot Cloud Functions that's exactly they were made for.
Google Cloud Functions already have an Alpha product for running Java functions.
AWS Lambda seems to have support for this as well.
In case you simply wrote a Spring Boot app with embedded Tomcat that you packaged in a Docker container which you're spinning up on demand, beware that cold start can be an issue, especially with the overhead of the Tomcat.

Using Spring Cloud Data Flow with Azure Service Bus

I am trying to find some examples of Spring Cloud Data Flow and Azure Service Bus setup. .
I have found https://github.com/microsoft/spring-cloud-azure/tree/master/spring-cloud-azure-stream-binder/spring-cloud-azure-servicebus-topic-stream-binder but it is still in RC and I do not see any examples (which cover Spring Cloud Data Flow) there.
Could you please help me to understand if I can use Spring Cloud Data Flow and Azure Service Bus together?
I was able to run examples with Kafka and RabbitMQ, but I cannot find anything about Azure Service Bus that can be used as the integration solution for Spring Cloud Data Flow
Spring Cloud Data Flow doesn't necessarily need to know what messaging layer you choose to run your applications on. Hence, your question is more likely related to how one can run the application with Azure Service Bus using Spring Cloud Stream.
This is one such a sample: https://learn.microsoft.com/en-us/java/azure/spring-framework/configure-spring-cloud-stream-binder-java-app-azure-event-hub?view=azure-java-stable
Once the application is built using Spring Cloud Stream (using the Azure event hub binder), you can then manage these applications using Spring Cloud Data Flow as Streaming applications.

Spring cloud task on data flow server vs #EnableTask

I am new to Spring cloud data flow. Trying to figure out what it mean by registering, creating a task on spring cloud data flow server vs running a spring class with annotation #EnableTask
Any clarification to understand what these two are, will be helpful!
With Spring Cloud Task, you'd build and test standalone Task microservices in isolation. With the programming model, you can address use-cases ranging from ETL/ELT, data migration, or predictive-model-training etc.
Once you have an "n" no. of such applications, you could use Spring Cloud Data Flow's DSL to compose them into coherent Task/Batch pipelines. To use them in the DSL, you'd have to first register the coordinates of the standalone Task Apps.
Refer to the SCDF's Task overview and as well as the Task Developer Guide for more details - you could repeat it locally to follow along and learn the mechanics.

Spring Cloud Netflix - how to access Eureka/Ribbon from traditional web app?

Everything I found on the internet about Spring Cloud Netflix is about running microservices from Boot applications using #EnableEurekaClients and so on.
Now I'm trying to connect my logging microservice within a traditional war application (springmvc, jaxws etc) - piece of legacy which can not be converted to Boot or modified in any way (by technical task).
I've created a new maven module "log-server-client" that knows nothing about upper web layer and intended to be used as a simple dependency in any maven project.
How should I configure access to Spring Cloud Netflix for this simple dependency? At least, how to configure Eureka and Ribbon?
I just extracted some lines of code from RestTemplate and created my custom JmsTemplate (microservice works with jms remoting with apache camel and activemq), exactly how it is done in RestTemplate, but this code stil lacks connection to infrastructure
afaik, we can create a global singleton bean, run a separate thread from this bean, and run Boot app from this thread, but don't you think that it is very ugly and can lead to problems? How it really should be used?
Great question!
One approach is to use a "sidecar". This seems to be a companion Spring Boot application that registers with the Eureka Server on behalf of your traditional web app.
See e.g.:
http://www.java-allandsundry.com/2015/09/spring-cloud-sidecar.html
http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#_polyglot_support_with_sidecar
Another approach is to use the following library:
"A small lib to allow registration of legacy applications in Eureka service discovery."
https://github.com/sawano/eureka-legacy-registrar
This library can be used outside of Spring Boot.

Resources