Send feedback to spring from jbpm process - spring

My application is written in Spring Framework 3.x.x. In my application I want to integrate the JBPM5.x processes using its REST API. I have done this thing but I want to send feedback like simple message to my spring application so that I'm able to know what will be the status of my process on the exit of the process. I'm not able to find any way to send this kind of feedback using REST API.
Please give the right direction for it, or give any other way to integrate Spring and JBPM so that my Spring application and JBPM process can be run in different application container instances (same application server but two different instances).

Not sure the REST api would be capable of handling something like that, it is basically some stateless API to get / send information, but doesn't handle async notifications.
What I would recommend is registering a custom process listener to the engine that will be notified when a process is completed, at that point you can do whatever you want, like for example send a JMS message or any other type of async message that could be picked up by your application.
This information is probably already stored in the history log as well. So if your Spring application could take advantage of that, that might be an option as well.

Related

Using rabbitmq to send String/Custom Object from one spring boot application to another

My requirement is to for starters send a string from one spring-boot application to another using AMQP.
I am new to it and I have gone through this spring-boot guide, so i know the basic fundamentals of Queue, Exchange, Binding, Container and listener.
So, above guide shows the steps when amqp is received in same application.
I am a little confused on where to start if I want to achieve above type of communication between 2 different spring-boot applications.
What are the properties needed for that, etc.
Let me know if any details required.
Just divide the application into two:
One without Receiver and ...
Another without Sender
Make sure your application and configuration etc stays the same. With Spring boot's built-in RabbitMQ, you will be able to run it alright.
Next step is to call sender as and when needed from your business logic.

Reactive spring boot for correlation between request and response in async application

I am a newbie in reactive programming. I did some research but could not find any satisfactory answer. My requirement is to correlate request and response using reactive programming (using spring boot) in a asynchronous set up.
In detail - My organization application architecture has front end, middleware and legacy backend. Front end makes a call to middleware which talks to legacy backend over MQ. At the moment call to backend is synchronous over MQ. We are trying to uplift the experience by making the backend call asynchronous. So in this setup front end will make a call over http/rest to middleware which puts the message over MQ to be consumed by legacy systems. Once legacy system is done with processing, it will put the message back on to another queue which will in turn be picked up by middleware again and send back to front end systems. In this set up my job is to correlate the request/response in the middle layer. We have one option to use DB but I want to see whether it is possible to use reactive java for the same.
Any help in this regard would be appreciated.

SCDF: Can I use an outside microservice as a source?

I am trying to work through a solution where the workflow is like this:
User hits a microservice to upload images
That microservice de-duplicates the image and if it really is new, queues it up for processing
The processing chain lives in Spring Cloud Dataflow
The microservice already exists, and we are trying to extend it to do the fancy processing. My initial cut was to use the Http Source from the sample starter pack since that would be something I didn't have to create. The problem is that the source doesn't register itself with Spring Discovery server, so there is no way to get an end point without making gross assumptions (like it lives on the dataflow server at port XYZ).
We can create a Queue endpoint and send the data directly a Queue source that receives the outside event and forwards it to an SCDF queue.
What would be awesome is if DataFlow could connect the start of the queue for me, without repackaging the microservice as a Source.
The major issue with Spring Data Flow is that it does not automatically start up deployed streams when the server starts up, and we need to be reasonably sure that microservice is always up.
The lifecycle of the server is decoupled from the apps it deploys, that was intentional.
I'm not following your thoughts on how dataflow could connect the start of the queue, but from your description there's a few things you could do:
You would need to modify the app in order to have it registered with eureka, but this is a very simple operation, no more than a few lines of code:
You can either start from a stream app perspective: https://start-scs.cfapps.io/ , select http source, your binder, and then add the spring-cloud-netflix library as well as #EnableDiscoveryClient at the Main boot class
Start with http://start.spring.io Select Stream Rabbit or Stream Kafka, add Web and netflix libraries, then add the #EnableDiscoveryClient and #EnableBinding annotations and create a simple HTTP endpoint for your use case.
In any case should be a small addition.
You can also open an issue at :https://github.com/spring-cloud-stream-app-starters/http/issues suggesting that we add #EnableDiscoveryClient to the http source app, we can take that in consideration on our next iteration as well.
I'll try to clarify few bits.
upload images -> if it really is new -> queues it up for processing
Upon a new upload event, you'd want to process the image. Here's a similar use-case, but more of a real-time streaming style solution. This is not what you're looking to do, but I thought it might be useful.
Porting the image processing code to a Spring Cloud Stream application is as simple as adding #EnableBinding(Processor.class). It is the same business logic - whether you're running it separately or orchestrating it via SCDF, it is still a standalone microservice. However, SCDF expects it to be either a Source, Processor, Sink, or Task application types. We will be opening this up to support any arbitrary "functions" (lambdas) in the future release.
We can create a Queue endpoint and send the data directly a Queue source that receives the outside event and forwards it to an SCDF queue.
This is one of the standard solutions. You can directly consume new events (images) from a queue/topic and process it in the image-processor that we created in previous step. The named-channel support in DSL facilitates just that.
What would be awesome is if DataFlow could connect the start of the queue for me, without repackaging the microservice as a Source.
I'm not sure I understand this. If I were to assume, you're looking for "named-channel" as source and that is supported.
The major issue with Spring Data Flow is that it does not automatically start up deployed streams when the server starts up, and we need to be reasonably sure that microservice is always up.
The moment you deploy a Stream in SCDF, all the individual steps included in the DSL (i.e., stream definition) are resolved and deployed as standalone apps in the target runtime (cloud foundry, kubernetes, etc.,). Once deployed, it is left to the platform where the apps run for lifecycle management. SCDF does not retain or track the app states.

How to send data to multiple servers in spring boot micro service?

I have requirement something like this:
once the request is received by my service, i need to send it 2-3 third party servers at a time and get the response from all server and return the response.
How can I achieve that?.
My thought : I can create separate threads for different servers and send the request to all servers parallely, but here the issue is, how I will come to know the threads are finished and consolidate the response from all servers and return to caller.
Is there any other way to do in spring boot(micro service)?.
You can leverage asyn feature supported by Spring Framework. Let's see the folllowing example which issue multiple calls in Async style from Spring's official guides:Async Method
Another possible solution for internal communications between Microserives is to use the message queue.
You didn't specify what type of services are you consuming. If they are HTTP, you may want to use some Enterprise Integrations abstractions (most popular are Spring Integration and Apache Camel).
If you don't want to introduce message bus solution into your microservice, you may want to take a look at AsyncRestTemplate

Texting existing JMS application

I am working on existing project which uses JMS and spring. I am new to JMS. I need to test that application. My aim is to test that my classes which are used in the application are executed or not.
So can anybody provide me a way in which I can test the application which uses JMS?
I have searched on Google but everyone get started with a sample application. But I want to test my existing application, meaning how my application gets connected with another module. Is there any tool like SOAPUI for JMS test of my existing application, meaning something from which I can execute my classes or listener.
Edit 1
There is a scenario in my project that my module listen a JMS Queue and send SMS or Email to user but actually I am not getting that how my module connected to other module can anybody give me a way so I can find in that direction means which services or APIs used in there.

Resources