Skip to content
This repository has been archived by the owner on Dec 28, 2019. It is now read-only.

JHipster and Activiti in microservices option #2

Open
xsalefter opened this issue Feb 14, 2018 · 7 comments
Open

JHipster and Activiti in microservices option #2

xsalefter opened this issue Feb 14, 2018 · 7 comments

Comments

@xsalefter
Copy link

I know that this issue/question is not directly related to generated-jhipster-activiti project, but I think this issue/question could be a feature/improvement for the generated-jhipster-activiti project it self.

I'm looking at some code in the generator here, it seems like the only JHipster + Activiti integration is only for monolithic application, and there's no further integration point for microservice application generated by jhipster. Is this assumption correct?

If yes:

  1. As activiti has its own REST endpoint, is it possible if we creating a microservices (using JHipster microservices) that contains delegate operations from original Activiti REST controllers so that microservices will take advantage from a configuration generated by jhipster?

As an example, what I try to build is something like this in JHipster microservice generated project:

@RestController
@RequestMapping("/api")
public class JhipsterMicroserviceProcessDefinitionResource 
extends ProcessDefinitionControllerImpl implements ProcessDefinitionController {
    private final ProcessDefinitionController delegate;
    // Other code
}
  1. If point 1 possible: Which package do I need to look if I want to implements this microservice delegate? I guess it would be activiti-cloud-services-rest-api and activiti-cloud-services-rest-impl, but I could be wrong, so hence I asked.

If no:
If the answer is no, which is mean "yes" section not feasible/possible, is there any configuration point I could take a look to make Acitiviti REST take advantage of JHipster Registry, Feign Client, etc?

Thanks.

@ryandawsonuk
Copy link

ryandawsonuk commented Feb 14, 2018

Yes the integration is only monolithic at the moment. I can explain why.

If you just want to add REST endpoints you can certainly do that. You could follow the example of https://github.com/Activiti/generator-jhipster-activiti/blob/master/generators/app/templates/ActivitiController.java or you could use v6 and activiti-spring-boot-starter-rest-api

Activiti v7 adds Activiti Cloud concepts. Part of the idea is that the execution for the BPM process can be in different java processes. So processes that connect to the engine database and contain engine classes are called 'Runtime Bundles'. These are able delegate execution of individual tasks/delegates to microservices called 'connectors'. We have an example of this at https://github.com/Activiti/blueprint-trending-topic-campaigns where 'english-campaign-rb' is a runtime and there are connectors implementing delegates. For example https://github.com/Activiti/blueprint-trending-topic-campaigns/blob/develop/activiti-cloud-connectors-ranking/src/main/java/org/activiti/cloud/connectors/ranking/UpdateAuthorRankConnector.java#L39 . These look a bit different from traditional delegates as they get their instructions from runtime bundles via spring cloud streams. That stream in particular uses a destination name https://github.com/Activiti/blueprint-trending-topic-campaigns/blob/develop/activiti-cloud-connectors-ranking/src/main/resources/application.properties#L4 that links back to the task in process definition in the runtime bundle - https://github.com/Activiti/blueprint-trending-topic-campaigns/blob/develop/english-campaign-rb/src/main/resources/processes/en-campaign.bpmn20.xml#L55

This means the runtime bundle uses spring cloud streams and other stuff that makes it reliant on spring boot 2.0. When we started work on the jhipster generator, jhipster didn't support spring boot 2.0 and the differences were therefore very large. I see this may have very recently changed jhipster/generator-jhipster#7061

Even with jhipster on boot 1, it was possible to get a jhipster app talking to an Activiti runtime bundle that was running in its own process (https://github.com/quantixx/poc-activiti-jhipster) and calling out to it via REST. But I guess that's not what you're interested in.

I think what you had in mind was a generator to create microservices that implement delegates for tasks and call out to them via REST. The mechanism is instead spring cloud streams. What this generator does right now is make an existing jhipster app into a runtime bundle. It would be very interesting to try add an option to the generator to create a cloud connector in another directory like I think the jhipster microservices stuff does (creating the connector following steps from https://activiti.gitbooks.io/activiti-7-developers-guide/content/components/activiti-cloud-app/CloudConnectors.html - I guess the generator should ask a question to decide what name to use for the destination and could use a vanilla name for the delegate class).

This would be a JHipster optional module so I'm not sure whether it would have the power to create new projects - that power might be reserved for the core JHipster code. But even if so maybe it would be possible to run it to configure an existing JHipster microservice to act as an Activiti cloud connector. We started a conversation with JHipster about it previously (jhipster/generator-jhipster#6454) but didn't progress beyond attempting to handle the runtime bundle case due to the spring boot version mismatch.

If you want to know more about Activit v7 we have a presentation on the trending topics example that I referenced above (https://www.slideshare.net/RyanDawson16/activiti-cloud-deep-dive-86736270?qid=c55d7618-4457-45aa-9395-880cedefff0e&v=&b=&from_search=17) and have a work-in-progress gitbook (https://www.gitbook.com/book/activiti/activiti-7-developers-guide/details). Or for previous versions and non-cloud usage there are lots of good articles at https://github.com/Activiti/Activiti/wiki/Articles-and-Blogs-on-Activiti - e.g. for the spring boot starter there is https://spring.io/blog/2015/03/08/getting-started-with-activiti-and-spring-boot

Apologies for the length of my reply - I'm glad to see you're interested and keen to help if I can

@warnonphilippe
Copy link

Hello all,

I made a microservice with an integrated activiti. My approach is different, I use it in some microservices that requires workflows, but I don't need a centralized activiti engine. An advantage is that activiti and the service share the same spring context, so they can work together without rest calls or streams.

What do you think of this approach ?

I fork a poc from jBarrez using spring-boot and activiti and adapt it to use jhipster. You see an example here :

https://github.com/warnonphilippe/spring-boot-with-activiti-example

I didn't implement a generator.

Philippe

@ryandawsonuk
Copy link

@warnonphilippe Yeah you can totally use the spring boot starter to embed Activiti. I was thinking of having the generator do that for a JHipster monolith application.

I think I am missing something as I'm not sure where the JHipster is your example project? Do you meant that plan to run your service with embedded Activiti as one of the services behind the JHipster gateway? Happy to chat about this at https://gitter.im/Activiti/Activiti7 if that's easier

@warnonphilippe
Copy link

Sorry, you're right, jhipster is not in this example.
I forked and completed the spring-boot app with a Facade, test, etc... before copying the sources in a microservice generated by jhipster ( I'll post a clean "jhipster" version later on my github).
My microservice was generated by jhipster, but is also a spring-boot app, so I could integrated activiti in the same way I did with a spring-boot app without jhipster.

Behind my gateway, a micro-service with business logic (bigger than a true micro-service in fact) needs workflows management, activiti engine is included in this service.

I thought also to create an 'activiti' microservice, used by others services, but considering the complex business logic, I need a good integration between service logic and workflow.

@warnonphilippe
Copy link

My microservice is more a hybrid service between monolith and true small microservice, a "big microservice" connected to others services in the micro-services environment, to avoid splitting a too complex business logic.

@ryandawsonuk
Copy link

Yeah I can see how that could be useful. Certainly keen to discuss further so that we prioritise the kind of JHipster integration that gives most value.

@coderLinJ5945
Copy link

I am very interested in the current jhipster integration activity.
Do you have any communication blogs?
I would like to know the current progress.Looking forward to your reply. Thank you very much

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants