What is RFH header in MQ messages and its purpose - java

When I am writing message in MQ queue through JMS, RFH header is also getting added with message as its property.
Property including
Jms delivery Mode
JMS Destination
JMS Timestamp
Mcd.msd
Can anyone explain me its use and significance?

The RFH header only allow for a single header to exist in a message, and the RFH2 header allow multiples headers to exist in a message.
I'm not going to explain, this site explained it better than I can :
New Link (previous one was not working anymore)
https://docs.actian.com/dataconnect/11.4/index.html#page/User/RFH_Header_Support_3a_Websphere_MQ.htm
I hope it will help you !

Related

In gmail api get message, how do prevent getting the previous message chain when getting current message? [duplicate]

I'm using the Gmail RESTful API directly (not from some library).
Looking at the documentation here Gmail Documentation.
I have managed to get the content of the message body, however it also returns the whole history chain for the current message.
Is there a way to get a response from the API only the requested message body, without the whole thread history?
According to this thread, it is not possible because it is part of the email's body content and you're specifying the ID of the message to retrieve.
You are getting the full reply message. When the report replied, they quoted the original message and this the text of the original is in the reply message. You may just want to do what Gmail and many other modern emails apps do and collapse/hide any reply text which begins with >.
References:
How to get the reply message without the original message from the Gmail API
GMAIL API : How to get the reply without the original message
Most efficient way to get new messages

'AWS S3 Key header missing' error when trying to upload file to Amazon S3 Using Apache Camel

