I have a process where, at some point, two different kind of message can occurs, and if none appears after a time, the workflow goes timeout.
Based on the documentation, I have modelised the process using a event gateway :
To progress my activiti workflow, I am using activiti REST API. However, I cannot find in the documentation how to send a message to the gateway in order to continue to either Message 1 or Message 2. I tried triggering message to all execution IDs linked to my process ID but to no avail.
What is the right REST API command to progress in this workflow ?
Thanks for your support.
Edit 1 :
It seems that the Event Gateway is subbed to only one event.
It react to :
POST http://localhost:8082/activiti-rest/service/runtime/executions/20178
{"action":"messageEventReceived","messageName":"Message 1"}
and continue the process for the Message 1. However, with Message 2 defined exactly the same (but with another message), it returns the not found subscription error :
Execution with id '20178' does not have a subscription to a message event with name 'Message 2'"
For an event gateway (https://www.activiti.org/userguide/#bpmnEventbasedGateway). The intermediate message/signal catching events are mutually exclusive. It will follow only one path from the gateway depending on which message is received. In your case, you have fired message 1 already, so the execution continues on message 1 path and other message subscriptions are deleted. Therefore you are getting the error.
Related
I am subscribed to a Azure servicebus topic made by an external department. The way I want the code to work is as follows:
Trigger an http endpoint that starts processorClient and listens to the topic.
Fetches one message
Does required actions to that message
Closes processorClient connection.
Repeat
I am using the ServiceBusProcessorClient class as shown in the following documentation Receive messages from a subscription
Is there a way to utilize this code in order to only fetch one message from the topic at a time before calling the processorClient.close();
I have tried using setting maxConcurrentCalls and setting prefetchCount(0).
Our system has configured to consume and send reply to the same queue, i.e., JMSDestination and JMSReplyTo are the same. I cannot change that right now.
In my integration test, if I set replyToSameDestinationAllowed=true, Camel continues to consume the reply I sent to the queue, i.e., it "captures" the source and never stop and enters a loop.
But, if I don't set it, Camel refuses to send the reply to the queue, saying this:
JMSDestination and JMSReplyTo is the same, will skip sending a reply message to itself
That causes problem for my integration test. I want to consume the message in a separate method and assert against it.
How can I stop Camel from capturing this queue, i.e., consuming only once and ignore the rest?
At the end of my route I call stop() to send reply automatically.
When receiving the second message(the reply), I see this line:
2023-01-10 14:37:22,186 DEBUG [org.apa.cam.com.jms.EndpointMessageListener]-{Camel (camel-1) thread #19 - JmsConsumer[my.queue]}-Received Message has JMSCorrelationID [ID:hostname-1673354133272-4:1:1:10:1]
Can I use this to ignore the reply? Should I stop the route? Rollback? Or what should I do?
At last I filtered out messages based on the presence of JMSCorrelationID header.
from("activemq:xxx")
.filter(simple("${header.JMSCorrelationID} == null")) // ignore reply
.to("direct:main");
Even that I don't set it in my client side code, seems that Camel will use message id to set JMSCorrelationID when sending reply if the incoming message hasn't it. If incoming message already has JMSCorrelationID, Camel will not change it, and will copy that value to the reply.(I guess that if you manually set JMSCorrelationID in client side, Camel will stop setting it for you).
So basically, message without JMSCorrelationID means it's new message which hasn't passed through my client application. I think only client side should set it, especially in my case where original message and replies are put into the same queue, where client needs a mean to filter out replies.
Also, I find that receiving can specify a message collector stating the field you want to filter. For example:
QueueReceiver receiver = jmsSession.createReceiver(myQueue, "JMSCorrelationID='" + correlationId + "'");
This is useful when you know the correlationId. But in my case (#QuarkusIntegrationTest which is a black box test), this cannot be used.
But after doing that, in my integration test Camel still "captures" the consuming and will not let another method to consume the message properly(the other method never receives anything) when I run the whole test class(with other test cases); when running individually, this test case passes. So at last I disabled the test case.
Seems that after filtering out the message, Camel behaves exactly same as if I called .stop(), executing the callback (sending reply); and will send the original message to reply queue, in my case, the original queue, so it's looping and never let go. Even I enable duplicate check, it still captures.
At the very last, we separate the queues so even capturing is happening, it does not matter any more.
In QuickFix/J we can send a ResendRequest message to the Acceptor to request messages to be resent to the Initiator, within a given MsgSeq number range. For example:
Session session = Session.lookupSession(new SessionID("FIXT.1.1:SENDER->TARGET"));
session.send(new ResendRequest(new BeginSeqNo(1), new EndSeqNo(0)));
This message will request all existing Execution Reports for any open orders in the Acceptor.
The issue we have is that these messages come with PossDupFlag set to Y in the header. QuickFix/J by default ignores these messages and doesn't call the fromApp callback. I found that the callback is called if we set
ValidateSequenceNumbers=Y
but, as per the documentation, it has a drawback
If not enabled and a mismatch is detected, nothing is done.
I was wondering:
is there a different way for these messages to be processed by the callback?
if there is no other way what are the consequences of setting ValidateSequenceNumbers=Y? Is it just detect the sequence number mismatch ourselves?
Thanks
After some digging around I found a solution for this problem. Basically, we need to tell QuickFix/J that our target MsgSeqNum is 1. The logic will detect that the actual target's MsgSeqNum is higher than the one we have set and it will send a ResendRequest to the Acceptor:
Session session = Session.lookupSession(new SessionID("FIXT.1.1:SENDER->TARGET"));
session.setNextTargetMsgSeqNum(1);
In this case, the fromApp callback is called even though the PosDupFlag is set in the messages.
My Program Working in Synchronous way...I stored my msg using rabbitTemplate.convertAndSend(queueName, (messageRequestXml));
In consumer ( Message receiver) it receives msg and processing it...
but till that time I am not getting response. Once I stored msg in queue..I need to send response to user without waiting for listener action.
Please help on this.
you may use DefaultConsumer, which is asynchronous consumer and will process newly added message immediately
I am using RabbitMQ in my java application.
I want to move messages from 1 queue to another queue.
The answer that i found here is helpful for me
Is it possible to move / merge messages between RabbitMQ queues?.
But on running that command, there's no success or failure message.
How can i ensure this during runtime?
The command I am using
rabbitmqctl set_parameter shovel my-shovel '{"src-uri": "amqp://localhost", "src-queue": "myQueue", \
"dest-uri": "amqp://localhost", "dest-queue": "test3"}'
And the output
Setting runtime parameter "my-shovel" for component "shovel" to
"{\"src-uri\": \"amqp://localhost\", \"src-queue\": \"myQueue\",
\"dest-uri\": \"amqp://localhost\", \"dest-queue\": \"test3\"}" ...
Another way to do this is to set a RabbitMQ policy for Time To Live or Size on the Queue. Then, setup up a policy to handle where the messages should go. This will expire the messages out of the first queue and send them to the second queue. The reference for how to do this is here and here.
If you have the rabbitmq_shovel_management plugin enabled, you can view the configured shovels and their status in the web-management console under the ADMIN tab.