exception when unpacking the field in JPOS - jpos

when i sent a request to server, at server log i am getting the correct result. this is my request to server as below
ISOMsg isoMsg = new ISOMsg();
isoMsg.setMTI(Constants.RequestType.MESSAGE_REQUEST.getValue());
isoMsg.set(3,Constants.Services.DEPOSIT_FUNDS_REQUEST.getValue());
isoMsg.set(4, depositFundRequest.getAmount().toString());
isoMsg.set(7, ISODate.getDateTime(today, TimeZone.getTimeZone("GMT+03")));
isoMsg.set(11, ServiceUtils.generate(6));
//isoMsg.set(12, "100629072055");
isoMsg.set(17, ISODate.getDate(today));
//isoMsg.set(24, "200");
isoMsg.set(32, "111111");
//isoMsg.set(35, "6278519999011712");
isoMsg.set(37, ServiceUtils.generate(12));
//isoMsg.set(41, "TERMID01");
//isoMsg.set(43, "11");
isoMsg.set(46,"00KESD000000000000500000000000D0000000000000000KES");
isoMsg.set(49,"KES");
isoMsg.set(102,depositFundRequest.getAccount());
isoMsg.set(123, userContextService.getCurrentUser());//UserId
isoMsg.set(126,Constants.Field126.CASH_IN.getValue());
channel.send (isoMsg);
ISOMsg responseMsg = channel.receive ();
But while incoming at client side i am getting the following exception.
org.jpos.iso.ISOException: org.jpos.iso.IFA_LLCHAR: Problem unpacking field 43 (java.lang.NegativeArraySizeException) unpacking field=43, consumed=97
I am using ASCII packager and BCD channel,please help me to resolve the exception

You can use org.jpos.iso.IFE_LLCHAR for field 43 in your packager.

Related

XMS.NET - Error while sending response back to reply queue/out queue

Regarding: “Sending response back to the out/reply queue.”
There is a requirement to send the response back to a different queue (reply queue).
While sending the response, we have to use the correlation and message id from the request message and pass it to the reply queue as header. I suspect the format of correlation/message id is wrong.
While reading the message, the correlation id and message id format are as below:
MessageId = “ID:616365323063633033343361313165646139306638346264”
CorrelationId = “ID:36626161303030305f322020202020202020202020202020”
While sending the back to out/reply queue, we are passing these ids as below:
ITextMessage txtReplyMessage = sessionOut.CreateTextMessage();
txtReplyMessage.JMSMessageID = “616365323063633033343361313165646139306638346264”;
txtReplyMessage.JMSCorrelationID = “36626161303030305f322020202020202020202020202020”;
txtReplyMessage.Text = sentMessage.Contents;
txtReplyMessage.JMSDeliveryMode = DeliveryMode.NonPersistent;
txtReplyMessage.JMSPriority = sentMessage.Priority;
messagePoducerOut.Send(txtReplyMessage);
Please note:
With the XMS.NET library, we need to pass the correlation and message id in string format as per shown above
With MQ API’s (which we were using earlier) passing the correlation and message ids we use to send in bytes format like below:
MQMessage queueMessage = new MQMessage();
string[] parms = document.name.Split('-');
queueMessage.MessageId = StringToByte(parms[1]);
queueMessage.CorrelationId = StringToByte(parms[2]);
queueMessage.CharacterSet = 1208;
queueMessage.Encoding = MQC.MQENC_NATIVE;
queueMessage.Persistence = 0; // Do not persist the replay message.
queueMessage.Format = "MQSTR ";
queueMessage.WriteString(document.contents);
queueOut.Put(queueMessage);
queueManagerOut.Commit();
Please help to troubleshoot the problem.
Troubleshooting is a bit difficult because you haven’t clearly specified the trouble (is there an exception, or is the message just not be correlated successfully?).
In your code you have missed to add the “ID:” prefix. However, to address the requirements, you should not need to bother too much about what is in this field, because you simply need to copy one value to the other:
txtReplyMessage.JMSCorrelationID = txtRequestMessage.JMSMessageID
A bit unclear what the issue is. Are you able to run the provided examples in the MQ tools/examples? This approach uses tmp queues(AMQ.*) as JMSReplyTo
Start the "server" application first.
Request/Response Client: "SimpleRequestor"
Request/Response Server: "SimpleRequestorServer"
You can find the exmaples at the default install location(win):
"C:\Program Files\IBM\MQ\tools\dotnet\samples\cs\xms\simple\wmq"
The "SimpleMessageSelector" will show how to use the selector pattern.
Note the format on the selector: "JMSCorrelationID = '00010203040506070809'"
IBM MQ SELECTOR