I am attempting to upload a csv file from a local directory to AWS S3 using Apache Camel.
Referencing the documentation found here (https://camel.apache.org/staging/components/latest/aws-s3-component.html), I tried to create a simple route like so (I have of course removed keys and other identifying information and replaced them with [FAKE_INFO]):
from("file:fileName=${in.headers[fileName]}")
.to("aws-s3://[BUCKET]?accessKey=[ACCESS_KEY]&secretKey=RAW([SECRET_KEY])&region=US_EAST_2&prefix=TEST.csv");
This results in the following error:
error: java.lang.IllegalArgumentException: AWS S3 Key header missing apache camel
After searching a bit online I removed the prefix that is passed and instead inserted a .setHeader to route like so:
from("file:fileName=${in.headers[fileName]}")
.setHeader(S3Constants.KEY, simple("TEST.csv"))
.to("aws-s3://[BUCKET]?accessKey=[ACCESS_KEY]&secretKey=RAW([SECRET_KEY])&region=US_EAST_2");
This works fine, as long as I am willing to hard code everything after the setHeader. However, for my particular use case I need to pass items from the exchange headers to feed the keys, bucket name, and fileName (this route is used by multiple files that go to different buckets based on different criteria which is received in the exchange headers). For some reason as soon as use setHeader to set the S3Constants.KEY, I am no longer able to access any of the exchange headers - in fact, I can't even assign the S3Constants.KEY value from an exchange header. As you can see, the fileName in the from section is assigned via an exchange header and I don't run into any issues there, so I know they are being received into the route.
Any thoughts on how I can modify this route so that it will allow me to upload files without the S3Constants and using exchange headers where appropriate?
Not sure if I understand you correct, but it sounds to me that
The problem of the question subject is already solved
Your only problem is the static destination address you want to have dynamic
To define dynamic destination addresses, there is a "dynamic to"
.toD(...)
You can use for example simple expressions in such a dynamic destination address
.toD("aws-s3://${in.header.bucket}?region=${in.header.region}&...")
See the Camel Docs (section "Dynamic To") for more details.
By the way: you write about "exchange headers". Don't confuse Exchange properties with Message headers!
Exchange properties are on the Exchange wrapper only and therefore lost with the Exchange after the Camel route has finished processing.
Message headers are on the message itself and therefore they are kept on the message even after routing it to a queue or whatever endpoint. This also implies that headers must be serializable.
You must access these two types differently. For example in Simple you get a header from the inbound message with ${in.header.myHeader} while you get an Exchange property with ${exchangeProperty.myProperty}

Auto-Replies to an email ,from gmail don't have 'In-Reply-To' and 'References' header

When an Auto-Reply Message is generated by Gmail for a message, the auto-reply message is not Threaded like a normal reply and the auto-reply message does not contain In-Reply-To: and References: header in its Headers Payload. The ThreadID of the auto-reply is different than its original message (unlike a normal reply where ThreadID remains same)
Which logic should we use to co-relate an auto-reply to its original message? In Other words, how do we figure out to which message is an auto-reply for?
Using Gmail API
There will be a portion of the subject of the auto-reply that matches the subject of the received email. Also, the timestamp will be close but later than the timestamp of the received email. It's not perfect, but should be functional.

Process HTTP MIME REST message in java

I am debugging an application which gets a bad Request, Response from JAX-RS. I have monitored the HTTP message using TCPMon and figured out that The MIME boundary in Header does not match the Boundary in message parts.
What I am trying to do is, Writing a simple java program that changes that boundary of the message part according to the header MIME boundary.
but When I edit the String and sent it back to the JAX-RS service I get errors like Unexpected EndOfLine,Uxexpected EOF.
What I did was , opened a server socket and read the message from incoming connection from my application and edited the MIME boundary of Message parts
String mimeBoundary = message.toString().split("\r\n")[5].split(";")[1].split("=")[1];
message.replace(message.indexOf("MIMEBoundary"), message.indexOf("MIMEBoundary")+61,mimeBoundary);
message.replace(message.indexOf("MIMEBoundary"),message.indexOf("MIMEBoundary")+61,mimeBoundary);
And send the Message(String) to the JAX-RS service.
What am I doing wrong here? someone please help.
Thank You.

Error in a middle of writing to outputstream handling

I'm building an httpserver as part of my academic java course,
The server should only support basic GET and POST requests.
I was wondering if there's an elegant way to handle an error which occures in the middle of writing an html file stream content (and after I've already sent the response headers) into the HttpServer output stream.
By elegant way I refer to showing or redirecting the user to a "Internal Server Error" error page.
I tried re-sending the http response headers with 501 error code, but java throws an exception which claims that the headers were already sent...
One fix would be to read the file's contents into memory, and only then sending the headers and the content, but other problems can arise, and furthermore, I don't want to load huge files into the memory before sending them out as a response.
Once the response status is sent on the wire, it cannot be changed. So if you sent a 200 OK response, you cannot change your mind afterwards. As you found, this presents a problem in case of errors that occur mid response.
As far as I know, the only think you can do is to send a chunked response. See section 3.6.1 of RFC 2616:
The chunked encoding modifies the body of a message in order to
transfer it as a series of chunks, each with its own size indicator,
followed by an OPTIONAL trailer containing entity-header fields. This
allows dynamically produced content to be transferred along with the
information necessary for the recipient to verify that it has received
the full message.
The purpose of this trailer is to give information about the entity body that cannot be calculated before the entity body is sent. However, section 7.1 allows any header to be included in this trailer:
The extension-header mechanism allows additional entity-header fields
to be defined without changing the protocol, but these fields cannot
be assumed to be recognizable by the recipient. Unrecognized header
fields SHOULD be ignored by the recipient and MUST be forwarded by
transparent proxies.
So while you can signal that an error has occurred mid response, it must be conventioned between the two parts how this is signaled. You cannot, in general, use any method you can assume the client will understand as signaling an error condition.
Ending the connection prematurely in a message with a Content-length header is an option, but one that is explicitly forbidden:
When a Content-Length is given in a message where a message-body is
allowed, its field value MUST exactly match the number of OCTETs in
the message-body. HTTP/1.1 user agents MUST notify the user when an
invalid length is received and detected.
That said, while the server must not send a message shorter than he advertises, the client must check for this error condition and reported as such (and proxies may even cache this partial response).
By elegant way I refer to showing or redirecting the user to a
"Internal Server Error" error page.
If you can't send the 'success' response how are you going to send a different response? All you can do is log it and forget about it.

Categories