Execute sql 92 query on message queue - mq

I want to retrieve messages sent in a queue between two PutTime. I try with this query:
TextMessage vMessage = (TextMessage)
super.receiveSelected("Root.MQMD.PutDate = '"+pPutDate+"'
AND Root.MQMD.PutTime BETWEEN CAST('103345' AS TIME) AND CAST('104345' AS TIME)");
But I have a message selector syntax exception. What's wrong with this query ?
org.springframework.jms.InvalidSelectorException: JMSWMQ2008:
Impossible to open the message queue.
It's caused by the the bad syntax of the query

Related

Sending Compiled bytecode of gremlin query to remote server

Example Code(JAVA):
Cluster cluster = Cluster.open(yml.getFile());
DriverRemoteConnection driver = DriverRemoteConnection.using(cluster, "graph_traversal");
GraphTraversalSource allGraph = AnonymousTraversalSource.traversal().withRemote(driver);
//Compile Script
GremlinScriptEngine engine = new GremlinGroovyScriptEngine();
String script = "graph_traversal.V().outE().inV().path().unfold().dedup().group().by{\"category\"}";
SimpleBindings bind = new SimpleBindings();
GraphTraversal compiled = (GraphTraversal)engine.eval(script, bind);
//Send bytecode to remote server
CompletableFuture<RemoteTraversal<?, Object>> result = driver.submitAsync(compiled.asAdmin().getBytecode());
result.get(); // Exception
I'm trying to send a gremlin bytecode to remote server through driver.
But the codes occurs an exception when the script includes 'lamda'.
The exception message is as following.
Exception:
io.netty.handler.codec.EncoderException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: An error occurred during serialization of this request [RequestMessage{, requestId=84d5d022-1b08-41a6-b57f-8fdc3b5b6c65, op='bytecode', processor='traversal', args={gremlin=[..., dedup(), unfold(), dedup(), group(), by(Script1$_run_closure1#78b612c6)]], aliases={g=graph_traversal}}}] - it could not be sent to the server - Reason: org.apache.tinkerpop.gremlin.driver.ser.SerializationException: java.lang.IllegalArgumentException: Class is not registered: java.lang.reflect.InvocationHandler
Note: To register this class use: kryo.register(java.lang.reflect.InvocationHandler.class);
if the script doesn't contain the lambda, it won't make any exception.
How can I resolve this?
Thank you.
Solved:
By using Lambda.Methods.

kafkatemplate is modifying message sent, need original message to be sent as it is

I have implemented custom kafkalistenererrorhandler. I want to send the message to retry topic if message fails in processing. For this purpose I have added some headers to it. For doing this I am using spring-meesage.
Issue is when I am sending message using kafkatemplate it adds "\" to the string message.
Following is the code what I am doing.
public Object handleError(Message<?> message, ListenerExecutionFailedException exception) {
logger.info("Enter handleError message");
int numberOfRetries = messageRetryCount(message);
MessageBuilder<?> messageBuilder = MessageBuilder.fromMessage(message).removeHeader(KafkaHeaders.TOPIC)
.removeHeader(KafkaHeaders.PARTITION_ID).removeHeader(KafkaHeaders.MESSAGE_KEY)
.setHeader(KafkaHeaders.TOPIC, numberOfRetries > 0 ? retryTopic : dlqTopic);
template.send(messageBuilder.build());
Internally spring-kafka converts message to producerRecord. which in output adds \ to the string.
2020-03-20 12:25:28.804 INFO 10936 --- [_consumer-0-C-1] c.h.kafkaretry.consumer.SimpleConsumer : in rety :: "\"testfail\""
Does anyone faced same issue ? any alternatives or solution ?
Looks like you use JsonSerializer while your data is just a plain string. Consider to use a StringSerializer or JsonDeserializer on the consumer side.

Document Client Exception Incorrect Error Status Code

While testing DocumentDb stored procedures I intentionally created a document with a duplicate id so that I can observe the DocumentClientException. According to the documentation at http://azure.github.io/azure-documentdb-js-server/Collection.html#.ErrorCodes I was expecting the exception to have a 409 status code indicating Conflict.
The stored procedure code is as follows:
isAccepted = collection.createDocument(collectionLink,
duplicateIdDoc,
{ disableAutomaticIdGeneration: true },
function(err, createdDoc, options){
if (err) throw err; // Rollback
});
I do receive an exception but the error code is 400 (BadRequest). The message text indicates the correct problem. A resource with the specified id or name already exists.
"Message: {\"Errors\":[\"Encountered exception while executing function. Exception = Error: {\\"Errors\\":[\\"Resource with specified id or name already exists\\"]}\r\nStack trace: Error: {\\"Errors\\":[\\"Resource with specified id or name already exists\\"]}\n at Anonymous function (duplicateIdTest.js:56:26)\n at Anonymous function (duplicateIdTest.js:685:29)\"]}\r\nActivityId: 886230cf-8d49-433e-845f-8cc7c2ae486d, Request URI: /apps/514defcb-ac21-44e6-a8e0-c7b785523c6c/services/32782613-7101-4924-97b0-604052a6723b/partitions/be6c2ec8-130c-4596-90a2-b1807977dd0b/replicas/131240065159522367p"
Am I missing something? Thanks.
All errors thrown inside stored procedures are propagated as 400 (BadRequest). However, individual calls to the database like createDocument return the same error codes as the REST API.
For example, you can check the value of err.code === 409 inside your callback to validate that crateDocument failed due to a conflict. amd not something else.
err.code wouldn't work, Use err.number in your callback to handle known exception
Ex: err.number === 409 for conflict

HTTP.call throws errors instead of returning response

I am working with the Facebook graph API and have run into trouble regarding handling failed requests.
I use this code to create a new post
SocialFacebook.createPosting = function(data) {
var options = {
params: {
access_token : data.tokens.accessToken,
message : data.text
}
};
var url = 'https://graph.facebook.com/' + data.graphId + '/feed';
var response = HTTP.call('POST', url, options).data;
return response;
}
But instead of returning a JS object with error information in the response, it throws an error on failed requests
Exception while invoking method 'createPosting' Error: failed [500] {"error":{"message":"Duplicate status message","type":"FacebookApiException","code":506,"error_subcode":1455006,"is_transient":false,"error_user_title":"Duplicate Status Update","error_user_msg":"This status update is identical to the last one you posted. Try posting something different, or delete your previous update."}}
Because it's wrapped in an Error, the otherwise JSON object is now a string with some other stuff appended to it, which makes it difficult to parse and extract the attributes
Any idea as to why it throws an error, instead of returning a JS object with error details like usually?
Much appreciated
According to the docs, about HTTP.call():
On the server, this function can be run either synchronously or asynchronously. If the callback is omitted, it runs synchronously and the results are returned once the request completes successfully. If the request was not successful, an error is thrown.
So there you have it: since you called HTTP.call() synchronously (without providing a callback), if it responds with an error (in your case, Code 500) the error is thrown and not included in the data.

Exception type: EmptyPartException error in Biztalk

I am getting an error called Exception type: EmptyPartException error. My work is after the message is sent to the sendPort successfully, send an email. The Orchestration used is,
The ConstructMessage_3 constructs, SucessMessage which refers to the Multipart message SuccMsg which is of type System.Xml.XmlDocument.
Under Message_Assignment I have
SuccEmailPort(Microsoft.XLANGs.BaseTypes.Address) = "mailto:abc#gmail.com";
SucessMessage.SuccEmail = MsgVariable;
SucessMessage(SMTP.CC) = "abc#xyz.org";
SucessMessage(SMTP.Subject) = "Employee Feed";
SucessMessage(SMTP.From) = "BizTalk#sample.com";
SucessMessage(SMTP.EmailBodyText) = "The Upload Failed";
SucessMessage(SMTP.MessagePartsAttachments) = 1;
SucessMessage(SMTP.SMTPHost) = "smtp.mycompany.org";
SucessMessage(SMTP.SMTPAuthenticate) = 0;
SucessMessage(SMTP.EmailBodyTextCharset)="UTF-8";
SucessMessage.SuccEmail(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";
SucessMessage.SuccEmail(MIME.FileName) = "emp.txt";
Here MsgVariable refers to the Variable whose type is System.Xml.XmlDocument. When tried to send the message, the message is received but not the email. It shows me error like,
xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'ErrorHandling.Orchestration_1
The service instance will remain suspended until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
InstanceId:
Shape name: Send_3
ShapeId:
Exception thrown from: segment 2, progress 14
Inner exception: The part 'SuccEmail' of message 'SucessMessage' contains zero bytes of data.
Exception type: EmptyPartException
Am I doing the process right or is there any other way for doing this. What is the mistake I did here. Any help would be greatly appreciated.
In the expression shape add
SucessMessage = new System.Xml.XmlDocument();

Resources