How to remove a message from the JMS queue (Message Processor) at a flow FAULT? - wso2

Normally when an error occurs in processing (MessageProcessor) JMS queue and goes to faultSequence and is not removed from the queue. My doubt is in some fault codes that I need to remove the message from the JMS queue even being a FAULT. Could you help me.

if you are using Message Forwarding Processor, You can not remove the message out from the Queue. It will be keep try until it send the message out successfully.
You can use Message Sampling Processor for your use case, Sample Message processor send the message only once and remove it from the queue. If you found it as a faulty attempt, you can re insert the message into the queue again based on Fault code that you got it in faultSequence.

You probably run your processor under transaction, having the following within your JMS listener config of axis2.xml:
<parameter name="transport.jms.SessionTransacted">true</parameter>
Changing this parameter to false will make your failed messages removed from the queue they were read from.

Related

Is there any way (like retry )to handle AWS SQS Sendmessage Failure scenario in WSO2 EI 6.4.0?

I am performing SendMessage operation in WSO2 EI 6.4.0 using AWS SQS Connector (V1.0.7).
Sometimes Message is not posted to AWS SQS Queue, got some ERROR/WARNING Message in Log mentioned below
ERROR Code from Log:
Error_code = 101506 or Error_code = 101508
Warning Message:
[HTTPS-Sender I/O dispatcher-2] WARN {org.apache.synapse.transport.passthru.Targe
tHandler} - Connection closed by target host before receiving the response Remote Address : host/ip
So whenever failure occurs, mediation will go to fault sequence , I'm just looking for some solution like retry .
Can i add some endpoint timeout error handling inside sendMessage template code and trying to rebuild the same?
Or else inside faulty sequence shall i perform same sendMessage Operation once again ?
Kindly let me know the feasible solution..
Did you try to use a Message Store and a Message Processor to implement a Guaranteed Delivery System? You have to publish the message to a Message Store. A Message Processor can try to post it to the SQS. If it fails, it will be added to another Failover Message Store. We can add the message to the original message store after some time with the help of another Message Processor. This way, it will keep on retrying until it succeeds.
https://docs.wso2.com/display/EI640/Guaranteed+Delivery+with+Failover+Message+Store+and+Scheduled+Failover+Message+Forwarding+Processor
If this solution is too complex, you can go with your second option where you call the sendMessage Operation inside the fault Sequence.

Deleting a message from SQS after certain number of receives regardless of success/failure

I am using SQS queues in two places of my Spring boot application :
In one queue, I would like the messages to be routed to DLQ when maximum numbers of receives for a given message > = 3
For the second case, I don't like to configure a DLQ.
In (1) and (2), however, I would like to delete the message from DLQ and normal queue respectively after 3 times receives.
As of now, I cannot find any such configurations in SQS, that allows me to delete a message from the queue after a certain number of receives.
Maybe, I am missing something. Could anyone please help here?
There is no mechanism for "automated" deletion of messages from SQS queue upon a given number of unsuccessful received, if you don't want to use DLQ.
Without DQL, SQS will keep messages in the queue till they expire. Thus, if you want to do what you wish, you have to create your own solution for that. You have to store number of times the message got received, e.g., in DynamoDB, and then upon third receive, the consumer must explicitly delete the message from the queue.
You can explore sqs message attributes. Once you received the message, delete it from the queue and send it back to the queue with an added message attribute stating how many times you have received the message.
Ref:https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-java-send-message-with-attributes.html

use aws sqs for different message types

I am using AWS SQS and Spring JMS in my project. I have my method with #JmsListener(destination = "queue_name"). I want to use this queue for two different types of messages.
Since this listener is configured to this queue it receives both types of messages. What I am trying to achieve is to ignore message of one type. (Sender is adding a MessageAttribute while sending message to Queue). So, is there a way to just ignore message coming from sender 2 so this method won't process them.
Also, I have DLQ set on this queue with max receives as 5. So if message is not processed in first 5 attempts it gets moved to DLQ.
Please do share your suggestion.
Thanks.
The correct solution is to use 2 different queues; SQS can't filter the messages delivered by any property, so as you are seeing, when the client reads the message and doesn't process it, it is going to end up in your DLQ quicker.
Queues are free, so having multiple won't cost any more.

WSO2 ESB - How process messages one by one (in series) from messages store

I try use sample process and scheduler process to do it. But they are work by fixed intervals and don't wait finish previous message.
A forwarding message processor (class ScheduledMessageForwardingProcessor) wait for the http response before dequeueing next message in the store, if the response is OK.
In case of error, 404 for exemple, it rollback JMS transaction and continue with the same message again and again.
The interval used in the ScheduledMessageForwardingProcessor's definition is the interval use by the MP to dequeue next message after a response.

publishing and subscribing through rabbitmq server

I need a scenario where one node send a message and another node starts waiting to get the message.
Each node after getting message sent turns into listener and after receiving message it turns into publisher again.
Look on this RPC example. You will have to slightly modify it to exit listening and start publishing.