Error performing esp-idf OTA update from AWS S3

I'm trying to perform an OTA update with esp-idf by downloading firmware from an S3 bucket. I'm using the following provided snippet:
esp_http_client_config_t config = {
.url = "https://my-bucket-name-here.s3.amazonaws.com/firmware.bin",
.cert_pem = (char *)server_cert_pem_start,
.event_handler = _http_event_handler,
};
esp_err_t ret = esp_https_ota(&config);
if (ret == ESP_OK) {
esp_restart();
} else {
ESP_LOGE(TAG, "Firmware upgrade failed");
}
When put that URL in my browser or wget it, the file downloads fine. However, the download fails on the ESP32. I get the following message:
␛[0;31mE (1043) esp-tls: couldn't get hostname for :my-bucket-name-here.s3.amazonaws.com:␛[0m
␛[0;31mE (1053) esp-tls: Failed to open new connection␛[0m>
␛[0;31mE (1063) TRANS_SSL: Failed to open a new connection␛[0m
␛[0;31mE (1063) HTTP_CLIENT: Connection failed, sock < 0␛[0m
␛[0;31mE (1073) esp_https_ota: Failed to open HTTP connection: ERROR␛[0m
␛[0;31mE (1073) esp_https_ota: Failed to establish HTTP connection␛[0m
␛[0;31mE (1083) subpub: Firmware upgrade failed␛[0m
I was able to track it down to the function that throws the first error. It's thrown by resolve_host_name() in esp_tls.c here. Specifically, the error occurs in this chunk of code:
if (getaddrinfo(use_host, NULL, &hints, address_info)) {
ESP_LOGE(TAG, "couldn't get hostname for :%s:", use_host);
free(use_host);
return ESP_ERR_ESP_TLS_CANNOT_RESOLVE_HOSTNAME;
}
Any clue why getaddrinfo wouldn't be able to resolve an S3 bucket address? I thought I might have used the wrong certificate, but this seems to be before the certificate is even used.
Can you log your Heap sizes before and after the request.
esp_get_free_heap_size();
esp_get_minimum_free_heap_size();
You would need probably 40K of heap available before making https/tls request.
If anyone from the future runs into this problem while trying the example from esp-idf, the problem is that xTaskCreate(&simple_ota_example_task, "ota_example_task", 8192, NULL, 5, NULL); is called before wifi is fully set up. I have an event_handler function for wifi, and creating the task after a SYSTEM_EVENT_STA_GOT_IP event worked for me.

Why would Kafka Stream app crash with suppress() enabled?

I'm writing a kafka stream 2.3.0 application to count the number of events in a session window and hopefully to print out only the final record when a session times out.
Serde<String> stringSerde = Serdes.serdeFrom(new StringSerializer(), new StringDeserializer());
Serde<MuseObject> museObjectSerde = Serdes.serdeFrom(new MuseObjectSerializer(), new MuseObjectDeserializer());
StreamsBuilder builder = new StreamsBuilder();
builder
.stream(INPUT_TOPIC, Consumed.with(stringSerde, museObjectSerde))
.map((key, value) -> {
return KeyValue.pair(value.getSourceValue("vid"), value.toString());
})
.groupByKey(Grouped.with(Serdes.String(), Serdes.String()))
.windowedBy(SessionWindows.with(Duration.ofSeconds(INACTIVITY_GAP)).grace(Duration.ZERO))
.count(Materialized.with(Serdes.String(), Serdes.Long()))
.suppress(Suppressed.untilWindowCloses(Suppressed.BufferConfig.unbounded()))
.toStream()
.print(Printed.toSysOut());
However the application crashes when a session times out:
12:35:03.859 [kafka-producer-network-thread | kafka-streams-test-kgu-4c3f2398-8f67-429d-82ce-6062c86af466-StreamThread-1-producer] ERROR o.a.k.s.p.i.RecordCollectorImpl - task [1_0] Error sending record to topic kafka-streams-test-kgu-KTABLE-SUPPRESS-STATE-STORE-0000000008-changelog due to The server experienced an unexpected error when processing the request.; No more records will be sent and no more offsets will be recorded for this task. Enable TRACE logging to view failed record key and value.
org.apache.kafka.common.errors.UnknownServerException: The server experienced an unexpected error when processing the request.
12:35:03.862 [kafka-streams-test-kgu-4c3f2398-8f67-429d-82ce-6062c86af466-StreamThread-1] ERROR o.a.k.s.p.i.AssignedStreamsTasks - stream-thread [kafka-streams-test-kgu-4c3f2398-8f67-429d-82ce-6062c86af466-StreamThread-1] Failed to commit stream task 1_0 due to the following error:
org.apache.kafka.streams.errors.StreamsException: task [1_0] Abort sending since an error caught with a previous record (key user01\x00\x00\x01m!\xCE\x99u\x00\x00\x01m!\xCE\x80\xD1 value null timestamp null) to topic kafka-streams-test-kgu-KTABLE-SUPPRESS-STATE-STORE-0000000008-changelog due to org.apache.kafka.common.errors.UnknownServerException: The server experienced an unexpected error when processing the request.
at org.apache.kafka.streams.processor.internals.RecordCollectorImpl.recordSendError(RecordCollectorImpl.java:138)
I've tried to comment out ".suppress..." line. It works fine without suppress() and prints out something like this
[KSTREAM-FILTER-0000000011]: [user01#1568230244561/1568230250869], MuseSession{vid='user01', es='txnSuccess', count=6, start=2019-06-26 17:11:02.937, end=2019-06-26 18:07:10.685, sessionType='open'}".
What did I miss in using suppress()? Is there another way to filter out only the session records that have been timed out?
Any help is appreciated. Thanks in advance.
suppress() requires at least broker version 0.11.0 and message format 0.11.

What is the correct way of adding RFH2 header to IBM MQ message

I have recently started working with IBM MQ (v7.5) and currently working on a bridge like service for 2 way data transfer between MQ & another REST service I have.
By using standard APIs I am able to read and write messages without any issue.
But the problem I am facing came when I started setting up MQRFH2 header to my messages. I must be doing some mistake while writing data with header because every time I am getting "End of file exception ('MQMessage.seek()')." error while reading those messages.
This is my code snippet while putting the message into MQ:
//Constructing message
MQMessage sendmsg = new MQMessage();
sendmsg.characterSet = 1208;
sendmsg.format = MQC.MQFMT_STRING;
sendmsg.feedback = MQC.MQFB_NONE;
sendmsg.messageType = MQC.MQMT_DATAGRAM;
sendmsg.replyToQueueName = outputBackupQueueName;
sendmsg.replyToQueueManagerName = queueManager;
//Constructing header
MQRFH2 rfh2 = new MQRFH2();
rfh2.setEncoding(MQConstants.MQENC_NATIVE);
rfh2.setCodedCharSetId(MQConstants.MQCCSI_INHERIT);
rfh2.setFormat(MQConstants.MQFMT_STRING);
rfh2.setNameValueCCSID(1208);
//adding message to header
rfh2.write(sendmsg);
//payload is the actual data which we want to send
byte[] messageBytes = payload.getBytes("UTF-8");
sendmsg.write(messageBytes);
//putting message to MQ
MQPutMessageOptions outputMsgOpt = new MQPutMessageOptions();
outputMsgOpt.options = MQConstants.MQPMO_FAIL_IF_QUIESCING |
MQConstants.MQPMO_DEFAULT_CONTEXT |
MQConstants.MQPMO_SYNCPOINT;
outputQueue.put(sendmsg, outputMsgOpt);
queueManager.commit();
And this is how I am trying to retrieve it later:
MQMessage incomingMessage = new MQMessage();
byte[] incomingMessageId = incomingMessage.messageId;
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQConstants.MQGMO_FAIL_IF_QUIESCING |
MQConstants.MQGMO_CONVERT |
MQConstants.MQGMO_SYNCPOINT |
MQConstants.MQGMO_LOGICAL_ORDER |
MQConstants.MQGMO_ALL_MSGS_AVAILABLE |
MQConstants.MQGMO_WAIT;
inputQueue.get(incomingMessage, gmo);
MQRFH2 myRfh2 = new MQRFH2(incomingMessage); //this statement throws error with headers
Complete error message is:
com.ibm.mq.headers.MQDataException: MQJE001: Completion Code '2', Reason '2195'.
at com.ibm.mq.headers.MQDataException.getMQDataException(MQDataException.java:317)
at com.ibm.mq.headers.internal.Header.read(Header.java:620)
at com.ibm.mq.headers.MQRFH2.<init>(MQRFH2.java:113)
at com.simility.util.MQRfh2HeaderHelper.getMsgByteArray(MQRfh2HeaderHelper.java:16)
at com.simility.mq.SimilityMQBridge.main(SimilityMQBridge.java:182)
Caused by: com.ibm.mq.headers.MQDataException: MQJE001: Completion Code '2', Reason '6114'.
at com.ibm.mq.headers.MQDataException.getMQDataException(MQDataException.java:314)
at com.ibm.mq.headers.MQRFH2.read(MQRFH2.java:184)
at com.ibm.mq.headers.internal.Header.read(Header.java:639)
at com.ibm.mq.headers.internal.Header.read(Header.java:617)
... 3 more
Caused by: java.io.EOFException: MQJE086: End of file exception ('MQMessage.seek()').
at com.ibm.mq.MQMessage.seek(MQMessage.java:716)
at com.ibm.mq.headers.internal.store.MQMessageStore.readFrom(MQMessageStore.java:274)
at com.ibm.mq.headers.internal.Header.read(Header.java:661)
at com.ibm.mq.headers.MQRFH2.read(MQRFH2.java:181)
Another thing I verified is message length by "TotalMessageLength", and that matches between reading and writing the messages, but still the failure happens.
Can anyone please help me out or point me in right direction related to adding and retrieving messages with RFH2 header ?
Another thing I verified is message length by "TotalMessageLength",
and that matches between reading and writing the messages, but still
the failure happens.
Does the method "getMessageLength()" of MQMessage return the data length of the payload?
Why don't you try (in the sender):
byte[] messageBytes = payload.getBytes();
If your data is not the same codepage or encoding then let MQ do the work rather than you doing getBytes("UTF-8").
i.e. Set the Encoding and CCSID to what the data is.
rfh2.setEncoding(???);
rfh2.setCodedCharSetId(???);

Exchange Web Services API 1.0 Error

I'm getting the following error when trying to connect to my exchange server at Microsoft Online. I couldn't see how to get access to the underlying XML and I wondered if this error is caused because exchange is just serving the standard OWA login form, rather than an XML response that the EWS API expects. How can I check this?
This is the error, thrown on the the last line of my code:
'>' is an unexpected token. The expected token is '"' or '''. Line 7, position 62.
This is my code:
Dim ews As New ExchangeService
ews.Credentials = New WebCredentials("mytestmailbox#mydomain.com", "mypassword")
ews.Url = New Uri("https://mysubdomain.microsoftonline.com")
'send a test message
Dim message As New EmailMessage(ews)
message.Subject = "Hello World!"
message.Body = "This is a test message"
message.ToRecipients.Add("some#email.com")
message.SendAndSaveCopy()
I fixed this by changing the Uri to the following: https://servername/ews/Exchange.asmx

Resources