How to control errors in mule 4? - error-handling

There is a scheduler API that I have created, inside that there is a for each which is taking an array as [1, 2, 3, 4, 5, 6]
Based on the value from the array I am using a choice router.
Now if any error occurs when payload == 2, how should I control the error handling such that after catching the error the control should go to payload == 3
No batching is used in this API.

Use a a Try scope with error handling inside the choice branch for payload == 2 to handle the error with on-continue to capture the error.
Note that there is nothing ache specific in your question or in this solution.

Related

grpc._channel._InactiveRpcError: _InactiveRpcError of RPC that terminated with: status = StatusCode.INTERNAL

This is a gRPC service & client python program. After running the client script it throwing this error. I am pretty new to using APIs/ gRPC in particular. It would be great if I get to know what might be the problem. Installed gRPC library & few supporting libraries too.
Even though the server is running correctly, the communication through gRPC is terminating with the INTERNAL error status code. Running it on localhost.
return _end_unary_response_blocking(state, call, False, None)
File "/home/mark/anaconda3/envs/custom-model-server/lib/python3.8/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INTERNAL
details = "indices[0,350] = 1650751580 is not in [0, 30522)
[[{{node tf_bert_for_sequence_classification/bert/embeddings/Gather}}]]"
debug_error_string = "{"created":"#1629922773.170809502","description":"Error received from peer ipv4:127.0.0.1:8001","file":"src/core/lib/surface/call.cc","file_line":1066,"grpc_message":"indices[0,350] = 1650751580 is not in [0, 30522)\n\t [[{{node tf_bert_for_sequence_classification/bert/embeddings/Gather}}]]","grpc_status":13}"
'''
The solution for this was to check the byte array that was being passed to the function and make sure the length we were taking was of the array itself not in bytes. So we were able to do:
dimensions = len(byte_array)//4

How to define multiple errors for -XX:AbortVMOnException

I am depending on libraries that hang for certain errors, which I cannot fix! The offenders are currently StackOverflowError and OutOfMemoryError but there might be more.
I am trying to upgrade the unrecoverable hang to an exit/abort. However, I cannot figure out how to pass multiple different errors to the -XX:AbortVMOnException as only the latest argument is active in:
JAVA_OPTS="-XX:+UnlockDiagnosticVMOptions -XX:AbortVMOnException=java.lang.StackOverflowError -XX:java.lang.OutOfMemoryError" foo
There can be only one value for AbortVMOnException option.
JVM does a substring search when checking if the exception class matches AbortVMOnException value. E.g. -XX:AbortVMOnException=Error will cause the VM to abort on any throwable with Error in its name: java.lang.StackOverflowError, java.lang.OutOfMemoryError, java.lang.NoClassDefFoundError, etc.
To add a custom callback on the desired exception types, you may use the JVM TI approach described in this answer. You'd only need to replace
if (strcmp(class_name + 1, fatal_error_class) == 0) {
with
if (strstr(fatal_error_class, class_name + 1) != NULL) {
and then it will be possible to specify multiple exceptions types that cause VM exit:
java -agentpath:/path/to/libabort.so=java/lang/StackOverflowError,java/lang/OutOfMemoryError ...

Celery Error Handling

I've built a fairly simple application linking Flask, Celery, and RabbitMQ using docker-compose by linking together a few solutions I saw online. I'm having some issues trying to update task states to reflect if a failure occurred. To keep error visibility at it's highest, I've had my custom class only raise expected errors, else the errors are handled at the celery app level as follows (in celery_app.py):
#celery_app.task(name='celery_worker.summary')
def async_summary(data):
"""Background summary processing"""
try:
logger.info('Summarizing text')
return BdsSummary(data, nlp=en_nlp).create_summary()
except Exception as e:
current_task.update_state(state='FAILURE', meta={'error_message': str(traceback.format_exc())})
logger.exception('Text Summary worker raised: %r'%e)
I've been doing some negative testing against my application, and when I pass it data that I know will throw an error (non-text data, for example), when i run r = requests.get('http://my.app.addr:8888/task/my-task-id') I get {'status': 'SUCCESS', 'result': None}. I'm vexed as to why this is happening. Based on my admittedly limited understanding of Celery's behavior, it should update the status to show a traceback and ExceptionClass, why would it not do this?
I am relatively new to Celery, so my understanding of the Canvas that they reference in the documentation is extremely basic. I'm just trying to provide some basic task failure information to the response/task. For context, when I give it proper input, I get back {'status': 'SUCCESS', 'result': {'summary': 'My Summary text here', 'num_sentences': 3, ...}}.
Any insight here would be much appreciated

Spring Batch JMSItemReader giving duplicate data in session transacted mode

I have a spring batch job which has single step. I am using JMSItemReader where jmstemplate is session transacted and my writer is just performing some business logic. Whenever any exception occurs by default and retry is exhausted then automatically batch size becomes 1 and retrys for all the items one by one.
I am defining step like this.
stepBuilderFactory.get("step")
.<String, String> chunk(10)
.reader(reader())
.processor(processor)
.writer(writer)
.faultTolerant()
.processorNonTransactional()
.retry(SomeException.class)
.retryLimit(2)
.backOffPolicy(backOffPolicy)
.skip(SomeException.class)
.skipLimit(Integer.MAX_VALUE)
.build();
The issue I am facing is something like this
Input is : 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Items in batch 1, 2, 3, 4, 5
Exception occurs in writer
Retrys for 2 times and retrys exhausted
Now it will try 1 by 1 like this
item - 1 - Error
item - 2 - Success
item - 3 - Error
item - 4 - Error
item - 5 - Success
As error occurred so items 1, 3, 4 are skipped and 2, 5 are successfully processed
Here is the issue - Next I should get 6, 7, 8, 9, 10 as batch for processing but I am getting 1, 2, 3, 4, 5 as batch again and its getting executing infitely.
Note: It works fine when the sessionTransacted is false but in that case it doesn't roll back messages in case of exception to ActiveMQ Queue.
Any help is appreciated.
I think this is valid behavior, Since there is transaction rollback and message is not removed from queue, message is available for next listener thread for reading. And you've skip limit of Integer.MAX_VALUE, hence it would retry for infinite time(nearly as you have large skiplimit). I believe you need to configure dead letter queue for the queue you are reading from such that, after certain retries, if the message is corrupt/invalid, should be moved to DLQ, for manual intervention to process the message. Thus the same message is not redelivered again to the listener.

Error returned by Nuance DragonMobile text-to-speech when maximum number of transactions is reached

I'm about to release my App on IOS that uses Nuance Dragon Mobile SDK. I'm signed up for the "Silver" plan, which allows me 20 transactions per day.
My question is, does anyone know what error is returned by Nuance, when the limit is exceeded? I'm concerned, because I am filtering out:
error.code == 5 // Because this fires whenever I interrupt running speech
error.code == 1 // Because after interrupting speech, the first time I restart, it cuts off
// before finished, so I automatically start again, so as not to trouble the user to do so
I figure if Nuance returns an error different from these, I'll allow it to pass through, and be able to alert the user that they've reached their daily limit.
I think the following gives the possible errors:
extern NSString * const SKSpeechErrorDomain;
enum {
SKServerConnectionError = 1,
SKServerRetryError = 2,
SKRecognizerError = 3,
SKVocalizerError = 4,
SKCancelledError = 5,
};
It seems likely to me that it's the SKServerConnectionError that would be fired. In that case, I need to come up with a different strategy. If I could figure out what's going on with the restart issue I wouldn't have to filter out that error. Plus, when I automatically restart these false starts, I'm probably racking up my transaction count, which is unfortunate.
Anybody have experience with this aspect of the Nuance SDK for IOS?