Sending metadata when gRPC connection is getting establised - java

I am looking for some mechanism in which I can send some metadata(key: value) when the gRPC connection is being established. That means, only once per connection.
I know how to send it per RPC but not sure how to so it per connection level.
Any help will be appreciated.
PS: I am working in Java framework.

Related

Apache Camel Netty Tcp Component send and receive

I'm struggleing while using the Apache Camel Netty Component. I want connect to a different system using a minimal route like this:
from("netty:tcp://localhost:4314?clientMode=true")
.log("${body}")
.end();
My Problem is, that in order to receive any data I have to send some subscription message using the same connection.
A similar Problem was easy to solve, when the connection was made via ActiveMQ, where you could take the connection Factory and make a seperate connection for the subscription.
I have found this Question: How to send a response back over a established TCP connection in async mode using Apache Camel Netty4?
but it only work if you can receive something before you can reply.
How can I send data, using the same Channel as the route ?
Thank you for your help !

How to track/monitor socket connection in spring boot?

We have a spring boot (with zuul) app using default embedded tomcat (I think). It has many clients implemented with different technologies and languages. And we have problem with too many port in TIME_WAIT: i.e. too many socket connections are opened/closed w.r.t the expected request behavior that should keep connections alive most of the time.
By retrieving the HttpRequest object in the deployed API, I can get information on the request header. This way I can track the http protocol used (http/1.1) and header parameter such as keep-alive (which, if present, is redundant with the use of http/1.1).
=> I would like to track opened and closed socket connections, but I don't see how?
Intermediate information would be better than nothing.
Note: I found some tutorial on a similar topic when using spring-websocket, but we don't.

SocketTimedOut when connecting to https Url through CXF

I am facing a problem with CXF framework trying to connect to a https backend service. Since the service is out side of my network I am using a proxy to connect. I am getting a SocketTimedOutException when I set the readTimeout Value to like 60000 which is the default. When I set the timeout to 0(infinite) it gives a connectionResetException after a while. I wrote a program on my own which used HttpsUrlConnection to connect to the same service with proxy and I am able to work with it.
I was initially under the feeling that the connection itself was not happening but later I came to know that that would have thrown a ConnectException rather than a socketException. It gave me some relief , but I want to know how I can deal with the SocketException, both the timeout and the Connection Reset.
Please explain to me whoever knows about this.
Thanks,
Sachin
You should blame on your network or your proxy, but not your codes. SocketTimedOutException and ConnectionTimedOutException are thrown when network is blocked or weak. So, the solution to both exceptions is smoothening your network.

JMS Connection Overhead

How much is the overhead of creating following objects everytime sending the message to queue?
Objects: javax.jms.Connection, javax.jms.Session, javax.jms.MessageProducer
In my code, Whenever I want to send a message, I am creating above 3 objects.
I know its good to create object only once and use it but the connection/session goes into IllegalState after Server Failover. My connectionFactory is able to reconnect but it is not able to refresh connection/session object.
Can someone please explain me the overhead?
https://developer.jboss.org/wiki/ShouldICacheJMSConnectionsAndJMSSessions
High Performance JMS Messaging
:)
It is always a costly affair to create a connection and session to a messaging provider every time. Every time a connection is requested, the underlying messaging library has to create a socket connection to messaging provider, flow some handshake data and establish a channel using which messages can be sent. After message is sent, connection close also requires some messaging provider specific data to be sent across to gracefully close connections.
You can quantify the overhead by running some tests with and without creating connections/session every time. But the above explanation gives a hint on what would be involved in creating/closing a connection.

How to use Netty clients within Netty server

I'm going to create an authentication server which itself interacts with
a set of different Oauth2.0 servers.
Netty seems to be a good candidate to implement network part here.
But before start I need to clear some details about netty as I'm new to it.
The routine will be as follows:
The server accepts an HTTPS connection from a client.
Then, not closing this first connection, it makes another connection
via HTTPS to a remote Oauth2.0 server and gets data
After all, the server sends the result back to the client which is supposed to keep the connection alive.
How to implement this scenario with Netty?
Do I have to create a new netty client and/or reconnect it each time I need to connect to a remote Oauth2.0 server?
If so, I'll have to create a separate thread for every
outgoing connection which will drastically reduce performance.
Another scenario is to create a sufficient number of Netty clients
within a server at the beginning (when server starts)
and keep them constantly connected to the Oauth2.0 servers via HTTPS.
That's easily done with Netty. First you set up your Netty server using the ServerBootstrap and then in a ChannelHandler that handles your connection from the client you can use e.g. the client Bootstrap to connect to the OAuth server and fetch the data. You don't need to worry about creating threads or similar. You can do it all in a non-blocking fashion. Take a look at and try to understand how this example works:
https://github.com/netty/netty/blob/master/example/src/main/java/io/netty/example/proxy/HexDumpProxyFrontendHandler.java#L44.

Categories