send multiple messages Via APi ?

1
0
-1

How we can send multiple messages via the APi?

with send message task, there is no connector to add API ?

2 answers

1
0
-1

Hello,

from one pool to several pool:

* use a Throw event. A thread event can send multiple messages (just click on Add for each message)

* via a groovy script. Look at the example I already sent you.

Best

Comments

Submitted by maouachria on Fri, 10/23/2020 - 06:38

Sorry but i think that my question was wrong:( or not precise!!!

I want to send the same message from one pool to several pool?

Submitted by Pierre-yves Monnet on Fri, 10/23/2020 - 21:26

No worry. Then just add multiple time the sender in the throw event, and change the target pool. Same with the API

With Bonita, a message is "1 sender, 1 receiver". So, if you want to send to a list of receiver, you have to send 1 message per receiver. Then to copy the message for each receiver.

Submitted by maouachria on Fri, 10/23/2020 - 21:48

So, for each message we must give a different name.

whoever I want to send it to different partenaires with the same name!!!!

Is it possible?

Submitted by Pierre-yves Monnet on Fri, 10/23/2020 - 23:59

Hello,

In the studio, you must be a different name. You can give as the name the name of the target pool.

By the API, I think you can give the same name, but this is not a good idea: name is used to identify easily the message on the log file, so even if you can give the same name, I want give a different name to understand which message have an issue, isn't it?

What do you want to give the same name?

Submitted by maouachria on Sat, 10/24/2020 - 00:43

Because it is a standard message.

Effectively, after process execution I want to extract messages information from log file !!!

You mean to use for example :

* From a Groovy custom page ==>JAVA API , getting the apiAccessor from the pageContext

So I must create this page with groovy out bonita(in another editor) or in bonita ?

How I can do it?

Submitted by Pierre-yves Monnet on Tue, 10/27/2020 - 01:41

Effectively, after process execution I want to extract messages information from log file !!!

==> Don't do that, you can rely on the LOG file. What do you want to do exactly?

* From a Groovy custom page ==>JAVA API , getting the apiAccessor from the pageContext

So I must create this page with groovy out bonita(in another editor) or in bonita ?

==> This is a possibility, but using the studio should solve your issue. It's simpler than using the JAVA here.

Reminber: a message is a 1 sender to 1 receiver. So, you already know your X reveiver, ins't it ?

Let's say you have 4 receivers, in 4 different process. Process "Vacation", "Expense", "Review", "OnBoard".

So, in the Throw Event, you click 4 times on "Add a message".

For the message 1, you target "Vacation", and you give as the name... what you want, it's only for internal usage, so let's say I named this message "Coffee". You add the message content the message correction. Then I have a variable "CarColor" in my process, I add a line "msgCarColor", assigned by "CarColor". Ok, done.

For the message 2, you target "Expense", and give as the name... "tea". You populate the message with the same content.

Do I understand correctly what you want to do ?

==> Effectively, after process execution I want to extract messages information from log file !!!

I think there is nothing in the log file. To extract a message information, in the "catch event", you can associate the content's message with your local process variable. Example, in the process "Vacation", you have a variable "ColorOfVacation". Then, you can say "ColorOfVacation <= msgCarColor".

That the way to extract message information. Do not try from the log file. Keep in mind, in case of a Synchronized message, the correlation can be executed days after the emission.

So, I'm not sure that I completely understand what you look for. Are you a Bonita Customer? You can be in touch with a consultant.

Best,

Submitted by maouachria on Tue, 10/27/2020 - 08:52

No, I'm PHd student,

I want to analyze the execution traces of collaborative process that I am trying to develop. I want to extract all the elements of my process (activities, messages, events, times ....) from the logs to build it later.
I use bonita to develop a collaborative process, using standard messages.
The message names are standard, we cannot change them.
I want to send a message to two collaborators with the same name, Throw Event does not allow the same nomination for two messages !!! so is there another solution?

how can I be in contact with a consultant?

Submitted by Pierre-yves Monnet on Tue, 10/27/2020 - 19:05

Hello,

You are already in touch with a consultant (I'm one of them !). But we are in priority to help and work for our customer, so I may have a look in the community every week only. Click on the "Contact us" on the Bonitasoft website, give the way to contact you, and the company will be in touch with you. With a consultant full time, you will address your concern in less than a day.

For your need, I would recommend:

* not to see the log file, but directly request the Database. All information are saved in the database (arch_flownode_instance for activity and event).

I want to send a message to two collaborators with the same name

For the message, do you mess up a BPMN message and a EMAIL? A message is sent to a PROCESS, not to a COLLABORATORS. If you want to send a EMAIL, use the Connector EMAIL (and here, you can use the same subject of course).

How the message name cannot be changed? A BPMN message name is an internal ID actually. So, of course, you cannot have the same name (the same ID) for two different messages. So, of course (hopefully !) the Throw Event does not allow the same name (the same ID) for two BPMN messages.

Why not named the BPMN message by "ProcessTarget_YourName" ? Then the message name (the ID) will be unique. And please notice that this name is visible for you to be convenience in case of issue, but this is really an internal information.

But I really have the sensation that you want to send an email, not a BPMN message,ins't it?

Best,

Submitted by maouachria on Tue, 10/27/2020 - 19:23

I mean partner process or collaborative process.

This names were imposed by standard, we can not change its Names.

We have xml schéma predefined.

But i create my owner schéma with bdm with the

same name.

OK sir I will try

Thanks a lot

Submitted by maouachria on Tue, 10/27/2020 - 19:31

I touch about consultant because I'm in my last year of phd I must finish it.

if the price is suitable for my situation :)

Submitted by Pierre-yves Monnet on Tue, 10/27/2020 - 19:32

Hello,

Consider the BPMN Message name is an internal ID, how it can be "imposed by standard" ? How an XML Schema can define them? Are you sure this is not an email that you want to send? What is the link between a internal ID and the Business Data Model?

You may have some requirement on an activity name (which are an ID as well, they must be unique), but on a message, that no user can access, I think I miss something.

Best

Submitted by maouachria on Tue, 10/27/2020 - 19:40

That's me who defined internal I'd name with the same name of message imposed by standard. For raison to detected them from log or database as you propose.

Even email I think we must send itsome with different name??

Submitted by Pierre-yves Monnet on Fri, 10/30/2020 - 17:38

Ok, so this is a constraint with the Bonita solution: each BPMN message has a unique name. This is due to identified a message and to log the correct information to help administrator to find which message has an issue.

For an email, you can do what you want, you can use the same subject, same sender, same content.

Best,

Submitted by maouachria on Fri, 10/30/2020 - 18:53

OK sir

I think that is a good idea.

I will send the message to the first process and the same message in email as notification for the second process.

Have a good weekend

1
0
-1

Hello,

Please find here an example to send a message via the API (this example comes from the Longboard page) https://community.bonitasoft.com/project/custom-page-longboard

Example:

https://github.com/Bonitasoft-Community/page_longboard/blob/master/src/m...

Have a look at line 231.

with send message task, there is no connector to add API ?

What do you mean by "add API"? And what is a "connector to add API"? Do you speak about the Command (which is a way to add a API method inside a Bonita Engine)?

Best,

Comments

Submitted by maouachria on Fri, 10/23/2020 - 00:09

I think that you propose to create a separate java application ?

How I can integrate it with bonitastudio with task which send this message?

I search a way to send message to différents pools within bonita studio or uI design without used source code !

Submitted by Pierre-yves Monnet on Fri, 10/23/2020 - 00:26

Hello,

That the question: you want to send message to different pool. From which component?

* from a connector in a process? ==> will be by the JAVA API, getting the apiAccessor in the "provided variable"

* from an operation? ==> JAVA API, getting the apiAccessor in the "provided variable"

* From a Groovy custom page ==>JAVA API , getting the apiAccessor from the pageContext

APISession apiSession = pageContext.getApiSession();
ProcessAPI processAPI = TenantAPIAccessor.getProcessAPI(apiSession);

IdentityAPI identityAPI= TenantAPIAccessor.getIdentityAPI(apiSession);

* from a UI Designer form => REST API https://documentation.bonitasoft.com/bonita/7.11/bpm-api#toc41

* from an external application, completely out of Bonita => Java API ( login, then get the API Accessor from the ApiSession)

So, from which components do you want to send a message ? With Bonita Studio does not help: you can build a UI Designer page, a Process, a Groovy Page, a REST API Extension from a Bonita Studio.

Submitted by maouachria on Fri, 10/23/2020 - 00:58

I am looking for the simplest, the essential that I send message (which contains a complex variable) from one pool to several pools.
What method do you suggest to me?

Submitted by Pierre-yves Monnet on Fri, 10/30/2020 - 19:13

Hello,

With Bonita, as I told you, you have to send one message per pool. 1 sender, 1 receiver.

So, in the throw event, click on "Add message" then send one message per receiver. On each message, give a different name ("message_1", "message_2" etc...)

You can use the JAVA API too to send message. In your process, create a Groovy Connector, so you can develop a Groovy code to send all your message, with the pattern

List listPoolToSend = ["Pool1", "Pool54", "Pool6654"];

for (int i=0,i< listPoolToSend.size();i++) {

// look the JavaAPI (processAPI.sendMessage() ) to send the message

}

Best

Submitted by maouachria on Fri, 10/30/2020 - 19:21

Thanks sir so much.

I will try this solution.

Have a good weekend

Submitted by maouachria on Wed, 11/18/2020 - 17:11

as you have suggested, i create a groovy connector with this code:

//import com.company.model.AdtA04DAO;
import com.company.model.AdtA04;
import org.bonitasoft.engine.api.APIAccessor;
import org.bonitasoft.engine.api.ProcessAPI;
import org.bonitasoft.engine.api.ProcessRuntimeAPI;
import org.bonitasoft.engine.expression.ExpressionBuilder;
import org.bonitasoft.engine.expression.Expression;
//import java.util.logging.Logger;

Expression targetProcess = new ExpressionBuilder().createConstantStringExpression("P2");
Expression targetFlowNode = new ExpressionBuilder().createConstantStringExpression("Démarrer3");

ProcessAPI processAPI = apiAccessor.getProcessAPI();

Map mapA = new HashMap();

Expression messageContentKey = new ExpressionBuilder().createConstantStringExpression("key");
Expression messageContentValue = new ExpressionBuilder().createConstantStringExpression("AdtA04DAO");

mapA.put(messageContentKey, messageContentValue)

processAPI.sendMessage("adt_A04", targetProcess, targetFlowNode,mapA);

but i don't know how to received this message by P2?

Submitted by Pierre-yves Monnet on Wed, 11/18/2020 - 18:24

Hello,

What do you mean by "Received this message by P2" ?

You should have, in the process P2, a Catch Event named "Démarrer3".

It may be a "Start message", a "Catch message" or a "boundary catch message".

Best

Submitted by maouachria on Wed, 11/18/2020 - 19:52

yes but what i must give to message content as value? there is no id message ?

view?usp=sharing

view?usp=sharing

Notifications